Skip to content

Combine InMemoryAssetReader and InMemoryAssetWriter into InMemoryAssetReaderWriter #3854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

davidmorgan
Copy link
Contributor

@davidmorgan davidmorgan commented Feb 13, 2025

For #3811

For my next PR the plan was to give access to the filesystem backing a Reader.

This turned out to be hard to do because of how the tests are set up: the reader and writer are often entirely disconnected. So there is no backing filesystem, even an in-memory one.

This PR refactors to fix that in a lot of cases: so reads and writes in tests are backed by one InMemoryAssetReaderWriter instance.

Copy link

github-actions bot commented Feb 13, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

@davidmorgan davidmorgan force-pushed the unify-write-read branch 4 times, most recently from b85997a to 9fb55d1 Compare February 13, 2025 11:40
…yAssetReaderWriter`.

Update tests so that reader and writer are backed by the same `InMemoryAssetReaderWriter`.
@davidmorgan davidmorgan marked this pull request as ready for review February 13, 2025 12:27
@davidmorgan davidmorgan requested a review from jensjoha February 13, 2025 12:27
@@ -311,38 +338,46 @@ void main() {
rootPackage('a', path: path.absolute('a')): ['b'],
package('b', path: path.absolute('a', 'b')): []
});
readerWriter = InMemoryRunnerAssetReaderWriter(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this (and another on line 472) create a new one (which doesn't have the package config written)? If this is what we want a comment explaining why would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good point: the root package is always a so there is no need to create a new one, removed in both places.

@@ -70,12 +68,11 @@ void _printOnFailure(LogRecord record) {
Future<BuildResult> testBuilders(
List<BuilderApplication> builders,
Map<String, /*String|List<int>*/ Object> inputs, {
BuildResult? resumeFrom,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do it this way? The whole Expando thing seems like somewhat of a hack, and unless there's a good reason I'd prefer not to use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

I was trying to avoid changing the return type to avoid such a big breaking change to tests ... but I was confused, I thought this was in build_test which is published. But fortunately it's in _test_common which we can just change. So, changed the return type :)

Copy link
Contributor Author

@davidmorgan davidmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@@ -70,12 +68,11 @@ void _printOnFailure(LogRecord record) {
Future<BuildResult> testBuilders(
List<BuilderApplication> builders,
Map<String, /*String|List<int>*/ Object> inputs, {
BuildResult? resumeFrom,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

I was trying to avoid changing the return type to avoid such a big breaking change to tests ... but I was confused, I thought this was in build_test which is published. But fortunately it's in _test_common which we can just change. So, changed the return type :)

@davidmorgan davidmorgan merged commit 7dbcd85 into dart-lang:master Feb 14, 2025
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants