| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#include <assert.h> |
| 27 |
#include <stdio.h> |
| 28 |
#include <stdlib.h> |
| 29 |
|
| 30 |
#include "scare.h" |
| 31 |
#include "sxprotos.h" |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
static sc_int |
| 41 |
test_run_game_script (sc_game game, sx_script script) |
| 42 |
{ |
| 43 |
sc_int errors; |
| 44 |
|
| 45 |
|
| 46 |
sc_reseed_random_sequence (1); |
| 47 |
|
| 48 |
|
| 49 |
scr_start_script (game, script); |
| 50 |
sc_interpret_game (game); |
| 51 |
|
| 52 |
|
| 53 |
errors = scr_finalize_script (); |
| 54 |
return errors; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
sc_int |
| 65 |
test_run_game_tests (const sx_test_descriptor_t tests[], |
| 66 |
sc_int count, sc_bool is_verbose) |
| 67 |
{ |
| 68 |
const sx_test_descriptor_t *test; |
| 69 |
sc_int errors; |
| 70 |
assert (tests); |
| 71 |
|
| 72 |
errors = 0; |
| 73 |
|
| 74 |
|
| 75 |
for (test = tests; test < tests + count; test++) |
| 76 |
{ |
| 77 |
sc_int test_errors; |
| 78 |
|
| 79 |
if (is_verbose) |
| 80 |
{ |
| 81 |
sx_trace ("--- Running Test \"%s\" [\"%s\", by %s]...\n", |
| 82 |
test->name, |
| 83 |
sc_get_game_name (test->game), |
| 84 |
sc_get_game_author (test->game)); |
| 85 |
} |
| 86 |
|
| 87 |
test_errors = test_run_game_script (test->game, test->script); |
| 88 |
errors += test_errors; |
| 89 |
|
| 90 |
if (is_verbose) |
| 91 |
{ |
| 92 |
sx_trace ("--- Test \"%s\": ", test->name); |
| 93 |
if (test_errors > 0) |
| 94 |
sx_trace ("%s [%ld error%s]\n", |
| 95 |
"FAIL", test_errors, test_errors == 1 ? "" : "s"); |
| 96 |
else |
| 97 |
sx_trace ("%s\n", "PASS"); |
| 98 |
} |
| 99 |
else |
| 100 |
sx_trace ("%s", test_errors > 0 ? "F" : "."); |
| 101 |
fflush (stdout); |
| 102 |
fflush (stderr); |
| 103 |
} |
| 104 |
sx_trace ("%s", is_verbose ? "" : "\n"); |
| 105 |
|
| 106 |
return errors; |
| 107 |
} |