diff options
| author | Yong He <yonghe@outlook.com> | 2024-12-10 03:49:38 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-10 19:49:38 +0800 |
| commit | 89bf795f105ebe2703ee74a021e16786990ca7b2 (patch) | |
| tree | 59f9900680f40c6bd91a4511cdab032840c98336 /tools | |
| parent | b0dfb1aef2cd5483f59b858c8921707174ffdf2d (diff) | |
Fix a crash when search for files. (#5818)
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index ae6eb6216..376d0e0bd 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -524,6 +524,17 @@ static SlangResult _extractCommand(const char** ioCursor, UnownedStringSlice& ou } } +static void applyMacroSubstitution(String filePath, TestDetails& details) +{ + for (auto& arg : details.options.args) + { + arg = StringUtil::replaceAll( + arg.getUnownedSlice(), + toSlice("$dirname"), + Path::getParentDirectory(filePath).getUnownedSlice()); + } +} + // Try to read command-line options from the test file itself static SlangResult _gatherTestsForFile( TestCategorySet* categorySet, @@ -597,6 +608,7 @@ static SlangResult _gatherTestsForFile( if (command == "TEST") { SLANG_RETURN_ON_FAIL(_gatherTestOptions(categorySet, &cursor, testDetails.options)); + applyMacroSubstitution(filePath, testDetails); // See if the type of test needs certain APIs available const RenderApiFlags testRequiredApis = @@ -611,6 +623,7 @@ static SlangResult _gatherTestsForFile( else if (command == "DIAGNOSTIC_TEST") { SLANG_RETURN_ON_FAIL(_gatherTestOptions(categorySet, &cursor, testDetails.options)); + applyMacroSubstitution(filePath, testDetails); // Apply the file wide options _combineOptions(categorySet, fileOptions, testDetails.options); |
