Skip to content

Commit 0469489

Browse files
authored
Disable run-test262 progress indicator unless tty (#1094)
In case stdout is not a TTY (e.g. a pipe), trying to rewrite the last line (using \r) does not work, and the output of the test execution gets mangled by the progress indicator. Hence, do not use a progress indicator at all in case the output is not a TTY (checked only on non-Windows OSes).
1 parent 9d0380b commit 0469489

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

run-test262.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,7 @@ int main(int argc, char **argv)
21362136
const char *ignore = "";
21372137
bool is_test262_harness = false;
21382138
bool is_module = false;
2139+
bool enable_progress = true;
21392140

21402141
js_std_set_worker_new_context_func(JS_NewCustomContext);
21412142

@@ -2238,6 +2239,12 @@ int main(int argc, char **argv)
22382239

22392240
update_exclude_dirs();
22402241

2242+
#ifndef _WIN32
2243+
if (!isatty(STDOUT_FILENO)) {
2244+
enable_progress = false;
2245+
}
2246+
#endif
2247+
22412248
if (is_dir_list) {
22422249
if (optind < argc && !isdigit((unsigned char)argv[optind][0])) {
22432250
filename = argv[optind++];
@@ -2266,7 +2273,9 @@ int main(int argc, char **argv)
22662273
}
22672274
js_cond_init(&progress_cond);
22682275
js_mutex_init(&progress_mutex);
2269-
js_thread_create(&progress_thread, show_progress, NULL, /*flags*/0);
2276+
if (enable_progress) {
2277+
js_thread_create(&progress_thread, show_progress, NULL, /*flags*/0);
2278+
}
22702279
for (i = 0; i < nthreads; i++) {
22712280
js_thread_create(&threads[i], run_test_dir_list,
22722281
(void *)(uintptr_t)i, /*flags*/0);
@@ -2276,7 +2285,9 @@ int main(int argc, char **argv)
22762285
js_mutex_lock(&progress_mutex);
22772286
js_cond_signal(&progress_cond);
22782287
js_mutex_unlock(&progress_mutex);
2279-
js_thread_join(progress_thread);
2288+
if (enable_progress) {
2289+
js_thread_join(progress_thread);
2290+
}
22802291
js_mutex_destroy(&progress_mutex);
22812292
js_cond_destroy(&progress_cond);
22822293
} else {

0 commit comments

Comments
 (0)