Skip to content

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

Merged
merged 5 commits into from
Sep 30, 2019
Merged

Conversation

corwinsheahan-wf
Copy link
Contributor

@corwinsheahan-wf corwinsheahan-wf commented Sep 24, 2019

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):

  • Without using the --hack-fast-builds flag, incremental rebuild time was 12m 35s
  • With using the --hack-fast-builds flag and specifying the test as test/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):

  • Without using the --hack-fast-builds flag, incremental rebuild time was 8m 9s
  • With using the --hack-fast-builds flag and specifying the test as test/unit/sox_ui/flux/test_form/test_form_store_test.dart: 36s

Testing:

This modifies both the test and the gen-test-runner tasks. Pick a repo, publink this branch, and run these steps:

  • ddev test works normally in dart 1
  • ddev test path/to/file/ works as it did in dart 1
  • ddev test works in dart 2
  • ddev test path/to/file works in dart 2 and doesn’t re-write runners
  • ddev 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 use git status to verify):
  • Run ddev gen-test-runner && ddev format and verify there are not any code changes.

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@corwinsheahan-wf corwinsheahan-wf marked this pull request as ready for review September 25, 2019 19:40
if (testFilePath.contains(_config.directory)) {
mapConfigToTestFiles.containsKey(_config)
? mapConfigToTestFiles[_config].add(testFilePath)
: mapConfigToTestFiles[_config] = [testFilePath];

Choose a reason for hiding this comment

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

You could use putIfAbsent.

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) {

Choose a reason for hiding this comment

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

Why the underscore?

Copy link
Contributor Author

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) {

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?

Copy link
Contributor Author

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.

// Empty all other unused generated runners
for (final _config in config.genTestRunner.configs) {
await genTestRunner(_config, filesToInclude: []);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

dartfmt?

Copy link
Contributor

@evanweible-wf evanweible-wf left a comment

Choose a reason for hiding this comment

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

Approach looks good!

@willdrach-wk
Copy link

QA+1 - verified with a local dependency override in graph_app

  • ddev test works normally in dart 1
  • ddev test path/to/file/ works as it did in dart 1
  • ddev test works in dart 2
  • ddev test path/to/file works in dart 2 and doesn’t re-write runners
  • ddev 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 use git status to verify):
  • Run ddev gen-test-runner && ddev format and verify there are not any code changes.

@corwinsheahan-wf
Copy link
Contributor Author

corwinsheahan-wf commented Sep 30, 2019

@corwinsheahan-wf
Copy link
Contributor Author

corwinsheahan-wf commented Sep 30, 2019

QA +1

  • All consumer testing branches pass
  • QA provided here
  • CI broken is an unrelated known issue, and will be doing away with dart_dev v3, which is imminent

Merging into master.
@Workiva/release-management-p

@rmconsole6-wk rmconsole6-wk merged commit 3a3db68 into master Sep 30, 2019
@rmconsole6-wk rmconsole6-wk deleted the gen_test_runner_in_test_task branch September 30, 2019 21:46
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.

7 participants