Commit b7a83915 authored by Wez's avatar Wez Committed by Commit Bot

Switch ScopedTaskEnvironment's Run() timeout to use ADD_FAILURE.

ScopedTaskEnvironment would previously LOG(FATAL) on Run() timeout,
causing the calling process to crash, preventing tests scheduled later
in the same batch from being run.

ScopedTaskEnvironment now uses MakeExpectedNotRunClosure() as the Run()
timeout callback, allowing test batches to run to completion.

Bug: 918724
Change-Id: I23269ee9d9e2c55108a57d4081f62a7769b1f44b
Reviewed-on: https://chromium-review.googlesource.com/c/1481655
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634938}
parent 4ce64657
......@@ -17,6 +17,7 @@
#include "base/task/sequence_manager/time_domain.h"
#include "base/task/task_scheduler/task_scheduler.h"
#include "base/task/task_scheduler/task_scheduler_impl.h"
#include "base/test/bind_test_util.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/test/test_timeouts.h"
#include "base/threading/sequence_local_storage_map.h"
......@@ -335,8 +336,7 @@ ScopedTaskEnvironment::ScopedTaskEnvironment(
? nullptr
: std::make_unique<RunLoop::ScopedRunTimeoutForTest>(
TestTimeouts::action_max_timeout(),
BindRepeating(
[]() { LOG(FATAL) << "Run() timed out."; }))) {
MakeExpectedNotRunClosure(FROM_HERE, "Run() timed out."))) {
CHECK(now_source == NowSource::REAL_TIME || mock_time_domain_)
<< "NowSource must be REAL_TIME unless we're using mock time";
CHECK(!TaskScheduler::GetInstance())
......
......@@ -25,6 +25,7 @@
#include "base/win/com_init_util.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-spi.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_POSIX)
......@@ -363,13 +364,14 @@ TEST_F(ScopedTaskEnvironmentTest, SetsDefaultRunTimeout) {
{
ScopedTaskEnvironment scoped_task_environment;
// ScopedTaskEnvironment should set a default Run() timeout that CHECKs if
// reached.
// ScopedTaskEnvironment should set a default Run() timeout that fails the
// calling test.
const RunLoop::ScopedRunTimeoutForTest* run_timeout =
RunLoop::ScopedRunTimeoutForTest::Current();
ASSERT_NE(run_timeout, old_run_timeout);
EXPECT_EQ(run_timeout->timeout(), TestTimeouts::action_max_timeout());
EXPECT_DEATH_IF_SUPPORTED({ run_timeout->on_timeout().Run(); }, "");
EXPECT_NONFATAL_FAILURE({ run_timeout->on_timeout().Run(); },
"Run() timed out");
}
EXPECT_EQ(RunLoop::ScopedRunTimeoutForTest::Current(), old_run_timeout);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment