Support gtest-parallel when running Impeller unit tests (flutter/engine#51079)
ImpellerC tests that use a temporary directory will append the current process ID to the directory name to avoid collisions. The temporary directory will also be deleted after each test case completes. See https://github.com/flutter/flutter/issues/143379
This commit is contained in:
@@ -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/native_library_posix.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/platform/posix/paths_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/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.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/fml/platform/posix/shared_mutex_posix.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/platform/win/command_line_win.cc + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/fml/platform/win/command_line_win.cc + ../../../flutter/LICENSE
|
||||||
@@ -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/native_library_win.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/platform/win/paths_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/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.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/platform/win/wstring_conversion.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/fml/platform/win/wstring_conversion.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/posix_wrappers.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.cc + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/raster_thread_merger.h + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/fml/raster_thread_merger.h + ../../../flutter/LICENSE
|
||||||
ORIGIN: ../../../flutter/fml/shared_thread_merger.cc + ../../../flutter/LICENSE
|
ORIGIN: ../../../flutter/fml/shared_thread_merger.cc + ../../../flutter/LICENSE
|
||||||
@@ -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/native_library_posix.cc
|
||||||
FILE: ../../../flutter/fml/platform/posix/paths_posix.cc
|
FILE: ../../../flutter/fml/platform/posix/paths_posix.cc
|
||||||
FILE: ../../../flutter/fml/platform/posix/posix_wrappers_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.cc
|
||||||
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.h
|
FILE: ../../../flutter/fml/platform/posix/shared_mutex_posix.h
|
||||||
FILE: ../../../flutter/fml/platform/win/command_line_win.cc
|
FILE: ../../../flutter/fml/platform/win/command_line_win.cc
|
||||||
@@ -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/native_library_win.cc
|
||||||
FILE: ../../../flutter/fml/platform/win/paths_win.cc
|
FILE: ../../../flutter/fml/platform/win/paths_win.cc
|
||||||
FILE: ../../../flutter/fml/platform/win/posix_wrappers_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.cc
|
||||||
FILE: ../../../flutter/fml/platform/win/wstring_conversion.h
|
FILE: ../../../flutter/fml/platform/win/wstring_conversion.h
|
||||||
FILE: ../../../flutter/fml/posix_wrappers.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.cc
|
||||||
FILE: ../../../flutter/fml/raster_thread_merger.h
|
FILE: ../../../flutter/fml/raster_thread_merger.h
|
||||||
FILE: ../../../flutter/fml/shared_thread_merger.cc
|
FILE: ../../../flutter/fml/shared_thread_merger.cc
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ source_set("fml") {
|
|||||||
"paths.cc",
|
"paths.cc",
|
||||||
"paths.h",
|
"paths.h",
|
||||||
"posix_wrappers.h",
|
"posix_wrappers.h",
|
||||||
|
"process.h",
|
||||||
"raster_thread_merger.cc",
|
"raster_thread_merger.cc",
|
||||||
"raster_thread_merger.h",
|
"raster_thread_merger.h",
|
||||||
"shared_thread_merger.cc",
|
"shared_thread_merger.cc",
|
||||||
@@ -251,6 +252,7 @@ source_set("fml") {
|
|||||||
"platform/win/native_library_win.cc",
|
"platform/win/native_library_win.cc",
|
||||||
"platform/win/paths_win.cc",
|
"platform/win/paths_win.cc",
|
||||||
"platform/win/posix_wrappers_win.cc",
|
"platform/win/posix_wrappers_win.cc",
|
||||||
|
"platform/win/process_win.cc",
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
sources += [
|
sources += [
|
||||||
@@ -260,6 +262,7 @@ source_set("fml") {
|
|||||||
"platform/posix/native_library_posix.cc",
|
"platform/posix/native_library_posix.cc",
|
||||||
"platform/posix/paths_posix.cc",
|
"platform/posix/paths_posix.cc",
|
||||||
"platform/posix/posix_wrappers_posix.cc",
|
"platform/posix/posix_wrappers_posix.cc",
|
||||||
|
"platform/posix/process_posix.cc",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
engine/src/flutter/fml/platform/posix/process_posix.cc
Normal file
13
engine/src/flutter/fml/platform/posix/process_posix.cc
Normal file
@@ -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
engine/src/flutter/fml/platform/win/process_win.cc
Normal file
13
engine/src/flutter/fml/platform/win/process_win.cc
Normal file
@@ -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
engine/src/flutter/fml/process.h
Normal file
14
engine/src/flutter/fml/process.h
Normal file
@@ -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_
|
||||||
@@ -3,29 +3,39 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "impeller/compiler/compiler_test.h"
|
#include "impeller/compiler/compiler_test.h"
|
||||||
|
#include "flutter/fml/paths.h"
|
||||||
|
#include "flutter/fml/process.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace impeller {
|
namespace impeller {
|
||||||
namespace compiler {
|
namespace compiler {
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
static fml::UniqueFD CreateIntermediatesDirectory() {
|
static std::string GetIntermediatesPath() {
|
||||||
auto test_name = flutter::testing::GetCurrentTestName();
|
auto test_name = flutter::testing::GetCurrentTestName();
|
||||||
std::replace(test_name.begin(), test_name.end(), '/', '_');
|
std::replace(test_name.begin(), test_name.end(), '/', '_');
|
||||||
std::replace(test_name.begin(), test_name.end(), '.', '_');
|
std::replace(test_name.begin(), test_name.end(), '.', '_');
|
||||||
return fml::OpenDirectory(flutter::testing::OpenFixturesDirectory(),
|
std::stringstream dir_name;
|
||||||
test_name.c_str(),
|
dir_name << test_name << "_" << std::to_string(fml::GetCurrentProcId());
|
||||||
true, // create if necessary
|
return fml::paths::JoinPaths(
|
||||||
fml::FilePermission::kReadWrite);
|
{flutter::testing::GetFixturesPath(), dir_name.str()});
|
||||||
}
|
}
|
||||||
|
|
||||||
CompilerTest::CompilerTest()
|
CompilerTest::CompilerTest() : intermediates_path_(GetIntermediatesPath()) {
|
||||||
: intermediates_directory_(CreateIntermediatesDirectory()) {
|
intermediates_directory_ =
|
||||||
|
fml::OpenDirectory(intermediates_path_.c_str(),
|
||||||
|
true, // create if necessary
|
||||||
|
fml::FilePermission::kReadWrite);
|
||||||
FML_CHECK(intermediates_directory_.is_valid());
|
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) {
|
static std::string ReflectionHeaderName(const char* fixture_name) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class CompilerTest : public ::testing::TestWithParam<TargetPlatform> {
|
|||||||
const char* entry_point_name = "main") const;
|
const char* entry_point_name = "main") const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string intermediates_path_;
|
||||||
fml::UniqueFD intermediates_directory_;
|
fml::UniqueFD intermediates_directory_;
|
||||||
|
|
||||||
CompilerTest(const CompilerTest&) = delete;
|
CompilerTest(const CompilerTest&) = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user