Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] Run pub get for custom-test #5322

Merged

Conversation

stuartmorgan-g
Copy link
Contributor

When running a Dart test script for custom-test, pub get needs to be
run first in order for it to work in a clean environment such as CI.

This will unblock enabling Pigeon's Dart tests in flutter/packages.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

When running a Dart test script for `custom-test`, `pub get` needs to be
run first in order for it to work in a clean environment such as CI.

This will unblock enabling Pigeon's Dart tests in flutter/packages.
@@ -43,10 +43,19 @@ class CustomTestCommand extends PackageLoopingCommand {

// Run the custom Dart script if presest.
if (script.existsSync()) {
final int exitCode = await processRunner.runAndStream(
// Ensure that dependencies are available.
final int pubGetExitCode = await processRunner.runAndStream(
Copy link
Member

Choose a reason for hiding this comment

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

runAndStream prints to stdout and stderr? If so this looks good. If not we should make sure we output that information when the exit code != 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's what the "AndStream" is supposed to capturing:

/// Run the [executable] with [args] and stream output to stderr and stdout.

Comment on lines +146 to +147
MockProcess(exitCode: 0), // pub get
MockProcess(exitCode: 1), // test script
Copy link
Member

Choose a reason for hiding this comment

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

This is a fragile. It would be nice if mockProcessesForExecutable was a Map<String, List<Process>> Where the key is the name of the process and the value is a list to handle multiple invocations of the same process. No need to fix it here if it is a lot of work, just wanted to call it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fragile.

Indeed, it's been on my list to get back to at some point.

It would be nice if mockProcessesForExecutable was a Map<String, List<Process>> Where the key is the name of the process and the value is a list to handle multiple invocations of the same process.

That's exactly what it is, actually (now; it used to just be a List<Process>, and this was the incremental improvement I made a while back because that was very fragile, and seriously impaired my ability to build out meaningful test coverage of the tool during that effort). The problem that's left is that it's using a list instead of an argument matcher, so we can't distinguish between dart pub get and dart run tool/run_tests.dart, and still have to handle that positionally instead.

@stuartmorgan-g stuartmorgan-g added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Apr 21, 2022
@stuartmorgan-g stuartmorgan-g merged commit 755fb82 into flutter:main Apr 21, 2022
@stuartmorgan-g stuartmorgan-g deleted the tool-custom-test-pub-get branch April 21, 2022 20:08
@stuartmorgan-g stuartmorgan-g removed the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Apr 21, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 22, 2022
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
When running a Dart test script for `custom-test`, `pub get` needs to be
run first in order for it to work in a clean environment such as CI.

This will unblock enabling Pigeon's Dart tests in flutter/packages.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants