Skip to content

Commit

Permalink
Merge pull request icecc#142 from kito-cheng/master
Browse files Browse the repository at this point in the history
Prevent different test result between make check and execute directly
coolo committed Feb 20, 2016
2 parents 3299ea6 + 2e3689e commit 7766b9f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/args.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,19 @@

using namespace std;

static const char *ICECC_COLOR_DIAGNOSTICS = NULL;
void backup_icecc_color_diagnostics() {
ICECC_COLOR_DIAGNOSTICS = getenv("ICECC_COLOR_DIAGNOSTICS");
setenv("ICECC_COLOR_DIAGNOSTICS", "0", 1);
}

void restore_icecc_color_diagnostics() {
if (ICECC_COLOR_DIAGNOSTICS)
setenv("ICECC_COLOR_DIAGNOSTICS", ICECC_COLOR_DIAGNOSTICS, 1);
else
unsetenv("ICECC_COLOR_DIAGNOSTICS");
}

void test_run(const string &prefix, const char * const *argv, bool icerun, const string expected) {
list<string> extrafiles;
CompileJob job;
@@ -25,17 +38,23 @@ void test_run(const string &prefix, const char * const *argv, bool icerun, const

static void test_1() {
const char * argv[] = { "gcc", "-D", "TEST=1", "-c", "main.cpp", "-o", "main.o", 0 };
backup_icecc_color_diagnostics();
test_run("1", argv, false, "local:0 language:C++ compiler:gcc local:'-D, TEST=1' remote:'-c' rest:''");
restore_icecc_color_diagnostics();
}

static void test_2() {
const char * argv[] = { "gcc", "-DTEST=1", "-c", "main.cpp", "-o", "main.o", 0 };
backup_icecc_color_diagnostics();
test_run("2", argv, false, "local:0 language:C++ compiler:gcc local:'-DTEST=1' remote:'-c' rest:''");
restore_icecc_color_diagnostics();
}

static void test_3() {
const char * argv[] = { "clang", "-D", "TEST1=1", "-I.", "-c", "make1.cpp", "-o", "make.o", 0};
backup_icecc_color_diagnostics();
test_run("3", argv, false, "local:0 language:C++ compiler:clang local:'-D, TEST1=1, -I.' remote:'-c' rest:''");
restore_icecc_color_diagnostics();
}

int main() {

0 comments on commit 7766b9f

Please sign in to comment.