Validate exit codes more thoroughly. C'mon, Cory.

This commit is contained in:
2024-04-02 20:32:47 -04:00
parent 9f3171e3f1
commit e50144bd34
3 changed files with 22 additions and 5 deletions

View File

@ -58,6 +58,20 @@ static void _test_nop(const tf_test_options_t* options)
assert(WEXITSTATUS(result) == 0);
}
static void _test_exception(const tf_test_options_t* options)
{
_write_file("out/test.js", "throw new Error('oops');");
char command[256];
snprintf(command, sizeof(command), "%s run --db-path=:memory: -s out/test.js" TEST_ARGS, options->exe_path);
tf_printf("%s\n", command);
int result = system(command);
tf_printf("result = %d\n", result);
(void)result;
assert(WIFEXITED(result));
assert(WEXITSTATUS(result) != 0);
}
#if !defined(__HAIKU__)
static void _test_sandbox(const tf_test_options_t* options)
{
@ -372,7 +386,7 @@ static void _test_import(const tf_test_options_t* options)
result = system(command);
tf_printf("returned %d\n", WEXITSTATUS(result));
assert(WIFEXITED(result));
assert(WEXITSTATUS(result) == 0);
assert(WEXITSTATUS(result) != 0);
unlink("out/test.js");
unlink("out/required.js");
@ -893,6 +907,7 @@ void tf_tests(const tf_test_options_t* options)
_tf_test_run(options, "ssb_id", tf_ssb_test_id_conversion, false);
_tf_test_run(options, "ssb_following", tf_ssb_test_following, false);
_tf_test_run(options, "nop", _test_nop, false);
_tf_test_run(options, "exception", _test_exception, false);
#if !defined(__HAIKU__)
_tf_test_run(options, "sandbox", _test_sandbox, false);
#endif