diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-03-18 16:17:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-18 16:17:21 -0400 |
| commit | 70048715cec251a23871747e342e5cf938c97255 (patch) | |
| tree | fbe22903368b1c63fe9b7dd2d541e480e5aba16c /source/core/slang-test-tool-util.cpp | |
| parent | 1bc99cf725e1fcaf542a61fc786be18e18173003 (diff) | |
* Added ToolReturnCode to be more rigerous about how a return code is passed back from a tool (#911)
* Added support for a tool being able to pass back an 'ignored' result.
* Used enum codes to indicate meanings
* Made spawnAndWait return a ToolReturnCode
Diffstat (limited to 'source/core/slang-test-tool-util.cpp')
| -rw-r--r-- | source/core/slang-test-tool-util.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index 7ecfacefa..20ba2fc47 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -4,18 +4,34 @@ namespace Slang { -/* static */int TestToolUtil::getReturnCode(SlangResult res) +/* static */ToolReturnCode TestToolUtil::getReturnCode(SlangResult res) { - if (SLANG_SUCCEEDED(res)) + switch (res) { - return 0; + case SLANG_OK: return ToolReturnCode::Success; + case SLANG_E_INTERNAL_FAIL: return ToolReturnCode::CompilationFailed; + case SLANG_FAIL: return ToolReturnCode::Failed; + case SLANG_E_NOT_AVAILABLE: return ToolReturnCode::Ignored; + default: + { + return (SLANG_SUCCEEDED(res)) ? ToolReturnCode::Success : ToolReturnCode::Failed; + } } - else if (res == SLANG_E_INTERNAL_FAIL) +} + +/* static */ToolReturnCode TestToolUtil::getReturnCodeFromInt(int code) +{ + if (code >= int(ToolReturnCodeSpan::First) && code <= int(ToolReturnCodeSpan::Last)) { - return -1; + return ToolReturnCode(code); + } + else + { + SLANG_ASSERT(!"Invalid integral code"); + return ToolReturnCode::Failed; } - return 1; } + } |
