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

Commit 96ea724

Browse files
author
Emmanuel Garcia
authored
Move plugin tool tests over (#3606)
1 parent 088bdee commit 96ea724

15 files changed

+3367
-15
lines changed

.cirrus.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ task:
1616
- flutter channel master
1717
- flutter upgrade
1818
- git fetch origin master
19-
submodules_script:
20-
- git submodule init
21-
- git submodule update
2219
matrix:
20+
- name: plugin_tools_tests
21+
script:
22+
- cd script/tool
23+
- pub get
24+
- CIRRUS_BUILD_ID=null pub run test
2325
- name: publishable
2426
script:
2527
- flutter channel master
@@ -132,9 +134,6 @@ task:
132134
- flutter channel master
133135
- flutter upgrade
134136
- git fetch origin master
135-
submodules_script:
136-
- git submodule init
137-
- git submodule update
138137
matrix:
139138
- name: build-linux+drive-examples
140139
install_script:
@@ -161,9 +160,6 @@ task:
161160
- flutter channel master
162161
- flutter upgrade
163162
- git fetch origin master
164-
submodules_script:
165-
- git submodule init
166-
- git submodule update
167163
create_simulator_script:
168164
- xcrun simctl list
169165
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot
@@ -222,9 +218,6 @@ task:
222218
- flutter channel master
223219
- flutter upgrade
224220
- git fetch origin master
225-
submodules_script:
226-
- git submodule init
227-
- git submodule update
228221
create_simulator_script:
229222
- xcrun simctl list
230223
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot
@@ -254,9 +247,6 @@ task:
254247
- flutter channel master
255248
- flutter upgrade
256249
- git fetch origin master
257-
submodules_script:
258-
- git submodule init
259-
- git submodule update
260250
matrix:
261251
- name: build_all_plugins_app
262252
script:

script/tool/pubspec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@ dependencies:
2121
http_multi_server: ^2.2.0
2222
collection: 1.14.13
2323

24+
dev_dependencies:
25+
matcher: ^0.12.6
26+
mockito: ^4.1.1
27+
pedantic: 1.8.0
28+
2429
environment:
2530
sdk: ">=2.3.0 <3.0.0"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import 'package:args/command_runner.dart';
2+
import 'package:file/file.dart';
3+
import 'package:flutter_plugin_tools/src/analyze_command.dart';
4+
import 'package:flutter_plugin_tools/src/common.dart';
5+
import 'package:test/test.dart';
6+
7+
import 'mocks.dart';
8+
import 'util.dart';
9+
10+
void main() {
11+
RecordingProcessRunner processRunner;
12+
CommandRunner runner;
13+
14+
setUp(() {
15+
initializeFakePackages();
16+
processRunner = RecordingProcessRunner();
17+
final AnalyzeCommand analyzeCommand = AnalyzeCommand(
18+
mockPackagesDir, mockFileSystem,
19+
processRunner: processRunner);
20+
21+
runner = CommandRunner<Null>('analyze_command', 'Test for analyze_command');
22+
runner.addCommand(analyzeCommand);
23+
});
24+
25+
tearDown(() {
26+
mockPackagesDir.deleteSync(recursive: true);
27+
});
28+
29+
test('analyzes all packages', () async {
30+
final Directory plugin1Dir = await createFakePlugin('a');
31+
final Directory plugin2Dir = await createFakePlugin('b');
32+
33+
final MockProcess mockProcess = MockProcess();
34+
mockProcess.exitCodeCompleter.complete(0);
35+
processRunner.processToReturn = mockProcess;
36+
await runner.run(<String>['analyze']);
37+
38+
expect(
39+
processRunner.recordedCalls,
40+
orderedEquals(<ProcessCall>[
41+
ProcessCall('pub', <String>['global', 'activate', 'tuneup'],
42+
mockPackagesDir.path),
43+
ProcessCall('flutter', <String>['packages', 'get'], plugin1Dir.path),
44+
ProcessCall('flutter', <String>['packages', 'get'], plugin2Dir.path),
45+
ProcessCall('pub', <String>['global', 'run', 'tuneup', 'check'],
46+
plugin1Dir.path),
47+
ProcessCall('pub', <String>['global', 'run', 'tuneup', 'check'],
48+
plugin2Dir.path),
49+
]));
50+
});
51+
52+
group('verifies analysis settings', () {
53+
test('fails analysis_options.yaml', () async {
54+
await createFakePlugin('foo', withExtraFiles: <List<String>>[
55+
<String>['analysis_options.yaml']
56+
]);
57+
58+
await expectLater(() => runner.run(<String>['analyze']),
59+
throwsA(const TypeMatcher<ToolExit>()));
60+
});
61+
62+
test('fails .analysis_options', () async {
63+
await createFakePlugin('foo', withExtraFiles: <List<String>>[
64+
<String>['.analysis_options']
65+
]);
66+
67+
await expectLater(() => runner.run(<String>['analyze']),
68+
throwsA(const TypeMatcher<ToolExit>()));
69+
});
70+
71+
test('takes an allow list', () async {
72+
final Directory pluginDir =
73+
await createFakePlugin('foo', withExtraFiles: <List<String>>[
74+
<String>['analysis_options.yaml']
75+
]);
76+
77+
final MockProcess mockProcess = MockProcess();
78+
mockProcess.exitCodeCompleter.complete(0);
79+
processRunner.processToReturn = mockProcess;
80+
await runner.run(<String>['analyze', '--custom-analysis', 'foo']);
81+
82+
expect(
83+
processRunner.recordedCalls,
84+
orderedEquals(<ProcessCall>[
85+
ProcessCall('pub', <String>['global', 'activate', 'tuneup'],
86+
mockPackagesDir.path),
87+
ProcessCall('flutter', <String>['packages', 'get'], pluginDir.path),
88+
ProcessCall('pub', <String>['global', 'run', 'tuneup', 'check'],
89+
pluginDir.path),
90+
]));
91+
});
92+
});
93+
}

0 commit comments

Comments
 (0)