Skip to content

Commit 2a38c47

Browse files
committed
Improvements to test-Z80.
1 parent 25ecd54 commit 2a38c47

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

sources/test-Z80.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ static zuint search_path_count = 0;
153153

154154
/*-----------------------------------------------------------------------------.
155155
| `verbosity` contains the verbosity level specified by using the `-v` option; |
156-
| `show_test_output` indicates whether to print the text output of the tests. |
156+
| `show_test_output` indicates whether to print the text output of the tests; |
157+
| `test_spacing` points to the string to print beetween each test: "\n" or "". |
157158
'=============================================================================*/
158159

159-
static zuint8 verbosity = 4;
160-
static zboolean show_test_output;
160+
static zuint8 verbosity = 4;
161+
static zboolean show_test_output;
162+
static const char *test_spacing;
161163

162164
/*-----------------------------------------------------------------------------.
163165
| [0]: The byte read from even I/O ports (specified by using the `-0` option). |
@@ -543,10 +545,7 @@ static zuint8 run_test(int test_index)
543545
)
544546
{
545547
error_loading_file:
546-
if (verbosity) puts(show_test_output
547-
? "error, test skipped\n"
548-
: "error, test skipped");
549-
548+
if (verbosity) printf("error, test skipped\n%s", test_spacing);
550549
return Z_FALSE;
551550
}
552551

@@ -690,14 +689,14 @@ static zuint8 run_test(int test_index)
690689
if (failure == Z_NULL) puts(&new_line[has_final_new_line]);
691690

692691
else printf(
693-
"%s>>> Test failed: %s.\n\n",
692+
"%s> Test failed: %s.\n\n",
694693
&new_line[!lines || (completed && has_final_new_line)],
695694
failure);
696695
}
697696

698697
else {
699-
if (failure == Z_NULL) puts ("passed");
700-
else printf("failed: %s\n", failure);
698+
if (failure == Z_NULL) printf("passed\n%s", test_spacing);
699+
else printf("failed: %s\n%s", failure, test_spacing);
701700
}
702701
}
703702

@@ -915,12 +914,14 @@ int main(int argc, char **argv)
915914
goto exit_with_error;
916915
}
917916

917+
show_test_output = verbosity == 4;
918+
test_spacing = &new_line[verbosity < 3];
919+
918920
/*---------------------------------------------------------------.
919921
| Disable output buffering if verbosity is enabled, so that the |
920922
| messages are visible immediately rather than after each ENTER. |
921923
'===============================================================*/
922924
if (verbosity) setvbuf(stdout, Z_NULL, _IONBF, 0);
923-
show_test_output = verbosity == 4;
924925

925926
/* Configure the Z80 CPU emulator. */
926927

@@ -978,7 +979,7 @@ int main(int argc, char **argv)
978979
| Print the results summary. |
979980
'===========================*/
980981
printf( "%sResults%s: %u test%s passed, %u failed.\n",
981-
&new_line[!verbosity || show_test_output],
982+
&new_line[!verbosity || *test_spacing],
982983
show_test_output ? " summary" : "",
983984
results[1],
984985
results[1] == 1 ? "" : "s",

0 commit comments

Comments
 (0)