fix unit test runner to match new return value of tools
MODIFY
tests/lit/lit/formats/alive2test.py
tests/lit/lit/formats/alive2test.py
@@ -56,24 +56,22 @@ class Alive2Test(TestFormat):
def execute(self, test, litConfig):
test = test.getSourcePath()
+ ok_string = 'Transformation seems to be correct!'
alive_tv_1 = test.endswith('.srctgt.ll')
if alive_tv_1:
cmd = ['./alive-tv']
- ok_string = 'Transformation seems to be correct!'
if not os.path.isfile('alive-tv'):
return lit.Test.UNSUPPORTED, ''
alive_tv_2 = test.endswith('.src.ll')
if alive_tv_2:
cmd = ['./alive-tv']
- ok_string = 'Transformation seems to be correct!'
if not os.path.isfile('alive-tv'):
return lit.Test.UNSUPPORTED, ''
if not alive_tv_1 and not alive_tv_2:
cmd = ['./alive']
- ok_string = 'Optimization is correct!'
input = readFile(test)
@@ -112,18 +110,15 @@ class Alive2Test(TestFormat):
if chk != None and (out + err).find(chk.group(1).strip()) == -1:
return lit.Test.FAIL, out + err
- # wrong
- if expect_err != None and xfail is None:
- return lit.Test.PASS, ''
-
if expect_err is None and xfail is None:
if exitCode == 0 and (out + err).find(ok_string) != -1:
return lit.Test.PASS, ''
return lit.Test.FAIL, out + err
- if exitCode != 0:
if expect_err != None and err.find(expect_err.group(1)) != -1:
return lit.Test.PASS, ''
+
if xfail != None and err.find(xfail.group(1)) != -1:
return lit.Test.XFAIL, ''
+
return lit.Test.FAIL, out + err

MODIFY
tools/alive.cpp
tools/alive.cpp
@@ -92,8 +92,6 @@ int main(int argc, char **argv) {
TransformPrintOpts print_opts;
print_opts.print_fn_header = false;
- unsigned num_errors = 0;
-
for (; argc_i < argc; ++argc_i) {
cout << "Processing " << argv[argc_i] << "..\n";
try {
@@ -102,7 +100,6 @@ int main(int argc, char **argv) {
if (root_only && (!t.src.hasReturn() || !t.tgt.hasReturn())) {
cerr << "Return instruction required with -root-only.\n";
- ++num_errors;
continue;
}
@@ -113,7 +110,6 @@ int main(int argc, char **argv) {
auto types = tv.getTypings();
if (!types) {
cerr << "Doesn't type check!\n";
- ++num_errors;
continue;
}
@@ -123,7 +119,6 @@ int main(int argc, char **argv) {
tv.fixupTypes(types);
if (auto errs = tv.verify()) {
cerr << errs;
- ++num_errors;
correct = false;
break;
}
@@ -131,7 +126,7 @@ int main(int argc, char **argv) {
}
cout << '\n';
if (correct)
- cout << "Optimization is correct!\n";
+ cout << "Transformation seems to be correct!\n";
}
} catch (const FileIOException &e) {
cerr << "Couldn't read the file" << endl;
@@ -145,5 +140,5 @@ int main(int argc, char **argv) {
if (show_smt_stats)
smt::solver_print_stats(cout);
- return num_errors;
+ return 0;
}

fix unit test runner to match new return value of tools