Slang Test (slang-test
) is a command-line tool that coordinates and runs the Slang test suite. It acts as a test runner hub, executing various types of tests and collecting their results.
slang-test [options] [test-prefix...]
If no test prefix is specified, all tests will be run. Test prefixes can be used to filter which tests to run, and include the path with directories separated by '/'.
Example:
slang-test -bindir path/to/bin -category full tests/compute/array-param
-h, --help
: Show help message-bindir <path>
: Set directory for binaries (default: the path to the slang-test executable)-test-dir <path>
: Set directory for test files (default: tests/)-v
: Enable verbose output-verbose-paths
: Use verbose paths in output-hide-ignored
: Hide results from ignored tests
-category <name>
: Only run tests in specified category-exclude <name>
: Exclude tests in specified category
Available test categories:
full
: All testsquick
: Quick testssmoke
: Basic smoke testsrender
: Rendering-related testscompute
: Compute shader testsvulkan
: Vulkan-specific testscompatibility-issue
: Tests for compatibility issues
A test may be in one or more categories. The categories are specified on top of a test, for example: //TEST(smoke,compute):COMPARE_COMPUTE:
-api <expr>
: Enable specific APIs (e.g., 'vk+dx12' or '+dx11')-api-only
: Only run tests that use specified APIs-synthesizedTestApi <expr>
: Set APIs for synthesized tests-skip-api-detection
: Skip API availability detection
API expression syntax:
- Use
+
or-
to add or remove APIs from defaults - Examples:
vk
: Vulkan only+vk
: Add Vulkan to defaults-dx12
: Remove DirectX 12 from defaultsall
: All APIsall-vk
: All APIs except Vulkangl+dx11
: Only OpenGL and DirectX 11
Available APIs:
- OpenGL:
gl
,ogl
,opengl
- Vulkan:
vk
,vulkan
- DirectX 12:
dx12
,d3d12
- DirectX 11:
dx11
,d3d11
-server-count <n>
: Set number of test servers (default: 1)-use-shared-library
: Run tests in-process using shared library-use-test-server
: Run tests using test server-use-fully-isolated-test-server
: Run each test in isolated server
-appveyor
: Use AppVeyor output format-travis
: Use Travis CI output format-teamcity
: Use TeamCity output format-xunit
: Use xUnit output format-xunit2
: Use xUnit 2 output format-show-adapter-info
: Show detailed adapter information
-generate-hlsl-baselines
: Generate HLSL test baselines-emit-spirv-via-glsl
: Emit SPIR-V through GLSL instead of directly-expected-failure-list <file>
: Specify file containing expected failures
Tests are identified by a special comment at the start of the test file: //TEST:<type>:
Available test types:
SIMPLE
: Runs the slangc compiler with specified options after the commandREFLECTION
: Runs slang-reflection-test with the options specified after the commandCOMPARE_COMPUTE
: Runs render-test to execute a compute shader and writes the result to a text file. The test passes if the output matches the expected contentCOMPARE_COMPUTE_EX
: Same as COMPARE_COMPUTE, but supports additional parameter specificationsCOMPARE_RENDER_COMPUTE
: Runs render-test with "-slang -gcompute" options and compares text file outputsLANG_SERVER
: Tests Language Server Protocol features by sending requests (like completion, hover, signatures) and comparing responses with expected outputs
Deprecated test types (do not create new tests of these kinds, and we need to slowly migrate existing tests to use SIMPLE, COMPARE_COMPUTE(_EX) or COMPARE_RENDER_COMPUTE instead):
COMPARE_HLSL
: Runs the slangc compiler with forced DXBC output and compares with a file having the '.expected' extensionCOMPARE_HLSL_RENDER
: Runs render-test to generate two images - one using HLSL (expected) and one using Slang, saving both as .png files. The test passes if the images matchCOMPARE_HLSL_CROSS_COMPILE_RENDER
: Runs render-test to generate two images - one using Slang and one using -glsl-cross. The test passes if the images matchCOMPARE_HLSL_GLSL_RENDER
: Runs render-test to generate two images - one using -hlsl-rewrite and one using -glsl-rewrite. The test passes if the images matchCOMPARE_GLSL
: Runs the slangc compiler both through Slang and directly, then compares the SPIR-V assembly outputHLSL_COMPUTE
: Runs render-test with "-hlsl-rewrite -compute" options and compares text file outputsCROSS_COMPILE
: Compiles using GLSL pass-through and through Slang, then compares the outputs
In addition to the above test tools, there are also slang-unit-test-tool
and gfx-unit-test-tool
, which are invoked as in the following examples.
# Regular unit tests
slang-test slang-unit-test-tool/<test-name>
# e.g. run the `byteEncode` test.
slang-test slang-unit-test-tool/byteEncode
These tests are located in the tools/slang-unit-test directory, and defined with macros like SLANG_UNIT_TEST(byteEncode)
.
# Graphics unit tests
slang-test gfx-unit-test-tool/<test-name>
# e.g. run the `precompiledTargetModule2Vulkan` test.
slang-test gfx-unit-test-tool/precompiledTargetModule2Vulkan
These tests are located in tools/gfx-unit-test, and likewise defined using macros like SLANG_UNIT_TEST(precompiledTargetModule2Vulkan)
.