Skip to content

impellerc's file I/O (via fml) is lacking #143379

@matanlurey

Description

@matanlurey

When working on #143330, the "right" thing to do is delete intermediates:

static fml::UniqueFD CreateIntermediatesDirectory() {
  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);
}

CompilerTest::CompilerTest()
    : intermediates_directory_(CreateIntermediatesDirectory()) {
  FML_CHECK(intermediates_directory_.is_valid());
}

- CompilerTest::~CompilerTest() = default;
+ CompilerTest::~CompilerTest() {
+   fml::DeleteDirectory(flutter::testing::OpenFixturesDirectory(),
+                            test_name.c_str());
+ }

However, fml::DeleteDirectory does not exist. I looked into the fml::<File I/O> related methods, and they are very minimal, and from what I heard, are not consistent across platforms (i.e. the WriteAtomically method is not actually atomic on Windows).

One suggestion from @jonahwilliams was, in the future, we move the File I/O and effectively "main()" of impellerc to Dart, and just use dart:io.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: tech-debtTechnical debt, code quality, testing, etc.engineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions