test: make tap output the default

With the non-tap output, it's sometimes difficult to distinguish skipped
tests from test failures.

PR-URL: https://github.com/libuv/libuv/pull/898
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Ben Noordhuis 2016-06-06 14:39:05 +02:00
parent 96b37293a9
commit cc1d38ea93
4 changed files with 15 additions and 92 deletions

View File

@ -43,11 +43,6 @@
/* Do platform-specific initialization. */
int platform_init(int argc, char **argv) {
const char* tap;
tap = getenv("UV_TAP_OUTPUT");
tap_output = (tap != NULL && atoi(tap) > 0);
/* Disable stdio output buffering. */
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
@ -310,9 +305,7 @@ int process_copy_output(process_info_t *p, int fd) {
/* TODO: what if write doesn't write the whole buffer... */
nwritten = 0;
if (tap_output)
nwritten += write(fd, "#", 1);
nwritten += write(fd, "#", 1);
nwritten += write(fd, buf, strlen(buf));
if (nwritten < 0) {

View File

@ -44,11 +44,6 @@
/* Do platform-specific initialization. */
int platform_init(int argc, char **argv) {
const char* tap;
tap = getenv("UV_TAP_OUTPUT");
tap_output = (tap != NULL && atoi(tap) > 0);
/* Disable the "application crashed" popup. */
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
@ -225,29 +220,23 @@ int process_copy_output(process_info_t *p, int fd) {
return -1;
}
if (tap_output)
write(fd, "#", 1);
write(fd, "#", 1);
while (ReadFile(p->stdio_out, (void*)&buf, sizeof(buf), &read, NULL) &&
read > 0) {
if (tap_output) {
start = buf;
start = buf;
while ((line = strchr(start, '\n')) != NULL) {
write(fd, start, line - start + 1);
write(fd, "#", 1);
start = line + 1;
}
if (start < buf + read)
write(fd, start, buf + read - start);
} else {
write(fd, buf, read);
while ((line = strchr(start, '\n')) != NULL) {
write(fd, start, line - start + 1);
write(fd, "#", 1);
start = line + 1;
}
if (start < buf + read)
write(fd, start, buf + read - start);
}
if (tap_output)
write(fd, "\n", 1);
write(fd, "\n", 1);
if (GetLastError() != ERROR_HANDLE_EOF)
return -1;

View File

@ -28,31 +28,6 @@
char executable_path[sizeof(executable_path)];
int tap_output = 0;
static void log_progress(int total,
int passed,
int failed,
int todos,
int skipped,
const char* name) {
int progress;
if (total == 0)
total = 1;
progress = 100 * (passed + failed + skipped + todos) / total;
fprintf(stderr, "[%% %3d|+ %3d|- %3d|T %3d|S %3d]: %s",
progress,
passed,
failed,
todos,
skipped,
name);
fflush(stderr);
}
const char* fmt(double d) {
static char buf[1024];
@ -109,10 +84,8 @@ int run_tests(int benchmark_output) {
}
}
if (tap_output) {
fprintf(stderr, "1..%d\n", total);
fflush(stderr);
}
fprintf(stderr, "1..%d\n", total);
fflush(stderr);
/* Run all tests. */
passed = 0;
@ -125,13 +98,6 @@ int run_tests(int benchmark_output) {
continue;
}
if (!tap_output)
rewind_cursor();
if (!benchmark_output && !tap_output) {
log_progress(total, passed, failed, todos, skipped, task->task_name);
}
test_result = run_test(task->task_name, benchmark_output, current);
switch (test_result) {
case TEST_OK: passed++; break;
@ -142,13 +108,6 @@ int run_tests(int benchmark_output) {
current++;
}
if (!tap_output)
rewind_cursor();
if (!benchmark_output && !tap_output) {
log_progress(total, passed, failed, todos, skipped, "Done.\n");
}
return failed;
}
@ -319,22 +278,11 @@ out:
FATAL("process_wait failed");
}
if (tap_output)
log_tap_result(test_count, test, status, &processes[i]);
log_tap_result(test_count, test, status, &processes[i]);
/* Show error and output from processes if the test failed. */
if (status != 0 || task->show_output) {
if (tap_output) {
fprintf(stderr, "#");
} else if (status == TEST_TODO) {
fprintf(stderr, "\n`%s` todo\n", test);
} else if (status == TEST_SKIP) {
fprintf(stderr, "\n`%s` skipped\n", test);
} else if (status != 0) {
fprintf(stderr, "\n`%s` failed: %s\n", test, errmsg);
} else {
fprintf(stderr, "\n");
}
fprintf(stderr, "#");
fflush(stderr);
for (i = 0; i < process_count; i++) {
@ -359,10 +307,6 @@ out:
}
}
if (!tap_output) {
fprintf(stderr, "=============================================================\n");
}
/* In benchmark mode show concise output from the main process. */
} else if (benchmark_output) {
switch (process_output_size(main_proc)) {

View File

@ -172,7 +172,4 @@ void process_cleanup(process_info_t *p);
/* Move the console cursor one line up and back to the first column. */
void rewind_cursor(void);
/* trigger output as tap */
extern int tap_output;
#endif /* RUNNER_H_ */