Skip to content

Commit d8e4fee

Browse files
author
Eric Seidel
committed
Add nicer logging/reporting to dev/update_packages.dart
Makes it more obvious where we are spending our time on Travis. Also added travis caching for the global pub cache to speed this up! Modeled what dartdoc does: https://github.com/dart-lang/dartdoc/blob/master/.travis.yml#L13 @Hixie
1 parent e1fefc0 commit d8e4fee

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ before_script:
1313
- ./travis/setup.sh
1414
script:
1515
- ./travis/test.sh
16+
cache:
17+
directories:
18+
- $HOME/.pub-cache

dev/update_packages.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,40 @@
66
import 'dart:io';
77

88
final String binaryName = Platform.isWindows ? 'pub.bat' : 'pub';
9-
void update(Directory directory, bool upgrade) {
9+
int runPub(Directory directory, List<String> pubArgs) {
10+
int updateCount = 0;
1011
for (FileSystemEntity dir in directory.listSync()) {
1112
if (dir is Directory) {
12-
print("Updating ${dir.path}...");
13+
updateCount++;
14+
Stopwatch timer = new Stopwatch()..start();
15+
stdout.write("Updating ${dir.path}...");
1316
ProcessResult result = Process.runSync(
1417
binaryName,
15-
[ upgrade ? 'upgrade' : 'get' ],
18+
pubArgs,
1619
workingDirectory: dir.path
1720
);
21+
timer.stop();
22+
stdout.write(" (${timer.elapsedMilliseconds} ms)");
1823
if (result.exitCode != 0) {
1924
print("... failed with exit code ${result.exitCode}.");
2025
print(result.stdout);
2126
print(result.stderr);
27+
} else {
28+
stdout.write("\n");
2229
}
2330
}
2431
}
32+
return updateCount;
2533
}
2634

2735
void main(List<String> arguments) {
36+
Stopwatch timer = new Stopwatch()..start();
2837
bool upgrade = arguments.length > 0 && arguments[0] == '--upgrade';
2938
String FLUTTER_ROOT = new File(Platform.script.toFilePath()).parent.parent.path;
30-
update(new Directory("$FLUTTER_ROOT/packages"), upgrade);
31-
update(new Directory("$FLUTTER_ROOT/examples"), upgrade);
39+
List<String> pubArgs = [ upgrade ? 'upgrade' : 'get' ];
40+
int count = 0;
41+
count += runPub(new Directory("$FLUTTER_ROOT/packages"), pubArgs);
42+
count += runPub(new Directory("$FLUTTER_ROOT/examples"), pubArgs);
43+
String command = "$binaryName ${pubArgs.join(' ')}";
44+
print("Ran \"$command\" $count times in ${timer.elapsedMilliseconds} ms");
3245
}

0 commit comments

Comments
 (0)