summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorbspeice <bspeice@users.noreply.github.com>2025-01-01 18:26:43 -0800
committerGitHub <noreply@github.com>2025-01-01 18:26:43 -0800
commite3b71cf0356692bda5f0b3a06aed9d49ad3314a4 (patch)
tree6bb5dd847275f5f940d974727ef738cd296bf6c3 /tools
parenta13ef050996c2792ff3c16b6424d3a6336e56a58 (diff)
Allow explicit test root (#5980)
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-test/options.cpp15
-rw-r--r--tools/slang-test/options.h3
-rw-r--r--tools/slang-test/slang-test-main.cpp8
3 files changed, 21 insertions, 5 deletions
diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp
index 10f98f3a2..9dd831afa 100644
--- a/tools/slang-test/options.cpp
+++ b/tools/slang-test/options.cpp
@@ -327,6 +327,15 @@ static bool _isSubCommand(const char* arg)
optionsOut->expectedFailureList.add(line);
}
}
+ else if (strcmp(arg, "-test-dir") == 0)
+ {
+ if (argCursor == argEnd)
+ {
+ stdError.print("error: expected operand for '%s'\n", arg);
+ return SLANG_FAIL;
+ }
+ optionsOut->testDir = *argCursor++;
+ }
else
{
stdError.print("unknown option '%s'\n", arg);
@@ -365,5 +374,11 @@ static bool _isSubCommand(const char* arg)
}
}
+ if (optionsOut->testDir.getLength() == 0)
+ {
+ // If the test directory isn't set, use the "tests" directory
+ optionsOut->testDir = String("tests/");
+ }
+
return SLANG_OK;
}
diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h
index f84240c71..912e28465 100644
--- a/tools/slang-test/options.h
+++ b/tools/slang-test/options.h
@@ -51,6 +51,9 @@ struct Options
// Directory to use when looking for binaries to run. If empty it's not set.
Slang::String binDir;
+ // Root directory to use when looking for test cases
+ Slang::String testDir;
+
// only run test cases with names have one of these prefixes.
Slang::List<Slang::String> testPrefixes;
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 376d0e0bd..0987cbf80 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -4427,10 +4427,10 @@ void runTestsInParallel(TestContext* context, int count, const F& f)
context->setTestReporter(originalReporter);
}
-void runTestsInDirectory(TestContext* context, String directoryPath)
+void runTestsInDirectory(TestContext* context)
{
List<String> files;
- getFilesInDirectory(directoryPath, files);
+ getFilesInDirectory(context->options.testDir, files);
auto processFile = [&](String file)
{
if (shouldRunTest(context, file))
@@ -4865,9 +4865,7 @@ SlangResult innerMain(int argc, char** argv)
{
TestReporter::SuiteScope suiteScope(&reporter, "tests");
// 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/");
+ runTestsInDirectory(&context);
}
// Run the unit tests (these are internal C++ tests - not specified via files in a