@@ -8,6 +8,8 @@ import 'dart:io';
8
8
9
9
import 'package:path/path.dart' as path;
10
10
11
+ typedef Future <Null > ShardRunner ();
12
+
11
13
final String flutterRoot = path.dirname (path.dirname (path.dirname (path.fromUri (Platform .script))));
12
14
final String flutter = path.join (flutterRoot, 'bin' , Platform .isWindows ? 'flutter.bat' : 'flutter' );
13
15
final String dart = path.join (flutterRoot, 'bin' , 'cache' , 'dart-sdk' , 'bin' , Platform .isWindows ? 'dart.exe' : 'dart' );
@@ -22,6 +24,13 @@ final String yellow = hasColor ? '\x1B[33m' : '';
22
24
final String cyan = hasColor ? '\x 1B[36m' : '' ;
23
25
final String reset = hasColor ? '\x 1B[0m' : '' ;
24
26
27
+ const Map <String , ShardRunner > _kShards = const < String , ShardRunner > {
28
+ 'docs' : _generateDocs,
29
+ 'analyze' : _analyzeRepo,
30
+ 'tests' : _runTests,
31
+ 'coverage' : _runCoverage,
32
+ };
33
+
25
34
/// When you call this, you can set FLUTTER_TEST_ARGS to pass custom
26
35
/// arguments to flutter test. For example, you might want to call this
27
36
/// script using FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt to
@@ -33,94 +42,111 @@ final String reset = hasColor ? '\x1B[0m' : '';
33
42
/// SHARD=analyze bin/cache/dart-sdk/bin/dart dev/bots/test.dart
34
43
/// FLUTTER_TEST_ARGS=--local-engine=host_debug_unopt bin/cache/dart-sdk/bin/dart dev/bots/test.dart
35
44
Future <Null > main () async {
36
- if (Platform .environment['SHARD' ] == 'docs' ) {
37
- print ('${bold }DONE: test.dart does nothing in the docs shard.$reset ' );
38
- } else if (Platform .environment['SHARD' ] == 'analyze' ) {
39
- // Analyze all the Dart code in the repo.
40
- await _runFlutterAnalyze (flutterRoot,
41
- options: < String > ['--flutter-repo' ],
42
- );
45
+ final String shard = Platform .environment['SHARD' ] ?? 'tests' ;
46
+ if (! _kShards.containsKey (shard))
47
+ throw new ArgumentError ('Invalid shard: $shard ' );
48
+ await _kShards[shard]();
49
+ }
43
50
44
- // Analyze all the sample code in the repo
45
- await _runCommand (dart, < String > [path.join (flutterRoot, 'dev' , 'bots' , 'analyze-sample-code.dart' )],
46
- workingDirectory: flutterRoot,
47
- );
51
+ Future <Null > _generateDocs () async {
52
+ print ('${bold }DONE: test.dart does nothing in the docs shard.$reset ' );
53
+ }
48
54
49
- // Try with the --watch analyzer, to make sure it returns success also.
50
- // The --benchmark argument exits after one run .
51
- await _runFlutterAnalyze (flutterRoot,
52
- options: < String > ['--flutter-repo' , '--watch' , '--benchmark ' ],
53
- );
55
+ Future < Null > _analyzeRepo () async {
56
+ // Analyze all the Dart code in the repo .
57
+ await _runFlutterAnalyze (flutterRoot,
58
+ options: < String > ['--flutter-repo' ],
59
+ );
54
60
55
- // Try an analysis against a big version of the gallery.
56
- await _runCommand (dart, < String > [path.join (flutterRoot, 'dev' , 'tools' , 'mega_gallery.dart' )],
57
- workingDirectory: flutterRoot,
58
- );
59
- await _runFlutterAnalyze (path.join (flutterRoot, 'dev' , 'benchmarks' , 'mega_gallery' ),
60
- options: < String > ['--watch' , '--benchmark' ],
61
- );
61
+ // Analyze all the sample code in the repo
62
+ await _runCommand (dart, < String > [path.join (flutterRoot, 'dev' , 'bots' , 'analyze-sample-code.dart' )],
63
+ workingDirectory: flutterRoot,
64
+ );
62
65
63
- print ('${bold }DONE: Analysis successful.$reset ' );
64
- } else {
65
- // Verify that the tests actually return failure on failure and success on success.
66
- final String automatedTests = path.join (flutterRoot, 'dev' , 'automated_tests' );
67
- await _runFlutterTest (automatedTests,
68
- script: path.join ('test_smoke_test' , 'fail_test.dart' ),
69
- expectFailure: true ,
70
- printOutput: false ,
71
- );
72
- await _runFlutterTest (automatedTests,
73
- script: path.join ('test_smoke_test' , 'pass_test.dart' ),
74
- printOutput: false ,
75
- );
76
- await _runFlutterTest (automatedTests,
77
- script: path.join ('test_smoke_test' , 'crash1_test.dart' ),
78
- expectFailure: true ,
79
- printOutput: false ,
80
- );
81
- await _runFlutterTest (automatedTests,
82
- script: path.join ('test_smoke_test' , 'crash2_test.dart' ),
83
- expectFailure: true ,
84
- printOutput: false ,
85
- );
86
- await _runFlutterTest (automatedTests,
87
- script: path.join ('test_smoke_test' , 'syntax_error_test.broken_dart' ),
88
- expectFailure: true ,
89
- printOutput: false ,
90
- );
91
- await _runFlutterTest (automatedTests,
92
- script: path.join ('test_smoke_test' , 'missing_import_test.broken_dart' ),
93
- expectFailure: true ,
94
- printOutput: false ,
95
- );
96
- await _runCommand (flutter, < String > ['drive' , '--use-existing-app' , '-t' , path.join ('test_driver' , 'failure.dart' )],
97
- workingDirectory: path.join (flutterRoot, 'packages' , 'flutter_driver' ),
98
- expectFailure: true ,
99
- printOutput: false ,
100
- );
66
+ // Try with the --watch analyzer, to make sure it returns success also.
67
+ // The --benchmark argument exits after one run.
68
+ await _runFlutterAnalyze (flutterRoot,
69
+ options: < String > ['--flutter-repo' , '--watch' , '--benchmark' ],
70
+ );
101
71
102
- final List <String > coverageFlags = < String > [];
103
- if (Platform .environment['TRAVIS' ] != null && Platform .environment['TRAVIS_PULL_REQUEST' ] == 'false' )
104
- coverageFlags.add ('--coverage' );
72
+ // Try an analysis against a big version of the gallery.
73
+ await _runCommand (dart, < String > [path.join (flutterRoot, 'dev' , 'tools' , 'mega_gallery.dart' )],
74
+ workingDirectory: flutterRoot,
75
+ );
76
+ await _runFlutterAnalyze (path.join (flutterRoot, 'dev' , 'benchmarks' , 'mega_gallery' ),
77
+ options: < String > ['--watch' , '--benchmark' ],
78
+ );
105
79
106
- // Run tests.
107
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter' ),
108
- options: coverageFlags,
109
- );
110
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_driver' ));
111
- await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_test' ));
112
- await _pubRunTest (path.join (flutterRoot, 'packages' , 'flutter_tools' ));
113
-
114
- await _runAllDartTests (path.join (flutterRoot, 'dev' , 'devicelab' ));
115
- await _runFlutterTest (path.join (flutterRoot, 'dev' , 'manual_tests' ));
116
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'hello_world' ));
117
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'layers' ));
118
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'stocks' ));
119
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'flutter_gallery' ));
120
- await _runFlutterTest (path.join (flutterRoot, 'examples' , 'catalog' ));
121
-
122
- print ('${bold }DONE: All tests successful.$reset ' );
80
+ print ('${bold }DONE: Analysis successful.$reset ' );
81
+ }
82
+
83
+ Future <Null > _runTests () async {
84
+ // Verify that the tests actually return failure on failure and success on success.
85
+ final String automatedTests = path.join (flutterRoot, 'dev' , 'automated_tests' );
86
+ await _runFlutterTest (automatedTests,
87
+ script: path.join ('test_smoke_test' , 'fail_test.dart' ),
88
+ expectFailure: true ,
89
+ printOutput: false ,
90
+ );
91
+ await _runFlutterTest (automatedTests,
92
+ script: path.join ('test_smoke_test' , 'pass_test.dart' ),
93
+ printOutput: false ,
94
+ );
95
+ await _runFlutterTest (automatedTests,
96
+ script: path.join ('test_smoke_test' , 'crash1_test.dart' ),
97
+ expectFailure: true ,
98
+ printOutput: false ,
99
+ );
100
+ await _runFlutterTest (automatedTests,
101
+ script: path.join ('test_smoke_test' , 'crash2_test.dart' ),
102
+ expectFailure: true ,
103
+ printOutput: false ,
104
+ );
105
+ await _runFlutterTest (automatedTests,
106
+ script: path.join ('test_smoke_test' , 'syntax_error_test.broken_dart' ),
107
+ expectFailure: true ,
108
+ printOutput: false ,
109
+ );
110
+ await _runFlutterTest (automatedTests,
111
+ script: path.join ('test_smoke_test' , 'missing_import_test.broken_dart' ),
112
+ expectFailure: true ,
113
+ printOutput: false ,
114
+ );
115
+ await _runCommand (flutter, < String > ['drive' , '--use-existing-app' , '-t' , path.join ('test_driver' , 'failure.dart' )],
116
+ workingDirectory: path.join (flutterRoot, 'packages' , 'flutter_driver' ),
117
+ expectFailure: true ,
118
+ printOutput: false ,
119
+ );
120
+
121
+ // Run tests.
122
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter' ));
123
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_driver' ));
124
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter_test' ));
125
+ await _pubRunTest (path.join (flutterRoot, 'packages' , 'flutter_tools' ));
126
+
127
+ await _runAllDartTests (path.join (flutterRoot, 'dev' , 'devicelab' ));
128
+ await _runFlutterTest (path.join (flutterRoot, 'dev' , 'manual_tests' ));
129
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'hello_world' ));
130
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'layers' ));
131
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'stocks' ));
132
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'flutter_gallery' ));
133
+ await _runFlutterTest (path.join (flutterRoot, 'examples' , 'catalog' ));
134
+
135
+ print ('${bold }DONE: All tests successful.$reset ' );
136
+ }
137
+
138
+ Future <Null > _runCoverage () async {
139
+ if (Platform .environment['TRAVIS' ] == null ||
140
+ Platform .environment['TRAVIS_PULL_REQUEST' ] != 'false' ) {
141
+ print ('${bold }DONE: test.dart does not run coverage for Travis pull requests' );
142
+ return ;
123
143
}
144
+
145
+ await _runFlutterTest (path.join (flutterRoot, 'packages' , 'flutter' ),
146
+ options: const < String > ['--coverage' ],
147
+ );
148
+
149
+ print ('${bold }DONE: Coverage collection successful.$reset ' );
124
150
}
125
151
126
152
Future <Null > _pubRunTest (
0 commit comments