191 Commits

Author SHA1 Message Date
d2bac9116b [flutter_plugin_tools] Migrate 'test' to new base command (#4133)
Migrates `test` to the new package looping base command.

Refactors the bulk of the logic to helpers for easier understanding of the flow.

Part of flutter/flutter#83413
2021-07-07 08:32:03 -07:00
b7ff215760 [flutter_plugin_tools] Add --packages, and deprecated --plugins (#4134)
Most of the tool operates on packages in general, and the targetting
done currently by the `--plugins` flag is not actually restricted to
plugins, so this makes the name less confusing.

Part of https://github.com/flutter/flutter/issues/83413
2021-07-04 09:26:28 -07:00
d2761ab1de [flutter_plugin_tool] Add more failure test coverage (#4132)
Many commands had insufficient failure testing. This adds new tests that
ensure that for every Process call, at least one test fails if a failure
from that process were ignored (with the exception of calls in the
`publish` command, which has a custom process mocking system, so was out
of scope here; it already has more coverage than most tests did though.)

For a few existing failure tests, adds output checks to ensure that they
are testing for the *right* failures.

Other changes:
- Adds convenience constructors to MockProcess for the common cases of a
  mock process that just exits with a 0 or 1 status, to reduce test
  verbosity.
- Fixes a few bugs that were found by the new tests.
- Minor test cleanup, especially cases where a mock process was being
  set up just to make all calls succeed, which is the default as of
  recent changes.
2021-07-02 10:49:04 -07:00
6fe9a8ef82 [flutter_plugin_tools] Migrate publish-check to the new base command (#4119)
To support this command's --machine flag, which moves all normal output into a field in a JSON struct, adds a way of capturing output and providing it to the command subclass on completion.

Part of flutter/flutter#83413
2021-07-02 09:30:49 -07:00
b9f601cc7b [flutter_plugin_tools] Remove most exitOnError:true usage (#4130)
The intent of package-looping commands is that we always want to run them for all the targeted packages, accumulating failures, and then report them all at the end, so we don't end up with the problem of only finding errors one at a time. However, some of them were using `exitOnError: true` for the underlying commands, causing the first error to be fatal to the test.

This PR:
- Removes all use of `exitOnError: true` from the package-looping commands. (It's still used in `format`, but fixing that is a larger issue, and less important due to the way `format` is currently structured.)
- Fixes the mock process runner used in our tests to correctly simulate `exitOrError: true`; the fact that it didn't was hiding this problem in test (e.g., `drive-examples` had a test that asserted that all failures were summarized correctly, which passed because in tests it was behaving as if `exitOnError` were false)
- Adjusts the mock process runner to allow setting a list of mock result for a specific executable instead of one result for all calls to anything, in order to fix some tests that were broken by the two changes above and unfixable without this (e.g., a test of a command that had been calling one executable with `exitOnError: true` then another with ``exitOnError: false`, where the test was asserting things about the second call failing, which only worked because the first call's failure wasn't actually checked). To limit the scope of the PR, the old method of setting a single result for all calls is still supported for now as a fallback.
- Fixes the fact that the mock `run` and `runAndStream` had opposite default exit code behavior when no mock process was set (since that caused me a lot of confusion while fixing the above until I figured it out).
2021-07-02 07:50:24 -07:00
4b77aaff42 [flutter_plugin_tools] Minor test cleanup (#4120)
- Updates the remaining tests (other than one that still needs to be
  converted to the new base command, which will be fixed then) that
  aren't using runCapturingPrint to do so to reduce test log spam.
- Simplifies and standardizes the matcher used for ToolExit in tests.
2021-07-01 18:05:54 -07:00
edeb10a752 [flutter_plugin_tools] Add a summary for successful runs (#4118)
Add a summary to the end of successful runs for everything using the new looping base command, similar to what we do for summarizing failures. This will make it easy to manually check results for PRs that we know should be changing the set of run packages (adding a new package, adding a new test type to a package, adding a new test type to the tool), as well as spot-checking when we see unexpected results (e.g., looking back and why a PR didn't fail CI when we discover that it should have).

To support better surfacing skips, this restructures the return value of `runForPackage` to have "skip" as one of the options. As a result of it being a return value, packages that used `printSkip` to indicate that *parts* of the command were being skipped have been changed to no longer do that.

Fixes https://github.com/flutter/flutter/issues/85626
2021-07-01 16:25:21 -07:00
92d6214984 [flutter_plugin_tools] Overhaul drive-examples (#4099)
Significantly restructures drive-examples:
- Migrates it to the new package-looping base command
- Enforces that only one platform is passed, since in practice multiple platforms never actually worked. (The logic is structured so that it will be easy to enable multi-platform if `flutter drive` gains multi-platform support.)
- Fixes the issue where `--ios` and `--android` were semi-broken, by doing explicit device targeting for them rather than relying on the default device being the right kind
- Extracts much of the logic to helpers so it's easier to understand the flow
- Removes support for a legacy integration test file structure that is no longer used
- Adds more test coverage; previously no failure cases were actually tested.

Fixes https://github.com/flutter/flutter/issues/85147
Part of https://github.com/flutter/flutter/issues/83413
2021-06-30 12:16:46 -07:00
ec9233eb41 [flutter_plugin_tools] Migrate firebase-test-lab to new base command (#4116)
Migrates firebase-test-lab to use the new package-looping base command.

Other changes:
- Extracts several helpers to make the main flow easier to follow
- Removes support for finding and running `*_e2e.dart` files, since we no longer use that file structure for integration tests.

Part of https://github.com/flutter/flutter/issues/83413
2021-06-30 11:43:41 -07:00
ea72f74d0b [flutter_plugin_tools] Migrate build-examples to new base command (#4087)
Switches build-examples to the new base command that handles the boilerplate of looping over target packages.

While modifying the command, also does some minor cleanup:
- Extracts a helper to reduce duplicated details of calling `flutter build`
- Switches the flag for iOS to `--ios` rather than `--ipa` since `ios` is what is actually passed to the build command
- iOS no longer defaults to on, so that it behaves like all the other platform flags
- Passing no platform flags is now an error rather than a silent pass, to ensure that we never accidentally have CI doing a no-op run without noticing.
- Rewords the logging slightly for the versions where the label for what is being built is a platform, not an artifact (which is now everything but Android).

Part of flutter/flutter#83413
2021-06-30 11:33:09 -07:00
6ccb344119 [flutter_plugin_tools] Move license-check tests to runCapturingPrint (#4107) 2021-06-30 11:21:05 -07:00
23c3f5794a [flutter_plugin_tools] Restructure version-check (#4111)
Combines the two different aspects of version-checking into a single looping structure based on plugins, using the new base command, rather than one operating on plugins as controlled by the usual flags and the other operating on a git list of changed files.

Also simplifies the determination of the new version by simply checking the file, rather than querying git for the HEAD state of the file. Tests setup is simplified since we no longer need to set up nearly as much fake `git` output.

Minor changes to base commands:
- Move indentation up to PackageLoopingCommand so that it is consistent across commands
- Add a new post-loop command for any cleanup, which is needed by version-check
- Change the way the GitDir instance is managed by the base PluginCommand, so that it's always cached even when not overridden, to reduce duplicate work and code.

Part of https://github.com/flutter/flutter/issues/83413
2021-06-28 13:25:06 -07:00
40162caa65 [flutter_plugin_tools] Migrate java-test to new base command (#4105)
Switches `java-test` to the new base command that handles the boilerplate of looping over target packages.

Includes test improvements:
- Adds failure tests; previously no failure cases were covered.
- Captures output so test output isn't spammed with command output.

Part of flutter/flutter#83413
2021-06-28 11:26:34 -07:00
355ffc0a88 [flutter_plugin_tools] ignore flutter_plugin_tools when publishing (#4110) 2021-06-28 09:06:03 -07:00
fef8e6c2fb [flutter_plugin_tools] release 0.3.0 (#4109) 2021-06-27 18:30:27 -07:00
9ce20139d5 Migrate command, add failure test, remove skip (#4106)
Switches `podspec` to the new base command that handles the boilerplate of looping over target packages.

Includes test improvements:
- Adds failure tests; previously no failure cases were covered.
- Captures output using the standard mechanism instead of using a custom
  `_print`, simplifying the command code.

Also removes `--skip`, which is redundant with `--exclude`.

Part of flutter/flutter#83413
2021-06-25 17:40:52 -04:00
d9857db0cf [flutter_plugin_tools] Migrate analyze to new base command (#4084)
Switches `analyze` to the new base command that handles the boilerplate
of looping over target packages. This will change the output format
slightly, but shoudn't have any functional change.

Updates tests to use runCapturingPrint so that test run output isn't
mixed with command output.

Part of https://github.com/flutter/flutter/issues/83413
2021-06-25 08:59:03 -07:00
552fceef91 [flutter_plugin_tools] publish-plugin check against pub to determine if a release should happen (#4068)
This PR removes a TODO where we used to check if a release should happen against git tags, instead, we check against pub.

Also, when auto-publish and the package is manually released, the CI will continue to fail without this change.

Fixes flutter/flutter#81047
2021-06-24 12:46:24 -07:00
356d316717 [flutter_plugin_tools] Add a new base command for looping over packages (#4067)
Most of our commands are generally of the form:
```
  for (each plugin as defined by the tool flags)
    check some things for success or failure
  print a summary all of the failing things
  exit non-zero if anything failed
```

Currently all that logic not consistent, having been at various points copied and pasted around, modified, in some cases rewritten. There's unnecessary boilerplate in each new command, and there's unnecessary variation that makes it harder both to maintain the tool, and to consume the test output:
- There's no standard format for separating each plugin's run to search within a log
- There's no standard format for the summary at the end
- In some cases commands have been written to ToolExit on failure, which means we don't actually get the rest of the runs

This makes a new base class for commands that follow this structure to use, with shared code for all the common bits. This makes it harder to accidentally write new commands incorrectly, easier to maintain the code, and lets us standardize output so that searching within large logs will be easier.

This ports two commands over as a proof of concept to demonstrate that it works; more will be converted in follow-ups.

Related to https://github.com/flutter/flutter/issues/83413
2021-06-22 13:32:03 -07:00
f0967e5186 Update tool commands (#4065)
Update CI and README to call the tool via bin/flutter_plugin_tools.dart
rather than lib/src/main.dart to avoid a warning line on every run.
2021-06-17 21:23:51 -04:00
37f79be469 [flutter_plugin_tools] Simplify extraFiles in test utils (#4066)
Rather than taking a list of list of path elements, just accept a list
of Posix-style paths. In practice, the API was already being partially
used that way.
2021-06-17 21:23:18 -04:00
81a6f66eee [flutter_plugin_tool] Refactor createFakePlugin (#4064) 2021-06-17 13:29:03 -07:00
10486b0ceb [flutter_plugin_tools] Split common.dart (#4057)
common.dart is a large-and-growing file containing all shared code,
which makes it hard to navigate. To make maintenance easier, this splits
the file (and its test file) into separate files for each major
component or category.
2021-06-16 12:37:30 -07:00
ce948ce3cb [flutter_plugin_tools] Complete migration to NNBD (#4048) 2021-06-12 12:44:04 -07:00
038c1796b0 [flutter_plugin_tools] Migrate publish and version checks to NNBD (#4037)
Migrates publish-check and version-check commands to NNBD.

Reworks the version-check flow so that it's more consistent with the other commands: instead of immediately exiting on failure, it checks all plugins, gathers failures, and summarizes all failures at the end. This ensures that we don't have failures in one package temporarily masked by failures in another, so PRs don't need to go through as many check cycles.

Part of https://github.com/flutter/flutter/issues/81912
2021-06-11 19:10:41 -04:00
cb92e5d416 Enable macOS XCTest support (#4043)
- Adds macOS support to the `xctest` tool command
- Adds logic to the tool to check for packages that delegate their implementations
  to another package, so they can be skipped when running native unit tests
  - Updates the tool's unit test utility for writing pubspecs to be able to make
    delegated federated implementation references to test it
- Adds initial unit tests to the non-deprecated macOS plugins
- Enables macOS XCTesting in CI

macOS portion of https://github.com/flutter/flutter/issues/82445
2021-06-10 17:50:20 -04:00
b98034dd76 [flutter_plugin_tools] Migrate more commands to NNBD (#4026)
Migrates:
- `all_plugins_app`
- `podspecs`
- `firebase-test-lab`

Minor functional changes to `firebase-test-lab` based on issues highlighted by the migration:
- The build ID used in the path is now a) passable, and b) given a fallback value in the path that
  isn't "null"
- Flag setup will no longer assume that `$HOME` must be set in the environment.
- Adds a --build-id flag to `firebase-test-lab` instead of hard-coding the use of  `CIRRUS_BUILD_ID`.
  The default is still `CIRRUS_BUILD_ID` so no CI changes are needed.

Part of https://github.com/flutter/flutter/issues/81912
2021-06-09 11:00:04 -07:00
181fe18e27 [flutter_plugin_tools] Migrate xctest command to NNBD (#4024) 2021-06-07 11:44:05 -07:00
d491b95e69 [flutter_plugin_tools] Remove xctest's --skip (#4022) 2021-06-07 11:29:07 -07:00
74d03857f8 [flutter_plugin_tools] Remove global state from tests (#4018)
Eliminates the global test filesystem and global test packages directory, in favor of local versions. This guarantees that each test runs with a clean filesystem state, rather than relying on cleanup. It also simplifies understanding the tests, since everything is done via params and return values instead of needing to know about the magic global variables and which methods mutate them.
2021-06-07 10:04:43 -07:00
bb0a1ea161 [flutter_plugin_tools] Simplify filesystem usage (#4014)
- Replaces most explicit use of `fileSystem` with path construction using the `child*` utility methods
- Removes explicit passing of a filesystem to the commands; we're already passing a `Directory` for the
  root where the tool operates, and we should never be using a different filesystem than that directory's
  filesystem, so passing it was both redundant, and a potential source of test bugs.
2021-06-05 13:32:24 -04:00
533596f798 Enable linting of macOS podspecs (#4015)
- Removes the .cirrus.yml workaround that removed macOS podspecs before linting
- Deletes the dummy macOS podspecs that are no longer needed due to `flutter` fixes
- Adds --use-modular-headers to the lint command to reflect what Flutter Podfiles do
- Fix the actual issues in the podspecs
2021-06-04 19:48:31 -04:00
612be3575b Remove "unnecessary" imports. (#4012) 2021-06-04 10:24:05 -07:00
9c15a2b4ce Some small documentation fixes (#3999)
* Two small documentation fixes

* Fix url to plugin_tool format
2021-06-02 17:40:17 +02:00
407572bc04 [script/tool] Use 'dart pub' instead of deprecated 'pub' (#3991) 2021-06-01 12:17:21 -04:00
d21b1d9706 Add pubspec convention checks (#3984) 2021-05-27 20:54:06 -07:00
93047fff2f [script/tool] speed up the pub get portion of the analyze command (#3982) 2021-05-27 11:54:03 -07:00
6a8e6da028 use 'flutter pub get' for both dart and flutter packages (#3973) 2021-05-27 07:38:26 -07:00
b07809952c Allow reverts when checking versions (#3981)
If a new version is lower than the current checked-in version, and the
transition from the new version to the old version is valid (indicating
that it could have been the previous version), allow the change.

This prevents the version check from failing when reverting a PR.
This is not fool-proof (e.g., it would allow a revert of an
already-published PR); if we have issues in practice we can further
restrict the check (by checking that the new version is the current pub
version, for instance).
2021-05-27 07:10:14 -07:00
544cab7f39 add a --dart-sdk option to the repo analysis command (#3959) 2021-05-24 08:44:06 -07:00
04181cf38c Fix publish-check output (#3953) 2021-05-24 08:39:05 -07:00
c6a5122ace Remove codesign overrides from xctest command (#3952)
Workaround for https://github.com/flutter/flutter/issues/83048
2021-05-20 14:13:47 -07:00
7cf08e5683 Make run-on-changed-packages flag handle repo-level changes (#3946)
Changes to some files (e.g., CI scripts) have the potential to cause
failures in any packages, without changes to those packages themselves.
This updates the --run-on-changed-packages to consider all packages as
changed if any of those files are changed, to avoid issues where a
change that changes both some repo-level files and some package-specific
files only run presubmit tests on the packages that are directly
changed, causing post-submit-only failures.

Fixes https://github.com/flutter/flutter/issues/82965
2021-05-20 11:27:30 -07:00
89fc7cebb3 Bump min Android SDK to the version required at runtime (#3894) 2021-05-17 12:13:59 -07:00
842ae94fde Migrate some tool commands to NNBD (#3899)
Now that individual commands can be migrated, migrate several commands
that are trivially migratable.

Part of https://github.com/flutter/flutter/issues/81912
2021-05-17 11:25:01 -07:00
bd0081258a Begin migrating tools to NNBD (#3891)
- Updates dependencies to null-safe versions
- Migrates common.dart (which doesn't depend on anything)
- Migrates common_tests.dart and its one dependency, utils.dart
- Adds build_runner for Mockito mock generation
- Adds a new utility methods for getting arguments that handle both the casting and the removal of nullability to address a common problematic pattern while migrating code.
  - Converts all files, not just the migrated ones, to those new helpers.

Migrating common.dart and utils.dart should unblock a command-by-command migration to null safety.

Reverts the separate of podspect lints into a step that doesn't do a Flutter upgrade
(https://github.com/flutter/plugins/pull/3700) because without that step we had a
version of Dart too old to run null-safe tooling.

First step of https://github.com/flutter/flutter/issues/81912
2021-05-14 20:04:26 -04:00
e46aa5583f Update tool README for packages use (#3882)
Updates to better reflect that this tooling is still used in flutter/packages, and how that differs from the flutter/plugins usage.
2021-05-14 20:03:23 -04:00
f7f736a966 Revert "Temporarily run Windows tests via GitHub Actions (#3875)" (#3885) 2021-05-13 10:14:04 -07:00
3e28166394 [tool] add an skip-confirmation flag to publish-package for running the command on ci (#3842)
the skip-confirmation flag will add a --force flag to pub publish, it will also let users to skip the y/n question when pushing tags to remote.

Fixes flutter/flutter#79830
2021-05-11 14:39:58 -07:00
ec7bf3b464 Temporarily run Windows tests via GitHub Actions (#3875)
Until the infrastructure limitations that led to flutter/flutter#82032 are fixed, run basic Windows tests via GitHub Actions (which do have VS available) so that we aren't missing all Windows coverage.
2021-05-11 13:08:01 -07:00