summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-12-03 11:45:01 -0500
committerGitHub <noreply@github.com>2021-12-03 11:45:01 -0500
commitda6be80f18014a3972eedf05099cd0066e9eae04 (patch)
tree687cb3853e1794b9478ee2a7b0503590f00f4669 /tools
parentf4b86ff23c825f5e776a401f89302bfcd358aae8 (diff)
Split out ExecutableLocation (#2041)
* #include an absolute path didn't work - because paths were taken to always be relative. * Split out ExecutableLocation. * Fixes for changes to ExecutableLocation. * Fix issues around Process on windows. * Improve comments. Kick CI.
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-test/slang-test-main.cpp50
-rw-r--r--tools/slang-test/test-context.cpp2
-rw-r--r--tools/slang-test/test-reporter.cpp2
-rw-r--r--tools/slang-unit-test/unit-test-process.cpp2
4 files changed, 31 insertions, 25 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 68c7aeec7..f57fe22a1 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -553,13 +553,13 @@ Result spawnAndWaitExe(TestContext* context, const String& testPath, const Comma
Result spawnAndWaitSharedLibrary(TestContext* context, const String& testPath, const CommandLine& cmdLine, ExecuteResult& outRes)
{
const auto& options = context->options;
- String exeName = Path::getFileNameWithoutExt(cmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(cmdLine.m_executableLocation.m_pathOrName);
if (options.shouldBeVerbose)
{
CommandLine testCmdLine;
- testCmdLine.setExecutableFilename("slang-test");
+ testCmdLine.setExecutableLocation(ExecutableLocation("slang-test"));
if (options.binDir.getLength())
{
@@ -622,7 +622,7 @@ Result spawnAndWaitSharedLibrary(TestContext* context, const String& testPath, c
Result spawnAndWaitProxy(TestContext* context, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes)
{
// Get the name of the thing to execute
- String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executableLocation.m_pathOrName);
if (exeName == "slangc")
{
@@ -635,7 +635,7 @@ Result spawnAndWaitProxy(TestContext* context, const String& testPath, const Com
// Make the first arg the name of the tool to invoke
cmdLine.m_args.insert(0, exeName);
- cmdLine.setExecutable(context->exeDirectoryPath, "test-proxy");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->exeDirectoryPath, "test-proxy"));
const auto& options = context->options;
if (options.shouldBeVerbose)
@@ -707,7 +707,7 @@ static Result _executeRPC(TestContext* context, SpawnType spawnType, const Unown
Result spawnAndWaitTestServer(TestContext* context, SpawnType spawnType, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes)
{
- String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executableLocation.m_pathOrName);
// This is a test tool execution
TestServerProtocol::ExecuteToolTestArgs args;
@@ -945,7 +945,7 @@ static SlangResult _extractReflectionTestRequirements(const CommandLine& cmdLine
static SlangResult _extractTestRequirements(const CommandLine& cmdLine, TestRequirements* ioInfo)
{
- String exeName = Path::getFileNameWithoutExt(cmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(cmdLine.m_executableLocation.m_pathOrName);
if (exeName == "render-test")
{
@@ -1002,7 +1002,7 @@ static RenderApiFlags _getAvailableRenderApiFlags(TestContext* context)
}
// Try starting up the device
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
_addRenderTestOptions(context->options, cmdLine);
// We just want to see if the device can be started up
cmdLine.addArg("-only-startup");
@@ -1150,7 +1150,7 @@ String findExpectedPath(const TestInput& input, const char* postFix)
static void _initSlangCompiler(TestContext* context, CommandLine& ioCmdLine)
{
- ioCmdLine.setExecutable(context->options.binDir, "slangc");
+ ioCmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "slangc"));
if (context->options.verbosePaths)
{
@@ -1203,9 +1203,12 @@ static SlangResult _executeBinary(const UnownedStringSlice& hexDump, ExecuteResu
SLANG_RETURN_ON_FAIL(File::makeExecutable(fileName));
// Execute it
+ ExecutableLocation exe;
+ exe.setPath(fileName);
+
CommandLine cmdLine;
- cmdLine.m_executable = fileName;
- cmdLine.m_executableType = CommandLine::ExecutableType::Path;
+ cmdLine.setExecutableLocation(exe);
+
return ProcessUtil::execute(cmdLine, outExeRes);
}
@@ -1599,7 +1602,7 @@ TestResult runReflectionTest(TestContext* context, TestInput& input)
CommandLine cmdLine;
- cmdLine.setExecutable(options.binDir, "slang-reflection-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(options.binDir, "slang-reflection-test"));
cmdLine.addArg(filePath);
for( auto arg : input.testOptions->args )
@@ -1881,13 +1884,17 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
String modulePath = _calcModulePath(input);
// Remove the binary..
+ String moduleExePath;
{
- StringBuilder moduleExePath;
- moduleExePath << modulePath;
- moduleExePath << Process::getExecutableSuffix();
- File::remove(moduleExePath);
+ StringBuilder buf;
+ buf << modulePath;
+ buf << Process::getExecutableSuffix();
+ moduleExePath = buf;
}
+ // Remove the exe if it exists
+ File::remove(moduleExePath);
+
// Set up the compilation options
DownstreamCompiler::CompileOptions options;
@@ -1915,13 +1922,12 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
else
{
// Execute the binary and see what we get
-
CommandLine cmdLine;
- StringBuilder exePath;
- exePath << modulePath << Process::getExecutableSuffix();
+ ExecutableLocation exe;
+ exe.setPath(moduleExePath);
- cmdLine.setExecutablePath(exePath);
+ cmdLine.setExecutableLocation(exe);
ExecuteResult exeRes;
if (SLANG_FAILED(ProcessUtil::execute(cmdLine, exeRes)))
@@ -2385,7 +2391,7 @@ TestResult runPerformanceProfile(TestContext* context, TestInput& input)
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(input.filePath);
cmdLine.addArg("-performance-profile");
@@ -2538,7 +2544,7 @@ TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, cons
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(filePath999);
_addRenderTestOptions(context->options, cmdLine);
@@ -2647,7 +2653,7 @@ TestResult doRenderComparisonTestRun(TestContext* context, TestInput& input, cha
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(filePath);
_addRenderTestOptions(context->options, cmdLine);
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp
index acc680f24..2f0e23815 100644
--- a/tools/slang-test/test-context.cpp
+++ b/tools/slang-test/test-context.cpp
@@ -118,7 +118,7 @@ SlangResult TestContext::_createJSONRPCConnection(RefPtr<JSONRPCConnection>& out
{
CommandLine cmdLine;
- cmdLine.setExecutable(exeDirectoryPath.getBuffer(), "test-server");
+ cmdLine.setExecutableLocation(ExecutableLocation(exeDirectoryPath, "test-server"));
SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
}
diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp
index 8000fd2a5..83df0fb0b 100644
--- a/tools/slang-test/test-reporter.cpp
+++ b/tools/slang-test/test-reporter.cpp
@@ -439,7 +439,7 @@ void TestReporter::_addResult(const TestInfo& info)
// https://www.appveyor.com/docs/build-worker-api/#add-tests
CommandLine cmdLine;
- cmdLine.setExecutableFilename("appveyor");
+ cmdLine.setExecutableLocation(ExecutableLocation("appveyor"));
cmdLine.addArg("AddTest");
cmdLine.addArg(info.name);
cmdLine.addArg("-FileName");
diff --git a/tools/slang-unit-test/unit-test-process.cpp b/tools/slang-unit-test/unit-test-process.cpp
index 559522769..839a19f5d 100644
--- a/tools/slang-unit-test/unit-test-process.cpp
+++ b/tools/slang-unit-test/unit-test-process.cpp
@@ -14,7 +14,7 @@ using namespace Slang;
static SlangResult _createProcess(UnitTestContext* context, const char* toolName, const List<String>* optArgs, RefPtr<Process>& outProcess)
{
CommandLine cmdLine;
- cmdLine.setExecutable(context->executableDirectory, "test-process");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->executableDirectory, "test-process"));
cmdLine.addArg(toolName);
if (optArgs)
{