diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-10-13 18:14:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-13 18:14:42 -0700 |
| commit | 64ddefb90cf440df7879d1f2f9cc61de71e0f181 (patch) | |
| tree | 03d113b2e58c9e232021df38350744226600f79c /tools/slang-test/main.cpp | |
| parent | 575230b93370fea86ecccb53fba73927280e917b (diff) | |
Move reflection JSON generation into separate text fixture (#211)
Move reflection JSON generation into separate test fixture
Diffstat (limited to 'tools/slang-test/main.cpp')
| -rw-r--r-- | tools/slang-test/main.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index 0bf2ff6af..83d512cc1 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -691,6 +691,67 @@ TestResult runSimpleTest(TestInput& input) return result; } +TestResult runReflectionTest(TestInput& input) +{ + auto filePath = input.filePath; + auto outputStem = input.outputStem; + + OSProcessSpawner spawner; + + spawner.pushExecutablePath(String(options.binDir) + "slang-reflection-test" + osGetExecutableSuffix()); + spawner.pushArgument(filePath); + + for( auto arg : input.testOptions->args ) + { + spawner.pushArgument(arg); + } + + if (spawnAndWait(outputStem, spawner) != kOSError_None) + { + return kTestResult_Fail; + } + + String actualOutput = getOutput(spawner); + + String expectedOutputPath = outputStem + ".expected"; + String expectedOutput; + try + { + expectedOutput = Slang::File::ReadAllText(expectedOutputPath); + } + catch (Slang::IOException) + { + } + + // If no expected output file was found, then we + // expect everything to be empty + if (expectedOutput.Length() == 0) + { + expectedOutput = "result code = 0\nstandard error = {\n}\nstandard output = {\n}\n"; + } + + TestResult result = kTestResult_Pass; + + // Otherwise we compare to the expected output + if (actualOutput != expectedOutput) + { + result = kTestResult_Fail; + } + + // If the test failed, then we write the actual output to a file + // so that we can easily diff it from the command line and + // diagnose the problem. + if (result == kTestResult_Fail) + { + String actualOutputPath = outputStem + ".actual"; + Slang::File::WriteAllText(actualOutputPath, actualOutput); + + maybeDumpOutput(expectedOutput, actualOutput); + } + + return result; +} + TestResult runEvalTest(TestInput& input) { // We are going to load and evaluate the code @@ -1235,6 +1296,7 @@ TestResult runTest( TestCallback callback; } kTestCommands[] = { { "SIMPLE", &runSimpleTest }, + { "REFLECTION", &runReflectionTest }, #if SLANG_TEST_SUPPORT_HLSL { "COMPARE_HLSL", &runHLSLComparisonTest }, { "COMPARE_HLSL_RENDER", &runHLSLRenderComparisonTest }, |
