Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Support gtest-parallel when running Impeller unit tests #51079

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -34705,6 +34705,7 @@ ORIGIN: ../../../flutter/fml/platform/posix/mapping_posix.cc + ../../../flutter/
ORIGIN: ../../../flutter/fml/platform/posix/native_library_posix.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/posix/paths_posix.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/posix/process_posix.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/command_line_win.cc + ../../../flutter/LICENSE
Expand All @@ -34717,9 +34718,11 @@ ORIGIN: ../../../flutter/fml/platform/win/message_loop_win.h + ../../../flutter/
ORIGIN: ../../../flutter/fml/platform/win/native_library_win.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/paths_win.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/posix_wrappers_win.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/process_win.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/wstring_conversion.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/platform/win/wstring_conversion.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/posix_wrappers.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/process.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/raster_thread_merger.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/raster_thread_merger.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/fml/shared_thread_merger.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -37546,6 +37549,7 @@ FILE: ../../../flutter/fml/platform/posix/mapping_posix.cc
FILE: ../../../flutter/fml/platform/posix/native_library_posix.cc
FILE: ../../../flutter/fml/platform/posix/paths_posix.cc
FILE: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc
FILE: ../../../flutter/fml/platform/posix/process_posix.cc
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.cc
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.h
FILE: ../../../flutter/fml/platform/win/command_line_win.cc
Expand All @@ -37558,9 +37562,11 @@ FILE: ../../../flutter/fml/platform/win/message_loop_win.h
FILE: ../../../flutter/fml/platform/win/native_library_win.cc
FILE: ../../../flutter/fml/platform/win/paths_win.cc
FILE: ../../../flutter/fml/platform/win/posix_wrappers_win.cc
FILE: ../../../flutter/fml/platform/win/process_win.cc
FILE: ../../../flutter/fml/platform/win/wstring_conversion.cc
FILE: ../../../flutter/fml/platform/win/wstring_conversion.h
FILE: ../../../flutter/fml/posix_wrappers.h
FILE: ../../../flutter/fml/process.h
FILE: ../../../flutter/fml/raster_thread_merger.cc
FILE: ../../../flutter/fml/raster_thread_merger.h
FILE: ../../../flutter/fml/shared_thread_merger.cc
Expand Down
3 changes: 3 additions & 0 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ source_set("fml") {
"paths.cc",
"paths.h",
"posix_wrappers.h",
"process.h",
"raster_thread_merger.cc",
"raster_thread_merger.h",
"shared_thread_merger.cc",
Expand Down Expand Up @@ -251,6 +252,7 @@ source_set("fml") {
"platform/win/native_library_win.cc",
"platform/win/paths_win.cc",
"platform/win/posix_wrappers_win.cc",
"platform/win/process_win.cc",
]
} else {
sources += [
Expand All @@ -260,6 +262,7 @@ source_set("fml") {
"platform/posix/native_library_posix.cc",
"platform/posix/paths_posix.cc",
"platform/posix/posix_wrappers_posix.cc",
"platform/posix/process_posix.cc",
]
}
}
Expand Down
13 changes: 13 additions & 0 deletions fml/platform/posix/process_posix.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <unistd.h>

namespace fml {

int GetCurrentProcId() {
return static_cast<int>(getpid());
}

} // namespace fml
13 changes: 13 additions & 0 deletions fml/platform/win/process_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <windows.h>

namespace fml {

int GetCurrentProcId() {
return static_cast<int>(::GetCurrentProcessId());
}

} // namespace fml
14 changes: 14 additions & 0 deletions fml/process.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_FML_PROCESS_H_
#define FLUTTER_FML_PROCESS_H_

namespace fml {

int GetCurrentProcId();

} // namespace fml

#endif // FLUTTER_FML_PROCESS_H_
26 changes: 18 additions & 8 deletions impeller/compiler/compiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,39 @@
// found in the LICENSE file.

#include "impeller/compiler/compiler_test.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/process.h"

#include <algorithm>
#include <filesystem>

namespace impeller {
namespace compiler {
namespace testing {

static fml::UniqueFD CreateIntermediatesDirectory() {
static std::string GetIntermediatesPath() {
auto test_name = flutter::testing::GetCurrentTestName();
std::replace(test_name.begin(), test_name.end(), '/', '_');
std::replace(test_name.begin(), test_name.end(), '.', '_');
return fml::OpenDirectory(flutter::testing::OpenFixturesDirectory(),
test_name.c_str(),
true, // create if necessary
fml::FilePermission::kReadWrite);
std::stringstream dir_name;
dir_name << test_name << "_" << std::to_string(fml::GetCurrentProcId());
return fml::paths::JoinPaths(
{flutter::testing::GetFixturesPath(), dir_name.str()});
}

CompilerTest::CompilerTest()
: intermediates_directory_(CreateIntermediatesDirectory()) {
CompilerTest::CompilerTest() : intermediates_path_(GetIntermediatesPath()) {
intermediates_directory_ =
fml::OpenDirectory(intermediates_path_.c_str(),
true, // create if necessary
fml::FilePermission::kReadWrite);
FML_CHECK(intermediates_directory_.is_valid());
}

CompilerTest::~CompilerTest() = default;
CompilerTest::~CompilerTest() {
intermediates_directory_.reset();

std::filesystem::remove_all(std::filesystem::path(intermediates_path_));
}

static std::string ReflectionHeaderName(const char* fixture_name) {
std::stringstream stream;
Expand Down
1 change: 1 addition & 0 deletions impeller/compiler/compiler_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CompilerTest : public ::testing::TestWithParam<TargetPlatform> {
const char* entry_point_name = "main") const;

private:
std::string intermediates_path_;
fml::UniqueFD intermediates_directory_;

CompilerTest(const CompilerTest&) = delete;
Expand Down