aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp40
1 files changed, 30 insertions, 10 deletions
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);