mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 17:28:42 +08:00
[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.
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
@ -118,7 +120,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('fails when a test fails', () async {
|
||||
createFakePlugin(
|
||||
final Directory pluginDir = createFakePlugin(
|
||||
'plugin1',
|
||||
packagesDir,
|
||||
platformSupport: <String, PlatformSupport>{
|
||||
@ -130,10 +132,14 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
// Simulate failure from `gradlew`.
|
||||
final MockProcess mockDriveProcess = MockProcess();
|
||||
mockDriveProcess.exitCodeCompleter.complete(1);
|
||||
processRunner.processToReturn = mockDriveProcess;
|
||||
final String gradlewPath = pluginDir
|
||||
.childDirectory('example')
|
||||
.childDirectory('android')
|
||||
.childFile('gradlew')
|
||||
.path;
|
||||
processRunner.mockProcessesForExecutable[gradlewPath] = <io.Process>[
|
||||
MockProcess.failing()
|
||||
];
|
||||
|
||||
Error? commandError;
|
||||
final List<String> output = await runCapturingPrint(
|
||||
|
Reference in New Issue
Block a user