summaryrefslogtreecommitdiffstats
path: root/source/core/slang-test-tool-util.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /source/core/slang-test-tool-util.cpp
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'source/core/slang-test-tool-util.cpp')
-rw-r--r--source/core/slang-test-tool-util.cpp68
1 files changed, 42 insertions, 26 deletions
diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp
index d362d7043..a71048f10 100644
--- a/source/core/slang-test-tool-util.cpp
+++ b/source/core/slang-test-tool-util.cpp
@@ -2,29 +2,28 @@
#include "slang-test-tool-util.h"
#include "slang-com-helper.h"
-
#include "slang-io.h"
#include "slang-string-util.h"
namespace Slang
{
-/* static */ToolReturnCode TestToolUtil::getReturnCode(SlangResult res)
+/* static */ ToolReturnCode TestToolUtil::getReturnCode(SlangResult res)
{
switch (res)
{
- 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:
+ 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;
}
}
}
-/* static */ToolReturnCode TestToolUtil::getReturnCodeFromInt(int code)
+/* static */ ToolReturnCode TestToolUtil::getReturnCodeFromInt(int code)
{
if (code >= int(ToolReturnCodeSpan::First) && code <= int(ToolReturnCodeSpan::Last))
{
@@ -37,7 +36,7 @@ namespace Slang
}
}
-/* static */bool TestToolUtil::hasDeferredCoreModule(Index argc, const char*const* argv)
+/* static */ bool TestToolUtil::hasDeferredCoreModule(Index argc, const char* const* argv)
{
for (Index i = 0; i < argc; ++i)
{
@@ -50,7 +49,10 @@ namespace Slang
return false;
}
-/* static */SlangResult TestToolUtil::getIncludePath(const String& parentPath, const char* path, String& outIncludePath)
+/* static */ SlangResult TestToolUtil::getIncludePath(
+ const String& parentPath,
+ const char* path,
+ String& outIncludePath)
{
String includePath;
SLANG_RETURN_ON_FAIL(Path::getCanonical(Path::combine(parentPath, path), includePath));
@@ -73,7 +75,10 @@ static SlangResult _addCPPPrelude(const String& rootPath, slang::IGlobalSession*
String includePath;
SlangResult res = SLANG_FAIL;
if (SLANG_FAILED(res))
- res = TestToolUtil::getIncludePath(Path::combine(rootPath, "include"), "slang-cpp-prelude.h", includePath);
+ res = TestToolUtil::getIncludePath(
+ Path::combine(rootPath, "include"),
+ "slang-cpp-prelude.h",
+ includePath);
if (SLANG_FAILED(res))
res = TestToolUtil::getIncludePath(rootPath, "prelude/slang-cpp-prelude.h", includePath);
SLANG_RETURN_ON_FAIL(res);
@@ -88,7 +93,10 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
String includePath;
SlangResult res = SLANG_FAIL;
if (SLANG_FAILED(res))
- res = TestToolUtil::getIncludePath(Path::combine(rootPath, "include"), "slang-cuda-prelude.h", includePath);
+ res = TestToolUtil::getIncludePath(
+ Path::combine(rootPath, "include"),
+ "slang-cuda-prelude.h",
+ includePath);
if (SLANG_FAILED(res))
res = TestToolUtil::getIncludePath(rootPath, "prelude/slang-cuda-prelude.h", includePath);
SLANG_RETURN_ON_FAIL(res);
@@ -98,7 +106,9 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
return SLANG_OK;
}
-/* static */SlangResult TestToolUtil::getExeDirectoryPath(const char* exePath, String& outExeDirectoryPath)
+/* static */ SlangResult TestToolUtil::getExeDirectoryPath(
+ const char* exePath,
+ String& outExeDirectoryPath)
{
String canonicalPath;
SLANG_RETURN_ON_FAIL(Path::getCanonical(exePath, canonicalPath));
@@ -107,7 +117,9 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
return SLANG_OK;
}
-/* static */SlangResult TestToolUtil::getDllDirectoryPath(const char* exePath, String& outDllDirectoryPath)
+/* static */ SlangResult TestToolUtil::getDllDirectoryPath(
+ const char* exePath,
+ String& outDllDirectoryPath)
{
String canonicalPath;
SLANG_RETURN_ON_FAIL(Path::getCanonical(exePath, canonicalPath));
@@ -115,7 +127,8 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
// Get the directory
String binPath = Path::getParentDirectory(canonicalPath);
- // Windows puts the dlls in the same directory as the exe, while on other platforms they are in a 'lib' directory
+ // Windows puts the dlls in the same directory as the exe, while on other platforms they are in
+ // a 'lib' directory
#ifdef _WIN32
outDllDirectoryPath = binPath;
#else
@@ -125,7 +138,7 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
return SLANG_OK;
}
-/* static */SlangResult TestToolUtil::getRootPath(const char* inExePath, String& outExePath)
+/* static */ SlangResult TestToolUtil::getRootPath(const char* inExePath, String& outExePath)
{
// Get the directory holding the exe
String parentPath;
@@ -137,21 +150,23 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
SLANG_RETURN_ON_FAIL(Path::getCanonical(parentPath, rootRelPath));
do
{
- if(File::exists(Path::combine(rootRelPath, "include/slang-cpp-prelude.h")))
+ if (File::exists(Path::combine(rootRelPath, "include/slang-cpp-prelude.h")))
break;
- if(File::exists(Path::combine(rootRelPath, "prelude/slang-cpp-prelude.h")))
+ if (File::exists(Path::combine(rootRelPath, "prelude/slang-cpp-prelude.h")))
break;
rootRelPath = Path::getParentDirectory(rootRelPath);
- if(rootRelPath == "")
+ if (rootRelPath == "")
return SLANG_E_NOT_AVAILABLE;
- } while(1);
+ } while (1);
outExePath = std::move(rootRelPath);
return SLANG_OK;
}
-/* static */SlangResult TestToolUtil::setSessionDefaultPreludeFromExePath(const char* inExePath, slang::IGlobalSession* session)
+/* static */ SlangResult TestToolUtil::setSessionDefaultPreludeFromExePath(
+ const char* inExePath,
+ slang::IGlobalSession* session)
{
String rootPath;
SLANG_RETURN_ON_FAIL(getRootPath(inExePath, rootPath));
@@ -159,10 +174,12 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
return SLANG_OK;
}
-/* static */SlangResult TestToolUtil::setSessionDefaultPreludeFromRootPath(const String& rootPath, slang::IGlobalSession* session)
+/* static */ SlangResult TestToolUtil::setSessionDefaultPreludeFromRootPath(
+ const String& rootPath,
+ slang::IGlobalSession* session)
{
// Set the prelude to a path
-
+
if (SLANG_FAILED(_addCPPPrelude(rootPath, session)))
{
SLANG_ASSERT(!"Couldn't find the C++ prelude relative to the executable");
@@ -172,9 +189,8 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
{
SLANG_ASSERT(!"Couldn't find the CUDA prelude relative to the executable");
}
-
- return SLANG_OK;
-}
+ return SLANG_OK;
}
+} // namespace Slang