Commit a6fb79e9 authored by Etienne Pierre-Doray's avatar Etienne Pierre-Doray Committed by Commit Bot

Use singleton feature list in content::UnitTestTestSuite.

Commit 3f40244c had to be reverted due to a
data race between ScopedFeatureList's destructor and a feature in the scheduler.
Sample failure: https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Linux%20TSan%20Tests/30398
There is no need for the feature list to be restored with ScopedFeatureList in
the test launcher. Since the scheduler used for test launcher is leaked,
it makes sense to have a singleton feature list instead of a ScopedFeatureList.

Bug: 847501, 846380
Change-Id: I738ebebe5aa04871427399bcf012c072d7f0212c
Reviewed-on: https://chromium-review.googlesource.com/c/1361441
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616090}
parent 0dc6e0ae
......@@ -6,6 +6,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/test/test_suite.h"
......@@ -34,7 +35,14 @@ UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite)
command_line->GetSwitchValueASCII(switches::kEnableFeatures);
std::string disabled =
command_line->GetSwitchValueASCII(switches::kDisableFeatures);
feature_list_.InitFromCommandLine(enabled, disabled);
// The TaskScheduler created by the test launcher is never destroyed.
// Similarly, the FeatureList created here is never destroyed so it
// can safely be accessed by the TaskScheduler.
std::unique_ptr<base::FeatureList> feature_list =
std::make_unique<base::FeatureList>();
feature_list->InitializeFromCommandLine(enabled, disabled);
base::FeatureList::SetInstance(std::move(feature_list));
#if defined(OS_FUCHSIA)
// Use headless ozone platform on Fuchsia by default.
......
......@@ -8,7 +8,6 @@
#include <memory>
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#if defined(USE_AURA)
......@@ -40,8 +39,6 @@ class UnitTestTestSuite {
private:
std::unique_ptr<base::TestSuite> test_suite_;
base::test::ScopedFeatureList feature_list_;
std::unique_ptr<TestBlinkWebUnitTestSupport> blink_test_support_;
#if defined(USE_AURA)
std::unique_ptr<aura::AuraTestSuiteSetup> aura_test_suite_setup_;
......
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