21 Commits

Author SHA1 Message Date
a63c0eb59f [flutter_plugin_tools] Work around banner in drive-examples (#4142)
* [flutter_plugin_tools] Work around banner in drive-examples

Strip off any unexpected output before parsing `flutter devices
--machine` output. Works around a bug in the Flutter tool that can
result in banners being printed in `--machine` mode.

Fixes https://github.com/flutter/flutter/issues/86052
2021-07-07 20:02:35 -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
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
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
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
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
d21b1d9706 Add pubspec convention checks (#3984) 2021-05-27 20:54:06 -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
ce899a3151 Ensure that integration tests are actually being run (#3857)
Many of our integration tests weren't actually being run on CI because they were in the wrong place and/or missing the driver file, and it seems we've just never noticed. This makes a number of changes:
- Ensures that all packages with integration tests also have a driver file in the right location.
  - Also standardizes the format of those files, as the boilerplate `main()` is available in `integration_test`.
- Ensures that all integration_test directories are in the right place.
  - In a couple of places, removes a duplicate copy of the integration test file.
- Makes it an error for a plugin that's not excluded to not have integration tests, so this can't easily happen again.
- Adds logging of what's being run and skipped, so if something does go wrong in the future it's easy to determine what from the logs.
  - Excludes `*_platform_interface` since the logging was (potentially confusingly) reporting that they were skipped because they don't support the current platform. Skipping them is correct, just not for that reason.
- Excludes the plugins that currently have no integration tests, with references to issues about adding them.

Fixes https://github.com/flutter/flutter/issues/81929
2021-05-10 11:14:45 -07:00
3d9e523218 Switch script/tools over to the new analysis options (#3777)
Removes the legacy analysis options override and fixes all resulting issues. This is a combination of dart fix and manual changes (mostly mechanical, but some small restructuring to address warnings more cleanly, such as creating typed structs from args when they are used repeatedly to avoid repeated casting, or making things that were unnecessarily public private).

One small opportunistic extra cleanup is that the handling of null-safety prerelease versions is removed, as any new plugin would be written null-safe from the start, so we no longer need to allow those versions.

Part of flutter/flutter#76229
2021-04-06 13:04:25 -07:00
116a0e2900 [ci] Run more web tests (#3739)
This change enables the integration_tests of the following packages to run in Cirrus CI:

* google_sign_in_web
* connectivity_for_web
* google_maps_flutter_web
* url_launcher_web
2021-03-19 16:34:20 -07:00
514457de82 Enable web integration tests in CI (#3738) 2021-03-19 14:11:06 -07:00
aef6008b7b Standardize copyright year (#3737)
Standardizes all first-party copyrights on a single year, as is done in flutter/flutter and flutter/engine. All code now uses 2013, which is the earliest year that was in any existing copyright notice.

The script checks now enforce the exact format of first-party licenses and copyrights.

Fixes flutter/flutter#78448
2021-03-19 13:18:00 -07:00
c956cb3270 Standardize Copyrights: Chromium->Flutter (#2996)
In all copyright messages (and in the Xcode project organization name) standardize on "The Flutter Authors", adding "The Chromium Authors" to the Flutter AUTHORS list. This reduces inconsistency in the copyright lines in this repository, moving closer to a single consistent copyright+license (as in flutter/engine and flutter/flutter)

Updates the validation script to no longer accept "The Chromium Authors" or "the Chromium project authors" in first-party code.
2021-03-18 19:05:33 -04:00
6141051fa2 Add missing licenses, and add a check (#3720)
Adds a new CI check that all code files have a copyright+license block (and that it's one we are expecting to see).

Fixes the ~350 files (!) that did not have them. This includes all of the files in the .../example/ directories, following the example of flutter/flutter. (This does mean some manual intervention will be needed when generating new example directories in the future, but it's one-time per example.)

Also standardized some variants that used different line breaks than most of the rest of the repo (likely added since I standardized them all a while ago, but didn't add a check for at the time to enforce going forward), to simplify the checks.

Fixes flutter/flutter#77114
2021-03-16 17:50:51 -04:00
e1b3b296f2 Move plugin tool tests over (#3606) 2021-03-01 18:15:51 -08:00