@@ -324,7 +324,7 @@ Future<void> runDoc(ArgResults commandResults) async {
324
324
'help' => _docHelp (),
325
325
'package' => _docPackage (commandResults, withStats: stats),
326
326
'sdk' => docSdk (withStats: stats),
327
- 'testing-package' => docTestingPackage (),
327
+ 'testing-package' => docTestingPackage (withStats : stats ),
328
328
_ => throw UnimplementedError ('Unknown doc target: "$target "' ),
329
329
};
330
330
}
@@ -515,11 +515,15 @@ Map<String, String> createThrowawayPubCache() {
515
515
final String _defaultPubCache = Platform .environment['PUB_CACHE' ] ??
516
516
path.context.resolveTildePath ('~/.pub-cache' );
517
517
518
- Future <String > docTestingPackage () async {
518
+ Future <String > docTestingPackage ({
519
+ bool withStats = false ,
520
+ }) async {
519
521
var testPackagePath = testPackage.absolute.path;
520
522
var launcher = SubprocessLauncher ('doc-test-package' );
521
- await launcher.runStreamedDartCommand (['pub' , 'get' ],
522
- workingDirectory: testPackagePath);
523
+ await launcher.runStreamedDartCommand (
524
+ ['pub' , 'get' ],
525
+ workingDirectory: testPackagePath,
526
+ );
523
527
var outputPath = _testingPackageDocsDir.absolute.path;
524
528
await launcher.runStreamedDartCommand (
525
529
[
@@ -533,7 +537,21 @@ Future<String> docTestingPackage() async {
533
537
'--pretty-index-json' ,
534
538
],
535
539
workingDirectory: testPackagePath,
540
+ withStats: withStats,
536
541
);
542
+
543
+ if (withStats && (Platform .isLinux || Platform .isMacOS)) {
544
+ // Prints all files in `outputPath`, newline-separated.
545
+ var findResult = Process .runSync ('find' , [outputPath, '-type' , 'f' ]);
546
+ var fileCount = (findResult.stdout as String ).split ('\n ' ).length;
547
+ var diskUsageResult = Process .runSync ('du' , ['-sh' , outputPath]);
548
+ // Output looks like
549
+ // 146M /var/folders/72/ltck4q353hsg3bn8kpkg7f84005w15/T/sdkdocsHcquiB
550
+ var diskUsageNumber =
551
+ (diskUsageResult.stdout as String ).trim ().split (RegExp ('\\ s+' )).first;
552
+ print ('Generated $fileCount files amounting to $diskUsageNumber .' );
553
+ }
554
+
537
555
return outputPath;
538
556
}
539
557
0 commit comments