Skip to content

Commit 692fa86

Browse files
authored
modify errors_seen under lock to avoid race (#7619)
1 parent 85c5847 commit 692fa86

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/util/unit_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,10 @@ void TestList::ThreadContextImpl::run(SharedContextImpl::Entry entry, UniqueLock
718718
const Test& test = *entry.test;
719719
TestContext test_context(*this, test.details, entry.test_index, entry.recurrence_index);
720720
shared_context.reporter.begin(test_context);
721-
lock.unlock();
722-
723721
last_line_seen = test.details.line_number;
724722
errors_seen = false;
723+
lock.unlock();
724+
725725
Timer timer;
726726
try {
727727
(*test.run_func)(test_context);
@@ -735,10 +735,11 @@ void TestList::ThreadContextImpl::run(SharedContextImpl::Entry entry, UniqueLock
735735
test_context.test_failed(util::format("Unhandled exception after line %1 of unknown type", last_line_seen));
736736
}
737737
double elapsed_time = timer.get_elapsed_time();
738+
739+
lock.lock();
738740
if (errors_seen)
739741
++num_failed_tests;
740742

741-
lock.lock();
742743
shared_context.reporter.end(test_context, elapsed_time);
743744
}
744745

0 commit comments

Comments
 (0)