Commit 6d7df0f9 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[test] Fix default trace file name for parametrised tests.

When test tracing is enabled, by default browser tests generate a file
name based on the test name. However, when a test a parametrised, it has
slashes in its full name (e.g. All/Foo.Bar/0).

Replace slashes with underscores to ensure that we don't fail to
actually write a trace file to the file.

R=sky@chromium.org

Change-Id: I8073e0dbd925b9c35e97dd7f6726b6b5b9210d7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207376
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770777}
parent c5a2807c
......@@ -566,12 +566,17 @@ void BrowserTestBase::WaitUntilJavaIsReady(base::OnceClosure quit_closure) {
namespace {
std::string GetDefaultTraceFilaneme() {
std::string GetDefaultTraceFileneme() {
std::string test_suite_name = ::testing::UnitTest::GetInstance()
->current_test_info()
->test_suite_name();
std::string test_name =
::testing::UnitTest::GetInstance()->current_test_info()->name();
// Parameterised tests might have slashes in their full name — replace them
// before using it as a file name to avoid trying to write to an incorrect
// location.
base::ReplaceChars(test_suite_name, "/", "_", &test_suite_name);
base::ReplaceChars(test_name, "/", "_", &test_name);
// Add random number to the trace file to distinguish traces from different
// test runs.
// We don't use timestamp here to avoid collisions with parallel runs of the
......@@ -679,7 +684,7 @@ void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
// If there was no file specified, put a hardcoded one in the current
// working directory.
if (trace_file.empty())
trace_file = base::FilePath().AppendASCII(GetDefaultTraceFilaneme());
trace_file = base::FilePath().AppendASCII(GetDefaultTraceFileneme());
// Wait for tracing to collect results from the renderers.
base::RunLoop run_loop;
......
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