Skip to content

Commit 7a031d7

Browse files
authored
fix(core): fix TestRunner (#41)
There were tests that were failing, but due to a strange bug in TestRunner, they were not exposed. With this commit we can see the tests that are not really passing.
1 parent 0f857be commit 7a031d7

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

lib/core/src/test_runner.ri

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public struct TestRunner {
9393
}
9494
}
9595
self.print_summary_tests();
96-
process_exit(@as(int32, self.fail_tests));
96+
if self.fail_tests > 0 {
97+
process_exit(1);
98+
}
9799
}
98100

99101
func print_summary_tests(&self) {

rivetc/src/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def __init__(self, args):
5757
self.checker = checker.Checker(self)
5858
self.codegen = codegen.Codegen(self)
5959

60-
self.exit_code = 0
61-
6260
def import_modules(self):
6361
for sf in self.parsed_files:
6462
for decl in sf.decls:
@@ -147,8 +145,6 @@ def run(self):
147145
self.codegen.gen_source_files(self.source_files)
148146
if report.ERRORS > 0:
149147
self.abort()
150-
if self.exit_code != 0:
151-
exit(self.exit_code)
152148

153149
def load_root_module(self):
154150
if path.isdir(self.prefs.input):

rivetc/src/codegen/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ def gen_source_files(self, source_files):
276276
self.comp.vlog("generating C output from RIR...")
277277
CGen(self.comp).gen(self.out_rir)
278278
if self.comp.prefs.build_mode == prefs.BuildMode.Test:
279-
self.comp.exit_code = os.system(self.comp.prefs.mod_output)
279+
exit_code = os.system(self.comp.prefs.mod_output)
280280
os.remove(self.comp.prefs.mod_output)
281+
# assert exit_code == 0
282+
if exit_code != 0:
283+
exit(1)
281284

282285
def gen_mod_attributes(self, mod_name, attributes):
283286
mod_folder = os.path.join(prefs.RIVET_DIR, "obj", mod_name)

rivetc/src/prefs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def __init__(self, args: [str]):
298298
self.build_rivet_dir()
299299

300300
if self.build_mode == BuildMode.Test:
301-
self.mod_output = f"_tests_runner_"
301+
self.mod_output = f"_tests_runner__{self.mod_name}_"
302302
elif len(self.mod_output) == 0:
303303
self.mod_output = self.mod_name
304304
if self.target_os == OS.Windows and not self.mod_output.endswith(

0 commit comments

Comments
 (0)