Update unit test projects

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-19 16:45:13 +01:00
1 親 ea65177941
コミット a48290873e
7ファイル変更
+6 -165

検索条件に一致するファイルはありません

+3 -23
ファイルの表示
@@ -44,26 +44,6 @@ jobs:
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64
shell: cmd
# Build the whole ComputeSharp solution with /p:DisableShaderCompilationSupport=True
build-solution-release-no-dynamic:
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64 /p:DisableShaderCompilationSupport=True
shell: cmd
# Run all the unit tests referencing the ComputeSharp project directly
run-tests:
if: success()
@@ -84,7 +64,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET 6)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET 6)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
@@ -93,7 +73,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Core 3.1)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET Core 3.1)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
@@ -102,7 +82,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Framework 4.7.2)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET Framework 4.7.2)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
@@ -22,11 +22,6 @@
PrivateAssets="contentfiles;build" />
</ItemGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<!-- When the .NET Standard 2.0 version of ComputeSharp is resolved, the TerraFX APIs are internal, as they
are referenced from the shared project. The same reference is needed here to make all tests build fine. -->
<Import Condition="'$(TargetFramework)' != 'net6.0'" Project="..\..\src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" />
-47
ファイルの表示
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using ComputeSharp.Interop;
using ComputeSharp.Tests.Attributes;
using ComputeSharp.Tests.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -11,22 +10,10 @@ namespace ComputeSharp.Tests.DisableDynamicCompilation;
[TestCategory("Dispatch")]
public partial class DispatchTests
{
private static readonly bool IsDynamicCompilationDisabled =
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
true;
#else
false;
#endif
[CombinatorialTestMethod]
[AllDevices]
public void ComputeShader_Test_Ok(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
float[] array = Enumerable.Range(0, 128).Select(static i => (float)i).ToArray();
using ReadWriteBuffer<float> buffer = device.Get().AllocateReadWriteBuffer(array);
@@ -48,11 +35,6 @@ public partial class DispatchTests
[ExpectedException(typeof(NotSupportedException))]
public void ComputeShader_Test_Fail(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
using ReadWriteBuffer<float> buffer = device.Get().AllocateReadWriteBuffer<float>(128);
device.Get().For(128, 1, 1, 64, 1, 1, new ComputeShader(buffer, 2.0f));
@@ -76,11 +58,6 @@ public partial class DispatchTests
[AllDevices]
public void PixelShader_Test_Ok(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
using ReadWriteTexture2D<Rgba32, float4> texture = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(128, 128);
device.Get().ForEach(texture, new PixelShader(0.3f, 0.6f));
@@ -120,28 +97,4 @@ public partial class DispatchTests
return new(ThreadIds.Normalized.X, ThreadIds.Normalized.Y, b, a);
}
}
[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void ReflectionService_ComputeShader()
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
ReflectionServices.GetShaderInfo<ComputeShader>(out _);
}
[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void ReflectionService_PixelShader()
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
ReflectionServices.GetShaderInfo<PixelShader, float4>(out _);
}
}
+1 -6
ファイルの表示
@@ -4,12 +4,6 @@
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<DisableShaderCompilationSupport>false</DisableShaderCompilationSupport>
</PropertyGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<ItemGroup>
@@ -20,6 +14,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
-79
ファイルの表示
@@ -1,79 +0,0 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#pragma warning disable CS0618
namespace ComputeSharp.Tests.Internals;
[TestClass]
[TestCategory("ShaderBytecode")]
public partial class ShaderBytecodeTests
{
[TestMethod]
public void NonPrecompiledShader_Test()
{
Assert.IsFalse(((IComputeShader)default(NonPrecompiledShader)).TryGetBytecode(32, 1, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
internal readonly partial struct NonPrecompiledShader : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= factor;
}
}
[TestMethod]
public void ComputeShader_Test()
{
Assert.IsTrue(((IComputeShader)default(ComputeShader)).TryGetBytecode(32, 1, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsTrue(bytecode.Length > 0);
Assert.IsFalse(((IComputeShader)default(ComputeShader)).TryGetBytecode(64, 1, 1, out bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
[EmbeddedBytecode(32, 1, 1)]
internal readonly partial struct ComputeShader : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= factor;
}
}
[TestMethod]
public void PixelShader_Test()
{
Assert.IsTrue(((IPixelShader<float4>)default(PixelShader)).TryGetBytecode(8, 8, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsTrue(bytecode.Length > 0);
Assert.IsFalse(((IPixelShader<float4>)default(PixelShader)).TryGetBytecode(32, 1, 1, out bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
[EmbeddedBytecode(8, 8, 1)]
internal readonly partial struct PixelShader : IPixelShader<float4>
{
public readonly ReadWriteTexture2D<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public float4 Execute()
{
return buffer[ThreadIds.XY] * factor;
}
}
}
+1 -5
ファイルの表示
@@ -1,6 +1,4 @@
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System;
using ComputeSharp.Exceptions;
using ComputeSharp.Shaders.Translation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -47,5 +45,3 @@ public class ShaderCompilerTests
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan());
}
}
#endif
+1
ファイルの表示
@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"