summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test.bat1
-rw-r--r--tools/slang-test/main.cpp52
2 files changed, 31 insertions, 22 deletions
diff --git a/test.bat b/test.bat
index f21dcbbfb..6c6e88580 100644
--- a/test.bat
+++ b/test.bat
@@ -56,4 +56,3 @@ SET "PATH=%PATH%;%SLANG_TEST_BIN_DIR%"
:: TODO: Maybe we should actually invoke `msbuild` to make sure all the code is up to date?
"%SLANG_TEST_BIN_DIR%slang-test.exe" -bindir "%SLANG_TEST_BIN_DIR%\" %*
-"%SLANG_TEST_BIN_DIR%slang-test.exe" -bindir "%SLANG_TEST_BIN_DIR%\" -unitTests
diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp
index a4b903e25..654b18f85 100644
--- a/tools/slang-test/main.cpp
+++ b/tools/slang-test/main.cpp
@@ -113,9 +113,6 @@ struct Options
// By default we potentially synthesize test for all
// TODO: Vulkan is disabled by default for now as the majority as vulkan synthesized tests fail
RenderApiFlags synthesizedTestApis = RenderApiFlag::AllOf & ~RenderApiFlag::Vulkan;
-
- // Set this to turn on unit tests
- bool unitTests = false;
};
// Globals
@@ -286,10 +283,6 @@ Result parseOptions(int* argc, char** argv)
return res;
}
}
- else if (strcmp(arg, "-unitTests") == 0)
- {
- g_options.unitTests = true;
- }
else
{
fprintf(stderr, "unknown option '%s'\n", arg);
@@ -1845,6 +1838,7 @@ static bool endsWithAllowedExtension(
".tesc",
".tese",
".comp",
+ ".internal",
nullptr };
for( auto ii = allowedExtensions; *ii; ++ii )
@@ -1913,6 +1907,7 @@ int main(
auto vulkanTestCategory = addTestCategory("vulkan", fullTestCategory);
+ auto unitTestCatagory = addTestCategory("unit-test", fullTestCategory);
// An un-categorized test will always belong to the `full` category
g_defaultTestCategory = fullTestCategory;
@@ -1944,8 +1939,14 @@ int main(
context.m_dumpOutputOnFailure = g_options.dumpOutputOnFailure;
context.m_isVerbose = g_options.shouldBeVerbose;
-
- if (g_options.unitTests)
+
+ // Enumerate test files according to policy
+ // TODO: add more directories to this list
+ // TODO: allow for a command-line argument to select a particular directory
+ runTestsInDirectory(&context, "tests/");
+
+ // Run the unit tests (these are internal C++ tests - not specified via files in a directory)
+ // They are registered with SLANG_UNIT_TEST macro
{
TestContext::set(&context);
@@ -1953,26 +1954,35 @@ int main(
TestRegister* cur = TestRegister::s_first;
while (cur)
{
- context.startTest(cur->m_name);
-
- // Run the test function
- cur->m_func();
+ StringBuilder filePath;
+ filePath << "unit-tests/" << cur->m_name << ".internal";
- context.endTest();
+ TestOptions testOptions;
+ testOptions.categories.Add(unitTestCatagory);
+ testOptions.command = filePath;
+ if (shouldRunTest(&context, testOptions.command))
+ {
+ if (testPassesCategoryMask(&context, testOptions))
+ {
+ context.startTest(testOptions.command);
+ // Run the test function
+ cur->m_func();
+ context.endTest();
+ }
+ else
+ {
+ context.addTest(testOptions.command, TestResult::Ignored);
+ }
+ }
+
// Next
cur = cur->m_next;
}
TestContext::set(nullptr);
}
- else
- {
- // Enumerate test files according to policy
- // TODO: add more directories to this list
- // TODO: allow for a command-line argument to select a particular directory
- runTestsInDirectory(&context, "tests/");
- }
+
context.outputSummary();