Add incrementality unit tests for all generators
このコミットが含まれているのは:
1 親
49b1ac7c79
コミット
2fcfaafc63
4ファイル変更
+250
-2
検索条件に一致するファイルはありません
+98
@@ -0,0 +1,98 @@
|
||||
using ComputeSharp.SourceGenerators;
|
||||
using ComputeSharp.Tests.SourceGenerators.Helpers;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.Tests.SourceGenerators;
|
||||
|
||||
[TestClass]
|
||||
public class Test_ComputeShaderDescriptorGenerator_Incrementality
|
||||
{
|
||||
[TestMethod]
|
||||
public void AddedStatement_ModifiesOutput()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MyShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
const string updatedSource = """
|
||||
using ComputeSharp;
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MyShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
buffer[ThreadIds.X] *= 2.0;
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpGeneratorTest<ComputeShaderDescriptorGenerator>.VerifyIncrementalSteps(
|
||||
source,
|
||||
updatedSource,
|
||||
executeReason: IncrementalStepRunReason.Modified,
|
||||
diagnosticsReason: null,
|
||||
outputReason: IncrementalStepRunReason.Modified,
|
||||
diagnosticsSourceReason: null,
|
||||
sourceReason: IncrementalStepRunReason.Modified);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddedComment_DoesNotModifyOutput()
|
||||
{
|
||||
const string source = """
|
||||
using ComputeSharp;
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MyShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
const string updatedSource = """
|
||||
using ComputeSharp;
|
||||
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MyShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
// Some dummy comment
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
CSharpGeneratorTest<ComputeShaderDescriptorGenerator>.VerifyIncrementalSteps(
|
||||
source,
|
||||
updatedSource,
|
||||
executeReason: IncrementalStepRunReason.Unchanged,
|
||||
diagnosticsReason: null,
|
||||
outputReason: IncrementalStepRunReason.Cached,
|
||||
diagnosticsSourceReason: null,
|
||||
sourceReason: IncrementalStepRunReason.Cached);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする