|
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | 5 | #include "impeller/compiler/compiler_test.h" |
| 6 | +#include "flutter/fml/paths.h" |
| 7 | +#include "flutter/fml/process.h" |
6 | 8 |
|
7 | 9 | #include <algorithm> |
| 10 | +#include <filesystem> |
8 | 11 |
|
9 | 12 | namespace impeller { |
10 | 13 | namespace compiler { |
11 | 14 | namespace testing { |
12 | 15 |
|
13 | | -static fml::UniqueFD CreateIntermediatesDirectory() { |
| 16 | +static std::string GetIntermediatesPath() { |
14 | 17 | auto test_name = flutter::testing::GetCurrentTestName(); |
15 | 18 | std::replace(test_name.begin(), test_name.end(), '/', '_'); |
16 | 19 | std::replace(test_name.begin(), test_name.end(), '.', '_'); |
17 | | - return fml::OpenDirectory(flutter::testing::OpenFixturesDirectory(), |
18 | | - test_name.c_str(), |
19 | | - true, // create if necessary |
20 | | - fml::FilePermission::kReadWrite); |
| 20 | + std::stringstream dir_name; |
| 21 | + dir_name << test_name << "_" << std::to_string(fml::GetCurrentProcId()); |
| 22 | + return fml::paths::JoinPaths( |
| 23 | + {flutter::testing::GetFixturesPath(), dir_name.str()}); |
21 | 24 | } |
22 | 25 |
|
23 | | -CompilerTest::CompilerTest() |
24 | | - : intermediates_directory_(CreateIntermediatesDirectory()) { |
| 26 | +CompilerTest::CompilerTest() : intermediates_path_(GetIntermediatesPath()) { |
| 27 | + intermediates_directory_ = |
| 28 | + fml::OpenDirectory(intermediates_path_.c_str(), |
| 29 | + true, // create if necessary |
| 30 | + fml::FilePermission::kReadWrite); |
25 | 31 | FML_CHECK(intermediates_directory_.is_valid()); |
26 | 32 | } |
27 | 33 |
|
28 | | -CompilerTest::~CompilerTest() = default; |
| 34 | +CompilerTest::~CompilerTest() { |
| 35 | + intermediates_directory_.reset(); |
| 36 | + |
| 37 | + std::filesystem::remove_all(std::filesystem::path(intermediates_path_)); |
| 38 | +} |
29 | 39 |
|
30 | 40 | static std::string ReflectionHeaderName(const char* fixture_name) { |
31 | 41 | std::stringstream stream; |
|
0 commit comments