Skip to content

Add unit test coverage for incremental build invalidation. #3985

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 2 commits into from
Apr 29, 2025

Conversation

davidmorgan
Copy link
Contributor

@davidmorgan davidmorgan commented Apr 28, 2025

For #3811.

Add a new type of unit test covering invalidation logic: build, modify inputs, build again, verify what gets written and/or deleted.

There is a lot to cover here:

The test cases added in this PR only have generated assets with inputs that are also primary inputs. Already we encounter one existing issue #3875 to do with not deleting assets that have become stale. For now I will preserve rather than fix this, aiming for a release that matches current behaviour before fixing :)

Follow-up PRs will build on this to add test coverage for more complex cases: 1) when generators have more single-asset inputs than just the primary input; and 2) when generators have inputs from resolving source, i.e. full transitive deps inputs.

Mostly this coverage is already present in existing unit tests and e2e tests, but I wanted to add smaller+faster+clearer coverage before the next PRs changing the invalidation logic.

Copy link

github-actions bot commented Apr 28, 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 invalidate-tests branch 4 times, most recently from d7527b1 to a005f7e Compare April 29, 2025 09:01
@davidmorgan davidmorgan marked this pull request as ready for review April 29, 2025 09:16
@davidmorgan davidmorgan requested a review from jensjoha April 29, 2025 09:16
/// Adds a builder to the test.
///
/// [from] and [to] are the input and output extension of the builder,
/// without ".dart". So `from: '', to: '.g.dart'` is a builder that takes

Choose a reason for hiding this comment

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

From

  TestBuilder(this._tester, String from, Iterable<String> to, this.isOptional)
    : buildExtensions = {'$from.dart': to.map((to) => '$to.dart').toList()};

it seems that the "to" here should just be .g?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks. Done.

@davidmorgan davidmorgan merged commit 49821e9 into dart-lang:master Apr 29, 2025
74 of 75 checks passed
@davidmorgan davidmorgan deleted the invalidate-tests branch April 29, 2025 10:14
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