[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.
This commit is contained in:
stuartmorgan
2021-07-01 18:05:54 -07:00
committed by GitHub
parent edeb10a752
commit 4b77aaff42
8 changed files with 56 additions and 53 deletions

View File

@ -125,7 +125,7 @@ void main() {
extraFiles: <String>['analysis_options.yaml']);
await expectLater(() => runCapturingPrint(runner, <String>['analyze']),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
});
test('fails .analysis_options', () async {
@ -133,7 +133,7 @@ void main() {
extraFiles: <String>['.analysis_options']);
await expectLater(() => runCapturingPrint(runner, <String>['analyze']),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
});
test('takes an allow list', () async {
@ -168,7 +168,7 @@ void main() {
await expectLater(
() => runCapturingPrint(
runner, <String>['analyze', '--custom-analysis', '']),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
});
});
}

View File

@ -65,7 +65,7 @@ void main() {
test('all plugins from file system', () async {
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>['sample']);
await runCapturingPrint(runner, <String>['sample']);
expect(plugins, unorderedEquals(<String>[plugin1.path, plugin2.path]));
});
@ -74,7 +74,7 @@ void main() {
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
final Directory plugin3 =
createFakePlugin('plugin3', thirdPartyPackagesDir);
await runner.run(<String>['sample']);
await runCapturingPrint(runner, <String>['sample']);
expect(plugins,
unorderedEquals(<String>[plugin1.path, plugin2.path, plugin3.path]));
});
@ -82,7 +82,7 @@ void main() {
test('exclude plugins when plugins flag is specified', () async {
createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(
await runCapturingPrint(runner,
<String>['sample', '--plugins=plugin1,plugin2', '--exclude=plugin1']);
expect(plugins, unorderedEquals(<String>[plugin2.path]));
});
@ -90,14 +90,15 @@ void main() {
test('exclude plugins when plugins flag isn\'t specified', () async {
createFakePlugin('plugin1', packagesDir);
createFakePlugin('plugin2', packagesDir);
await runner.run(<String>['sample', '--exclude=plugin1,plugin2']);
await runCapturingPrint(
runner, <String>['sample', '--exclude=plugin1,plugin2']);
expect(plugins, unorderedEquals(<String>[]));
});
test('exclude federated plugins when plugins flag is specified', () async {
createFakePlugin('plugin1', packagesDir.childDirectory('federated'));
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--plugins=federated/plugin1,plugin2',
'--exclude=federated/plugin1'
@ -109,7 +110,7 @@ void main() {
() async {
createFakePlugin('plugin1', packagesDir.childDirectory('federated'));
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--plugins=federated/plugin1,plugin2',
'--exclude=federated'
@ -121,7 +122,7 @@ void main() {
test('all plugins should be tested if there are no changes.', () async {
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -136,7 +137,7 @@ void main() {
gitDiffResponse = 'AUTHORS';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -152,7 +153,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -168,7 +169,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -185,7 +186,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -202,7 +203,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -219,7 +220,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -236,7 +237,7 @@ packages/plugin1/CHANGELOG
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -249,7 +250,7 @@ packages/plugin1/CHANGELOG
gitDiffResponse = 'packages/plugin1/plugin1.dart';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -266,7 +267,7 @@ packages/plugin1/ios/plugin1.m
''';
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
createFakePlugin('plugin2', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -284,7 +285,7 @@ packages/plugin2/ios/plugin2.m
final Directory plugin1 = createFakePlugin('plugin1', packagesDir);
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
createFakePlugin('plugin3', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -305,7 +306,7 @@ packages/plugin1/plugin1_web/plugin1_web.dart
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
createFakePlugin('plugin2', packagesDir);
createFakePlugin('plugin3', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--base-sha=master',
'--run-on-changed-packages'
@ -325,7 +326,7 @@ packages/plugin3/plugin3.dart
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
final Directory plugin2 = createFakePlugin('plugin2', packagesDir);
createFakePlugin('plugin3', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--plugins=plugin1,plugin2',
'--base-sha=master',
@ -345,7 +346,7 @@ packages/plugin3/plugin3.dart
createFakePlugin('plugin1', packagesDir.childDirectory('plugin1'));
createFakePlugin('plugin2', packagesDir);
createFakePlugin('plugin3', packagesDir);
await runner.run(<String>[
await runCapturingPrint(runner, <String>[
'sample',
'--exclude=plugin2,plugin3',
'--base-sha=master',

View File

@ -45,7 +45,7 @@ void main() {
createFakePlugin('pluginb', packagesDir);
createFakePlugin('pluginc', packagesDir);
await runner.run(<String>['all-plugins-app']);
await runCapturingPrint(runner, <String>['all-plugins-app']);
final List<String> pubspec =
appDir.childFile('pubspec.yaml').readAsLinesSync();
@ -63,7 +63,7 @@ void main() {
createFakePlugin('pluginb', packagesDir);
createFakePlugin('pluginc', packagesDir);
await runner.run(<String>['all-plugins-app']);
await runCapturingPrint(runner, <String>['all-plugins-app']);
final List<String> pubspec =
appDir.childFile('pubspec.yaml').readAsLinesSync();
@ -80,7 +80,7 @@ void main() {
test('pubspec is compatible with null-safe app code', () async {
createFakePlugin('plugina', packagesDir);
await runner.run(<String>['all-plugins-app']);
await runCapturingPrint(runner, <String>['all-plugins-app']);
final String pubspec =
appDir.childFile('pubspec.yaml').readAsStringSync();

View File

@ -77,7 +77,7 @@ void main() {
group('Initial validation', () {
test('requires a package flag', () async {
await expectLater(() => commandRunner.run(<String>['publish-plugin']),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(
printedMessages.last, contains('Must specify a package to publish.'));
});
@ -90,7 +90,7 @@ void main() {
'iamerror',
'--no-push-tags'
]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(printedMessages.last, contains('iamerror does not exist'));
});
@ -105,7 +105,7 @@ void main() {
testPluginName,
'--no-push-tags'
]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(
printedMessages,
@ -119,7 +119,7 @@ void main() {
await expectLater(
() => commandRunner
.run(<String>['publish-plugin', '--package', testPluginName]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(processRunner.results.last.stderr, contains('No such remote'));
});
@ -248,7 +248,7 @@ void main() {
'--no-push-tags',
'--no-tag-release',
]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(printedMessages, contains('Publish foo failed.'));
});
@ -301,7 +301,7 @@ void main() {
testPluginName,
'--no-push-tags',
]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(printedMessages, contains('Publish foo failed.'));
final String? tag = (await gitDir.runCommand(
@ -327,7 +327,7 @@ void main() {
'--package',
testPluginName,
]),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(printedMessages, contains('Tag push canceled.'));
});
@ -958,7 +958,7 @@ void main() {
await expectLater(
() => commandRunner.run(
<String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']),
throwsA(const TypeMatcher<ToolExit>()));
throwsA(isA<ToolExit>()));
expect(processRunner.pushTagsArgs, isEmpty);
});

View File

@ -176,7 +176,7 @@ ${devDependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -196,7 +196,7 @@ ${devDependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -216,7 +216,7 @@ ${devDependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -236,7 +236,7 @@ ${devDependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -256,7 +256,7 @@ ${environmentSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -276,7 +276,7 @@ ${devDependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -296,7 +296,7 @@ ${dependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -316,7 +316,7 @@ ${dependenciesSection()}
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
});

View File

@ -36,7 +36,7 @@ void main() {
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
extraFiles: <String>['test/empty_test.dart']);
await runner.run(<String>['test']);
await runCapturingPrint(runner, <String>['test']);
expect(
processRunner.recordedCalls,
@ -54,7 +54,7 @@ void main() {
final Directory plugin2Dir = createFakePlugin('plugin2', packagesDir,
extraFiles: <String>['test/empty_test.dart']);
await runner.run(<String>['test']);
await runCapturingPrint(runner, <String>['test']);
expect(
processRunner.recordedCalls,
@ -71,7 +71,8 @@ void main() {
final Directory packageDir = createFakePackage('b', packagesDir,
extraFiles: <String>['test/empty_test.dart']);
await runner.run(<String>['test', '--enable-experiment=exp1']);
await runCapturingPrint(
runner, <String>['test', '--enable-experiment=exp1']);
expect(
processRunner.recordedCalls,
@ -99,7 +100,7 @@ void main() {
},
);
await runner.run(<String>['test']);
await runCapturingPrint(runner, <String>['test']);
expect(
processRunner.recordedCalls,
@ -118,7 +119,8 @@ void main() {
final Directory packageDir = createFakePackage('b', packagesDir,
extraFiles: <String>['test/empty_test.dart']);
await runner.run(<String>['test', '--enable-experiment=exp1']);
await runCapturingPrint(
runner, <String>['test', '--enable-experiment=exp1']);
expect(
processRunner.recordedCalls,

View File

@ -120,7 +120,7 @@ void main() {
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
expect(gitDirCommands.length, equals(1));
expect(
@ -188,7 +188,7 @@ void main() {
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -202,7 +202,7 @@ void main() {
await expectLater(
result,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
});
@ -244,7 +244,7 @@ void main() {
runner, <String>['version-check', '--base-sha=master']);
await expectLater(
output,
throwsA(const TypeMatcher<ToolExit>()),
throwsA(isA<ToolExit>()),
);
expect(gitDirCommands.length, equals(1));
expect(

View File

@ -106,7 +106,7 @@ void main() {
test('Fails if no platforms are provided', () async {
expect(
() => runner.run(<String>['xctest']),
() => runCapturingPrint(runner, <String>['xctest']),
throwsA(isA<ToolExit>()),
);
});
@ -227,7 +227,7 @@ void main() {
// will get this result and they should still be able to parse them correctly.
processRunner.resultStdout =
jsonEncode(schemeCommandResult..addAll(_kDeviceListMap));
await runner.run(<String>['xctest', '--ios']);
await runCapturingPrint(runner, <String>['xctest', '--ios']);
expect(
processRunner.recordedCalls,