diff --git a/Libraries/LibTest/JavaScriptTestRunner.h b/Libraries/LibTest/JavaScriptTestRunner.h index 8f737c2864..758bdbf87c 100644 --- a/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Libraries/LibTest/JavaScriptTestRunner.h @@ -149,8 +149,8 @@ extern IntermediateRunFileResult (*g_run_file)(ByteString const&, JS::Realm&, JS class TestRunner : public ::Test::TestRunner { public: - TestRunner(ByteString test_root, ByteString common_path, bool print_times, bool print_progress, bool print_json, bool detailed_json) - : ::Test::TestRunner(move(test_root), print_times, print_progress, print_json, detailed_json) + TestRunner(ByteString test_root, ByteString common_path, bool print_times, bool print_progress, bool print_json, bool detailed_json, bool print_each_test) + : ::Test::TestRunner(move(test_root), print_times, print_progress, print_json, detailed_json, print_each_test) , m_common_path(move(common_path)) { g_test_root = m_test_root; diff --git a/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index 6f98d5eae6..f7f708a440 100644 --- a/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -102,6 +102,7 @@ int main(int argc, char** argv) bool print_progress = false; bool print_json = false; bool per_file = false; + bool print_each_test = false; StringView specified_test_root; ByteString common_path; Vector test_globs; @@ -126,6 +127,7 @@ int main(int argc, char** argv) args_parser.add_option(print_json, "Show results as JSON", "json", 'j'); args_parser.add_option(per_file, "Show detailed per-file results as JSON (implies -j)", "per-file"); + args_parser.add_option(print_each_test, "Print each test file before running it", "verbose", 'v'); args_parser.add_option(g_collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g'); args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd'); args_parser.add_option(test_globs, "Only run tests matching the given glob", "filter", 'f', "glob"); @@ -213,7 +215,7 @@ int main(int argc, char** argv) }; } - Test::JS::TestRunner test_runner(test_root, common_path, print_times, print_progress, print_json, per_file); + Test::JS::TestRunner test_runner(test_root, common_path, print_times, print_progress, print_json, per_file, print_each_test); test_runner.run(test_globs); g_vm = nullptr; diff --git a/Libraries/LibTest/TestRunner.h b/Libraries/LibTest/TestRunner.h index 129ef5f1ca..fbc785b150 100644 --- a/Libraries/LibTest/TestRunner.h +++ b/Libraries/LibTest/TestRunner.h @@ -51,12 +51,13 @@ public: return s_the; } - TestRunner(ByteString test_root, bool print_times, bool print_progress, bool print_json, bool detailed_json = false) + TestRunner(ByteString test_root, bool print_times, bool print_progress, bool print_json, bool detailed_json = false, bool print_each_test = false) : m_test_root(move(test_root)) , m_print_times(print_times) , m_print_progress(print_progress) , m_print_json(print_json) , m_detailed_json(detailed_json) + , m_print_each_test(print_each_test) { VERIFY(!s_the); s_the = this; @@ -98,6 +99,7 @@ protected: bool m_print_progress; bool m_print_json; bool m_detailed_json; + bool m_print_each_test; double m_total_elapsed_time_in_ms { 0 }; Test::Counts m_counts; @@ -176,7 +178,7 @@ inline void TestRunner::run(ReadonlySpan test_globs) ++total_tests; } - bool live_display_enabled = !m_print_json && stdout_is_tty() && begin_live_display(); + bool live_display_enabled = !m_print_json && !m_print_each_test && stdout_is_tty() && begin_live_display(); if (live_display_enabled) render_live_display(0, total_tests); @@ -193,6 +195,11 @@ inline void TestRunner::run(ReadonlySpan test_globs) render_live_display(progress_counter - 1, total_tests); } + if (m_print_each_test) { + auto label = LexicalPath::relative_path(path, m_test_root); + warnln("[{}/{}] {}", progress_counter, total_tests, label.has_value() ? label.release_value() : path); + } + do_run_single_test(path, progress_counter, total_tests); if (live_display_enabled)