aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-09 05:32:49 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-09 05:32:49 +0100
commit2f4d2c4141e741aab767af2aa3e9c6fb3316e384 (patch)
tree2283c788763da444538701fabb284179a30df94f
parent7677125c3a99c0d794f7bdf9186a03782b065d11 (diff)
Add --args to sibs test command
-rw-r--r--backend/ninja/Ninja.cpp9
-rw-r--r--include/Conf.hpp1
-rw-r--r--src/main.cpp12
3 files changed, 20 insertions, 2 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index eecbaee..6c69d13 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -1843,7 +1843,14 @@ namespace backend
if(!zigTest && !config.testsBuildOnly)
{
- Result<ExecResult> runTestResult = exec({ Path(buildPath).join(toFileString(sibsTestConfig.getPackageName())).data }, true);
+ FileString executableName = toFileString(sibsTestConfig.getPackageName());
+ if(isSamePlatformFamily(sibsTestConfig.platform, PLATFORM_WIN))
+ executableName += TINYDIR_STRING(".exe");
+
+ std::vector<FileString> args = { Path(buildPath).join(executableName).data };
+ args.insert(args.end(), config.testRunArgs.begin(), config.testRunArgs.end());
+
+ Result<ExecResult> runTestResult = exec(args, true);
if(!runTestResult)
return Result<bool>::Err(runTestResult);
diff --git a/include/Conf.hpp b/include/Conf.hpp
index 673a7f6..54c6b89 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -444,6 +444,7 @@ namespace sibs
std::string linker;
bool testsBuildOnly = false;
bool skipCompile = false;
+ std::vector<FileString> testRunArgs;
protected:
virtual void processObject(StringView name) override;
virtual void processField(StringView name, const ConfigValue &value) override;
diff --git a/src/main.cpp b/src/main.cpp
index 0caaf22..2592135 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -139,7 +139,9 @@ static void usageBuild(bool run)
printf(" --lto Use link-time optimization. May increase compile times - Optional (default: not used)\n");
printf(" --debug-symbols Include debug symbols in release mode - Optional (default: not used)\n");
printf(" --linker=linker The linker to use. \"gold\" is the default linker when using gcc\n");
- if(!run) {
+ if(run) {
+ printf(" --args <args...> A list of arguments to run the program with\n");
+ } else {
printf(" --skip-compile Skip compilation. This can be used to generate a compile_commands.json file without compiling. Note that the compile_commands.json can miss files that are generated when this option is used\n");
}
printf("Examples:\n");
@@ -182,6 +184,7 @@ static void usageTest()
printf(" --all-files Test all files - Optional (default: not used), Only applicable for Zig\n");
printf(" --linker=linker The linker to use. \"gold\" is the default linker when using gcc\n");
printf(" --skip-compile Skip compilation. This can be used to generate a compile_commands.json file without compiling. Note that the compile_commands.json can miss files that are generated when this option is used. This option also skips running the tests\n");
+ printf(" --args <args...> A list of arguments to run the program with\n");
printf("Examples:\n");
printf(" sibs test\n");
printf(" sibs test dirA/dirB\n");
@@ -683,6 +686,7 @@ static int testProject(int argc, const _tinydir_char_t **argv)
bool buildOnly = false;
bool skipCompile = false;
std::string linker;
+ std::vector<FileString> run_args;
for(int i = 0; i < argc; ++i)
{
@@ -768,6 +772,11 @@ static int testProject(int argc, const _tinydir_char_t **argv)
usageTest();
}
}
+ else if(_tinydir_strcmp(arg, TINYDIR_STRING("--args")) == 0)
+ {
+ run_args.insert(run_args.end(), argv + i + 1, argv + argc);
+ break;
+ }
else if(_tinydir_strncmp(arg, TINYDIR_STRING("--"), 2) == 0)
{
ferr << "Error: Invalid argument " << arg << endl;
@@ -861,6 +870,7 @@ static int testProject(int argc, const _tinydir_char_t **argv)
sibsConfig.zigTestAllFiles = testAllFiles;
sibsConfig.testsBuildOnly = buildOnly;
sibsConfig.skipCompile = skipCompile;
+ sibsConfig.testRunArgs = std::move(run_args);
return buildProject(projectPath, projectConfFilePath, sibsConfig, false, {});
}