Skip to content

[native_toolchain_c] Inject FileSystem for file system access - #3555

Open
Varadraj75 wants to merge 2 commits into
dart-lang:mainfrom
Varadraj75:fix-3072-file-system
Open

[native_toolchain_c] Inject FileSystem for file system access#3555
Varadraj75 wants to merge 2 commits into
dart-lang:mainfrom
Varadraj75:fix-3072-file-system

Conversation

@Varadraj75

Copy link
Copy Markdown
Contributor

Description

Second half of the seam from #3072, following the merged ProcessManager work (#3531). Adds an optional fileSystem parameter next to processManager on CBuilder.run, CLinker.run, CLibrary.build, CLibrary.link, and ToolResolvingContext, defaulting to LocalFileSystem. All file system access in the package now goes through package:file, with glob resolution switched to listFileSystem. Public APIs keep taking Uri, so nothing user-facing changes.

As discussed on the issue, this is the combined PR with the end-to-end verification: a unit test runs CBuilder.run with a MemoryFileSystem and a FakeProcessManager, asserting the exact compiler invocations and the outputs written to the fake file system, with no real compiler and no real files. Also adds MemoryFileSystem tests for PathToolResolver and InstallLocationResolver. One caveat noted in the test: BuildInput.outputDirectory (package:hooks) hardcodes dart:io, so the shared output directory uses a real temp dir like the integration tests do; everything native_toolchain_c itself touches goes through the memory file system.

Splitting the test suite into unit and integration directories is the follow-up.

Related Issues

Fixes #3072

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've run dart tool/ci.dart --all locally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevel pubspec.yaml workspace.
  • All existing and new tests are passing. I added new tests to check the change I am making.
  • The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR.
  • I have updated CHANGELOG.md for the relevant packages. (Not needed for small changes such as doc typos).
  • I have updated the pubspec package version if necessary.

Adds an optional fileSystem parameter alongside processManager on
CBuilder, CLinker, CLibrary and ToolResolvingContext, defaulting to
LocalFileSystem, and routes all file system access through it. Glob
resolution switches to listFileSystem. Public APIs keep taking Uri,
so nothing user-facing changes.

Adds a unit test running CBuilder.run against a MemoryFileSystem and
a FakeProcessManager, asserting the full command sequence and the
outputs written to the fake file system, plus MemoryFileSystem tests
for the path and install-location resolvers.

Together with the ProcessManager work this completes the seam.

Fixes: dart-lang#3072
@Varadraj75
Varadraj75 marked this pull request as draft August 14, 2026 18:59
@Varadraj75
Varadraj75 marked this pull request as ready for review August 14, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[native_toolchain_c] Use ProcessManager and FileSystem

1 participant