aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-24 20:42:43 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-24 20:42:43 +0100
commit37b23908f195d54844486552cc4359bf6f4a949c (patch)
tree9397738dddb5890d6e9d088fd58f606f4bace135
parent445fd7c1968112664b1fbbe6215ed76609cfb8ac (diff)
Add --debug/--release option to sibs test
-rw-r--r--TODO1
-rw-r--r--src/main.cpp40
2 files changed, 31 insertions, 10 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..0414e95
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+[dependencies] should automatically download dependency from vcpkg if available. This is useful for windows
diff --git a/src/main.cpp b/src/main.cpp
index 00b7e92..7c0707d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -167,13 +167,14 @@ static void usageNew()
static void usageTest()
{
- printf("Usage: sibs test [project_path] [--sanitize=(address|undefined|leak|thread|none)] [--file <filepath>...|--all-files]\n\n");
+ printf("Usage: sibs test [project_path] [--debug|--release] [--sanitize=(address|undefined|leak|thread|none)] [--file <filepath>...|--all-files]\n\n");
printf("Build and run tests for a sibs project\n\n");
printf("Options:\n");
- printf(" project_path The directory containing a project.conf file - Optional (default: current directory)\n");
- printf(" --sanitize Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: address)\n");
- printf(" --file Specify file to test, path to test file should be defined after this. Can be defined multiple times to test multiple files - Optional (default: not used), Only applicable for Zig\n");
- printf(" --all-files Test all files - Optional (default: not used), Only applicable for Zig\n");
+ printf(" project_path The directory containing a project.conf file - Optional (default: current directory)\n");
+ printf(" --debug|--release Optimization level to build project and dependencies with (if not a system package) - Optional (default: --debug)\n");
+ printf(" --sanitize Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: address)\n");
+ printf(" --file Specify file to test, path to test file should be defined after this. Can be defined multiple times to test multiple files - Optional (default: not used), Only applicable for Zig\n");
+ printf(" --all-files Test all files - Optional (default: not used), Only applicable for Zig\n");
printf("Examples:\n");
printf(" sibs test\n");
printf(" sibs test dirA/dirB\n");
@@ -645,9 +646,7 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run)
static int testProject(int argc, const _tinydir_char_t **argv)
{
- if(argc > 2)
- usageTest();
-
+ OptimizationLevel optimizationLevel = OPT_LEV_NONE;
FileString projectPath;
vector<FileString> filesToTest;
bool testAllFiles = false;
@@ -656,7 +655,25 @@ static int testProject(int argc, const _tinydir_char_t **argv)
for(int i = 0; i < argc; ++i)
{
const _tinydir_char_t *arg = argv[i];
- if(_tinydir_strncmp(arg, TINYDIR_STRING("--sanitize="), 11) == 0)
+ if(_tinydir_strcmp(arg, TINYDIR_STRING("--debug")) == 0)
+ {
+ if(optimizationLevel != OPT_LEV_NONE)
+ {
+ ferr << "Error: Optimization level defined more than once. First defined as " << asString(optimizationLevel) << " then as debug" << endl;
+ usageTest();
+ }
+ optimizationLevel = OPT_LEV_DEBUG;
+ }
+ else if(_tinydir_strcmp(arg, TINYDIR_STRING("--release")) == 0)
+ {
+ if(optimizationLevel != OPT_LEV_NONE)
+ {
+ ferr << "Error: Optimization level defined more than once. First defined as " << asString(optimizationLevel) << " then as release" << endl;
+ usageTest();
+ }
+ optimizationLevel = OPT_LEV_RELEASE;
+ }
+ else if(_tinydir_strncmp(arg, TINYDIR_STRING("--sanitize="), 11) == 0)
{
sanitize = sanitize_string_to_type(arg + 11);
if(sanitize == SANITIZE_INVALID) {
@@ -712,6 +729,9 @@ static int testProject(int argc, const _tinydir_char_t **argv)
projectPath = arg;
}
}
+
+ if(optimizationLevel == OPT_LEV_NONE)
+ optimizationLevel = OPT_LEV_DEBUG;
// TODO: If projectPath is not defined and working directory does not contain project.conf, then search every parent directory until one is found
if(projectPath.empty())
@@ -779,7 +799,7 @@ static int testProject(int argc, const _tinydir_char_t **argv)
Compiler compiler = Compiler::MSVC;
#endif
- SibsConfig sibsConfig(compiler, projectPath, OPT_LEV_DEBUG, true);
+ SibsConfig sibsConfig(compiler, projectPath, optimizationLevel, true);
sibsConfig.showWarnings = true;
sibsConfig.setSanitize(sanitize);
sibsConfig.zigTestFiles = move(filesToTest);