mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
Tests: Don't use TestRunners after their scope ends in test-js
The TestRunner objects at the end of test-js are destroyed after the if/else that chooses whether to run the 262 parser tests or the standard tests. Accessing TestRunner::the() after the lifetime of the TestRunners ends is UB, so return the Test::Counts from run() instead. Also, fix the destructor of TestRunner to set s_the to nullptr so that if anyone tries this type of shenanigains again, they'll get a crash :^).
This commit is contained in:
parent
f90a19ba4c
commit
e96451edc9
1 changed files with 9 additions and 6 deletions
|
@ -79,9 +79,9 @@ public:
|
||||||
s_the = this;
|
s_the = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~TestRunner() = default;
|
virtual ~TestRunner() { s_the = nullptr; };
|
||||||
|
|
||||||
void run();
|
Test::Counts run();
|
||||||
|
|
||||||
const Test::Counts& counts() const { return m_counts; }
|
const Test::Counts& counts() const { return m_counts; }
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ Vector<String> TestRunner::get_test_paths() const
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRunner::run()
|
Test::Counts TestRunner::run()
|
||||||
{
|
{
|
||||||
size_t progress_counter = 0;
|
size_t progress_counter = 0;
|
||||||
auto test_paths = get_test_paths();
|
auto test_paths = get_test_paths();
|
||||||
|
@ -212,6 +212,8 @@ void TestRunner::run()
|
||||||
warn("\033]9;-1;\033\\");
|
warn("\033]9;-1;\033\\");
|
||||||
|
|
||||||
print_test_results();
|
print_test_results();
|
||||||
|
|
||||||
|
return m_counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
static Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
||||||
|
@ -739,12 +741,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
vm = JS::VM::create();
|
vm = JS::VM::create();
|
||||||
|
|
||||||
|
Test::Counts result_counts;
|
||||||
if (test262_parser_tests)
|
if (test262_parser_tests)
|
||||||
Test262ParserTestRunner(test_root, print_times, print_progress).run();
|
result_counts = Test262ParserTestRunner(test_root, print_times, print_progress).run();
|
||||||
else
|
else
|
||||||
TestRunner(test_root, print_times, print_progress).run();
|
result_counts = TestRunner(test_root, print_times, print_progress).run();
|
||||||
|
|
||||||
vm = nullptr;
|
vm = nullptr;
|
||||||
|
|
||||||
return TestRunner::the()->counts().tests_failed > 0 ? 1 : 0;
|
return result_counts.tests_failed > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue