OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Compares the test log of a build step with previous builds. | 5 /// Compares the test log of a build step with previous builds. |
6 /// | 6 /// |
7 /// Use this to detect flakiness of failures, especially timeouts. | 7 /// Use this to detect flakiness of failures, especially timeouts. |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 String computePath(BuildUri buildUri) { | 27 String computePath(BuildUri buildUri) { |
28 return 'data/${buildUri.botName}/${buildUri.buildNumber}' | 28 return 'data/${buildUri.botName}/${buildUri.buildNumber}' |
29 '/${buildUri.stepName.replaceAll(' ', '_')}.log'; | 29 '/${buildUri.stepName.replaceAll(' ', '_')}.log'; |
30 } | 30 } |
31 | 31 |
32 Future<String> readData(BuildUri buildUri) async { | 32 Future<String> readData(BuildUri buildUri) async { |
33 String path = computePath(buildUri); | 33 String path = computePath(buildUri); |
34 File file = new File.fromUri(Platform.script.resolve(path)); | 34 File file = new File.fromUri(Platform.script.resolve(path)); |
35 if (!file.existsSync() && _client != null) { | 35 if (!file.existsSync() && _client != null) { |
36 await file.parent.create(); | 36 await file.parent.create(recursive: true); |
37 log('Pulling $buildUri from http'); | |
38 BuildResult result = await _client.readResult(buildUri); | 37 BuildResult result = await _client.readResult(buildUri); |
39 if (result.buildNumber != null) { | 38 if (result.buildNumber != null) { |
40 print('Writing test data to $file'); | 39 print('Writing test data to $file'); |
41 String text = await cache.read( | 40 String text = await cache.read( |
42 result.buildUri.logdogPath, | 41 result.buildUri.logdogPath, |
43 () => throw new ArgumentError( | 42 () => throw new ArgumentError( |
44 'Cache missing for ${result.buildUri.logdogPath}.')); | 43 'Cache missing for ${result.buildUri.logdogPath}.')); |
45 await file.writeAsString(text); | 44 await file.writeAsString(text); |
46 } | 45 } |
47 } | 46 } |
48 assert(file.existsSync(), "File $file not found."); | 47 assert(file.existsSync(), "File $file not found."); |
49 log('Reading test data from $file'); | 48 log('Reading test data from $file'); |
50 return file.readAsString(); | 49 return file.readAsString(); |
51 } | 50 } |
52 | 51 |
53 @override | 52 @override |
54 Future<BuildResult> readResult(BuildUri buildUri) async { | 53 Future<BuildResult> readResult(BuildUri buildUri) async { |
55 String text = await readData(buildUri); | 54 String text = await readData(buildUri); |
56 return parseTestStepResult(buildUri, text); | 55 return parseTestStepResult(buildUri, text); |
57 } | 56 } |
58 | 57 |
59 @override | 58 @override |
60 void close() { | 59 void close() { |
61 _client?.close(); | 60 _client?.close(); |
62 } | 61 } |
63 | 62 |
64 @override | 63 @override |
65 int get mostRecentBuildNumber => -1; | 64 int get mostRecentBuildNumber => -1; |
66 } | 65 } |
OLD | NEW |