commit c3503b40480e891485edbcb0343e733e1ad7f4b6
parent f566ffc16fde2f417d10c22196c61f9dacc0e5fb
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 5 Aug 2023 20:12:02 -0400
test: reset environment before first test is run
The environment could've been modified by an initialization function, so
for consistency, the environment is now reset here in addition to after
each test function completes.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/test/+test.ha b/test/+test.ha
@@ -90,6 +90,7 @@ export @symbol("__test_main") fn main() size = {
defer finish_context(&ctx);
fmt::printfln("Running {}/{} tests:\n", len(enabled_tests), ntest)!;
+ reset(&ctx);
for (let i = 0z; i < len(enabled_tests); i += 1) {
do_test(&ctx, enabled_tests[i]);
};
@@ -141,6 +142,12 @@ export @symbol("__test_main") fn main() size = {
return len(ctx.failures);
};
+fn reset(ctx: *context) void = {
+ rt::fesetround(ctx.default_round);
+ rt::feclearexcept(~0u);
+ signal::resetall();
+};
+
fn do_test(ctx: *context, test: test) void = {
signal::handle(signal::sig::SEGV, &handle_segv, signal::flag::NODEFER);
memio::reset(&ctx.stdout);
@@ -190,9 +197,7 @@ fn do_test(ctx: *context, test: test) void = {
});
};
- rt::fesetround(ctx.default_round);
- rt::feclearexcept(~0u);
- signal::resetall();
+ reset(ctx);
};
fn run_test(ctx: *context, test: test) (void | failure) = {