From 70048715cec251a23871747e342e5cf938c97255 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 18 Mar 2019 16:17:21 -0400 Subject: * 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 --- source/core/slang-test-tool-util.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'source/core/slang-test-tool-util.cpp') 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; } + } -- cgit v1.2.3