-
Notifications
You must be signed in to change notification settings - Fork 40
Gen test runner in test task #315
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
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
lib/src/tasks/test/cli.dart
Outdated
if (testFilePath.contains(_config.directory)) { | ||
mapConfigToTestFiles.containsKey(_config) | ||
? mapConfigToTestFiles[_config].add(testFilePath) | ||
: mapConfigToTestFiles[_config] = [testFilePath]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use putIfAbsent.
lib/src/tasks/test/cli.dart
Outdated
final mapConfigToTestFiles = <TestRunnerConfig, | ||
List<String> /* tests to include in runner */>{}; | ||
// Construct mapping from config to tests which should be ran in that config | ||
for (final _config in config.genTestRunner.configs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the underscore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To not shadow config
List<String> /* tests to include in runner */>{}; | ||
// Construct mapping from config to tests which should be ran in that config | ||
for (final _config in config.genTestRunner.configs) { | ||
for (final testFilePath in parsedArgs.rest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be some issue if someone also passed the --release
flag instead of or at the end of end of a list of files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.rest
includes anything which wasn't specified as a top level option/flag, so we should be good here.
lib/src/tasks/test/cli.dart
Outdated
// Empty all other unused generated runners | ||
for (final _config in config.genTestRunner.configs) { | ||
await genTestRunner(_config, filesToInclude: []); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dartfmt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach looks good!
QA+1 - verified with a local dependency override in graph_app
|
QA +1
Merging into master. |
Description:
Incremental builds are slow for tests, since often a single library file can be transitively included in many tests, especially in the large repos. When there is a change in this file, that can cause very significant incremental build times.
This workaround adds a
--hack-fast-builds
flag, which re-writes the generated runners at run time in the test task. Use of this flag with a specific file to test will re-write the generated runners to include only this file. In practice, this dramatically improves incremental build times.Examples in graph_app:
When changing
lib/src/components/vertex_selector.dart
(with an otherwise warm cache):--hack-fast-builds
flag, incremental rebuild time was12m 35s
--hack-fast-builds
flag and specifying the test astest/unit/common/components/vertex_selector_test.dart
:45s
When changing
lib/src/sox_ui/src/flux/test_form/test_form_store.dart
(with an otherwise warm cache):--hack-fast-builds
flag, incremental rebuild time was8m 9s
--hack-fast-builds
flag and specifying the test astest/unit/sox_ui/flux/test_form/test_form_store_test.dart
:36s
Testing:
This modifies both the
test
and thegen-test-runner
tasks. Pick a repo, publink this branch, and run these steps:ddev test
works normally in dart 1ddev test path/to/file/
works as it did in dart 1ddev test
works in dart 2ddev test path/to/file
works in dart 2 and doesn’t re-write runnersddev test —hack-fast-builds path/to/file/
works in dart 2 and re-writes runners, improving iterative build times, and re-writes runners back to original contents after tests run (Can usegit status
to verify):ddev gen-test-runner && ddev format
and verify there are not any code changes.