From 2f4d2c4141e741aab767af2aa3e9c6fb3316e384 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 9 Mar 2022 05:32:49 +0100 Subject: Add --args to sibs test command --- src/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') 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 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 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 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, {}); } -- cgit v1.2.3