@@ -50,11 +50,6 @@ final String _dartdocDocsPath = createTempSync('dartdoc').path;
50
50
51
51
final Directory _flutterDir = createTempSync ('flutter' );
52
52
53
- Directory get testPackage => Directory (p.joinAll (['testing' , 'test_package' ]));
54
-
55
- Directory get testPackageExperiments =>
56
- Directory (p.joinAll (['testing' , 'test_package_experiments' ]));
57
-
58
53
Directory get testPackageFlutterPlugin => Directory (
59
54
p.joinAll (['testing' , 'flutter_packages' , 'test_package_flutter_plugin' ]));
60
55
@@ -84,35 +79,13 @@ final Directory flutterDirDevTools =
84
79
Directory (p.join (_flutterDir.path, 'dev' , 'tools' ));
85
80
86
81
@Task ('Analyze dartdoc to ensure there are no errors and warnings' )
87
- @Depends (analyzeTestPackages)
88
82
void analyze () async {
89
- await SubprocessLauncher ('analyze' ).runStreamed (
90
- Platform .resolvedExecutable,
91
- ['analyze' , '--fatal-infos' , '.' ],
92
- );
83
+ await task.analyzeTestPackages ();
84
+ await task.analyzePackage ();
93
85
}
94
86
95
87
@Task ('Analyze the test packages' )
96
- void analyzeTestPackages () async {
97
- var testPackagePaths = [testPackage.path];
98
- if (Platform .version.contains ('dev' )) {
99
- testPackagePaths.add (testPackageExperiments.path);
100
- }
101
- for (var testPackagePath in testPackagePaths) {
102
- await SubprocessLauncher ('pub-get' ).runStreamed (
103
- Platform .resolvedExecutable,
104
- ['pub' , 'get' ],
105
- workingDirectory: testPackagePath,
106
- );
107
- await SubprocessLauncher ('analyze-test-package' ).runStreamed (
108
- Platform .resolvedExecutable,
109
- // TODO(srawlins): Analyze the whole directory by ignoring the pubspec
110
- // reports.
111
- ['analyze' , 'lib' ],
112
- workingDirectory: testPackagePath,
113
- );
114
- }
115
- }
88
+ void analyzeTestPackages () async => task.analyzeTestPackages ();
116
89
117
90
@Task ('Check for dart format cleanliness' )
118
91
void checkFormat () async {
@@ -148,10 +121,11 @@ void checkFormat() async {
148
121
analyze,
149
122
checkFormat,
150
123
checkBuild,
151
- tryPublish,
152
- test,
153
124
)
154
- void presubmit () {}
125
+ void presubmit () async {
126
+ await task.runTryPublish ();
127
+ await task.runTest ();
128
+ }
155
129
156
130
@Task ('Run tests, self-test dartdoc, and run the publish test' )
157
131
@Depends (presubmit, test, testDartdoc)
@@ -268,7 +242,7 @@ Future<Iterable<Map<String, Object?>>> _buildTestPackageDocs(
268
242
String label = '' ,
269
243
String ? testPackagePath}) async {
270
244
if (label != '' ) label = '-$label ' ;
271
- testPackagePath ?? = testPackage.absolute.path;
245
+ testPackagePath ?? = task. testPackage.absolute.path;
272
246
var launcher = SubprocessLauncher ('build-test-package-docs$label ' );
273
247
var testPackagePubGet = launcher.runStreamed (
274
248
Platform .resolvedExecutable, ['pub' , 'get' ],
@@ -301,7 +275,7 @@ Future<Iterable<Map<String, Object?>>> _buildTestPackageDocs(
301
275
Future <void > buildTestExperimentsPackageDocs () async {
302
276
await _buildTestPackageDocs (
303
277
_testPackageExperimentsDocsDir.absolute.path, Directory .current.path,
304
- testPackagePath: testPackageExperiments.absolute.path,
278
+ testPackagePath: task. testPackageExperiments.absolute.path,
305
279
params: [
306
280
'--enable-experiment' ,
307
281
'non-nullable,generic-metadata' ,
@@ -311,10 +285,11 @@ Future<void> buildTestExperimentsPackageDocs() async {
311
285
312
286
@Task ('Serve experimental test package on port 8003.' )
313
287
@Depends (buildTestExperimentsPackageDocs)
314
- Future <void > serveTestExperimentsPackageDocs () async {
315
- await _serveDocsFrom (_testPackageExperimentsDocsDir.absolute.path, 8003 ,
316
- 'test-package-docs-experiments' );
317
- }
288
+ Future <void > serveTestExperimentsPackageDocs () async =>
289
+ await task.servePackageDocs (
290
+ name: Platform .environment['PACKAGE_NAME' ]! ,
291
+ version: Platform .environment['PACKAGE_VERSION' ],
292
+ );
318
293
319
294
@Task ('Build test package docs (HTML) with inherited docs and source code' )
320
295
@Depends (clean)
@@ -344,45 +319,8 @@ Future<void> startTestPackageDocsServer() async {
344
319
]);
345
320
}
346
321
347
- bool _serveReady = false ;
348
-
349
- Future <void > _serveDocsFrom (String servePath, int port, String context) async {
350
- log ('launching dhttpd on port $port for $context ' );
351
- var launcher = SubprocessLauncher (context);
352
- if (! _serveReady) {
353
- await launcher.runStreamed (Platform .resolvedExecutable, ['pub' , 'get' ]);
354
- await launcher.runStreamed (
355
- Platform .resolvedExecutable, ['pub' , 'global' , 'activate' , 'dhttpd' ]);
356
- _serveReady = true ;
357
- }
358
- await launcher.runStreamed (Platform .resolvedExecutable, [
359
- 'pub' ,
360
- 'global' ,
361
- 'run' ,
362
- 'dhttpd' ,
363
- '--port' ,
364
- '$port ' ,
365
- '--path' ,
366
- servePath
367
- ]);
368
- }
369
-
370
322
@Task ('Serve generated SDK docs locally with dhttpd on port 8000' )
371
- @Depends (buildSdkDocs)
372
- Future <void > serveSdkDocs () async {
373
- log ('launching dhttpd on port 8000 for SDK' );
374
- var launcher = SubprocessLauncher ('serve-sdk-docs' );
375
- await launcher.runStreamed (Platform .resolvedExecutable, [
376
- 'pub' ,
377
- 'global' ,
378
- 'run' ,
379
- 'dhttpd' ,
380
- '--port' ,
381
- '8000' ,
382
- '--path' ,
383
- task.sdkDocsDir.path,
384
- ]);
385
- }
323
+ Future <void > serveSdkDocs () async => await task.serveSdkDocs ();
386
324
387
325
@Task ('Compare warnings in Dartdoc for Flutter' )
388
326
Future <void > compareFlutterWarnings () async {
@@ -506,26 +444,28 @@ Future<Iterable<Map<String, Object?>>> _buildFlutterDocs(
506
444
@Task (
507
445
'Build an arbitrary pub package based on PACKAGE_NAME and PACKAGE_VERSION '
508
446
'environment variables' )
509
- Future <String > buildPubPackage () async => task.docPackage (
447
+ Future <String > buildPubPackage () async => await task.docPackage (
510
448
name: Platform .environment['PACKAGE_NAME' ]! ,
511
449
version: Platform .environment['PACKAGE_VERSION' ],
512
450
);
513
451
514
452
@Task (
515
- 'Serve an arbitrary pub package based on PACKAGE_NAME and PACKAGE_VERSION environment variables' )
516
- Future <void > servePubPackage () async {
517
- await _serveDocsFrom (await buildPubPackage (), 9000 , 'serve-pub-package' );
518
- }
453
+ 'Serve an arbitrary pub package based on PACKAGE_NAME and PACKAGE_VERSION '
454
+ 'environment variables' )
455
+ Future <void > servePubPackage () async => await task.servePackageDocs (
456
+ name: Platform .environment['PACKAGE_NAME' ]! ,
457
+ version: Platform .environment['PACKAGE_VERSION' ],
458
+ );
519
459
520
460
@Task ('Rebuild generated files' )
521
- @Depends (clean, buildWeb )
461
+ @Depends (clean)
522
462
Future <void > build () async {
523
463
if (Platform .isWindows) {
524
464
// Built files only need to be built on Linux and MacOS, as there are path
525
465
// issues with Windows.
526
466
return ;
527
467
}
528
-
468
+ await task. buildWeb ();
529
469
await task.buildRenderers ();
530
470
await task.buildDartdocOptions ();
531
471
}
@@ -595,11 +535,7 @@ Future<void> checkBuild() async {
595
535
Future <void > tryPublish () async => await task.runTryPublish ();
596
536
597
537
@Task ('Run all the tests.' )
598
- @Depends (analyzeTestPackages)
599
- Future <void > test () async {
600
- await SubprocessLauncher ('dart run test' ).runStreamed (
601
- Platform .resolvedExecutable, < String > ['--enable-asserts' , 'run' , 'test' ]);
602
- }
538
+ Future <void > test () async => await task.runTest ();
603
539
604
540
@Task ('Clean up test directories and delete build cache' )
605
541
Future <void > clean () async {
0 commit comments