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 import 'util.dart'; | 5 import 'util.dart'; |
6 | 6 |
7 /// The [Uri] of a build step stdio log split into its subparts. | 7 /// The [Uri] of a build step stdio log split into its subparts. |
8 class BuildUri { | 8 class BuildUri { |
9 final String scheme; | |
10 final String host; | |
11 final String prefix; | |
12 final String botName; | 9 final String botName; |
13 final int buildNumber; | 10 final int buildNumber; |
14 final String stepName; | 11 final String stepName; |
15 final String suffix; | |
16 | 12 |
17 factory BuildUri(Uri uri) { | 13 factory BuildUri(Uri uri) { |
18 List<String> parts = split(Uri.decodeFull(uri.path), | 14 List<String> parts = split(Uri.decodeFull(uri.path), |
19 ['/builders/', '/builds/', '/steps/', '/logs/']); | 15 ['/builders/', '/builds/', '/steps/', '/logs/']); |
20 String botName = parts[1]; | 16 String botName = parts[1]; |
21 int buildNumber = int.parse(parts[2]); | 17 int buildNumber = int.parse(parts[2]); |
22 String stepName = parts[3]; | 18 String stepName = parts[3]; |
23 return new BuildUri.fromData(botName, buildNumber, stepName); | 19 return new BuildUri.fromData(botName, buildNumber, stepName); |
24 } | 20 } |
25 | 21 |
26 factory BuildUri.fromUrl(String url) { | 22 factory BuildUri.fromUrl(String url) { |
27 if (!url.endsWith('/text')) { | 23 if (!url.endsWith('/text')) { |
28 // Use the text version of the stdio log. | 24 // Use the text version of the stdio log. |
29 url += '/text'; | 25 url += '/text'; |
30 } | 26 } |
31 return new BuildUri(Uri.parse(url)); | 27 return new BuildUri(Uri.parse(url)); |
32 } | 28 } |
33 | 29 |
34 factory BuildUri.fromData(String botName, int buildNumber, String stepName) { | 30 BuildUri.fromData(this.botName, this.buildNumber, this.stepName); |
35 return new BuildUri.internal('https', 'build.chromium.org', | |
36 '/p/client.dart', botName, buildNumber, stepName, 'stdio/text'); | |
37 } | |
38 | |
39 BuildUri.internal(this.scheme, this.host, this.prefix, this.botName, | |
40 this.buildNumber, this.stepName, this.suffix); | |
41 | 31 |
42 BuildUri withBuildNumber(int buildNumber) { | 32 BuildUri withBuildNumber(int buildNumber) { |
43 return new BuildUri.fromData(botName, buildNumber, stepName); | 33 return new BuildUri.fromData(botName, buildNumber, stepName); |
44 } | 34 } |
45 | 35 |
46 int get absoluteBuildNumber => buildNumber >= 0 ? buildNumber : null; | 36 int get absoluteBuildNumber => buildNumber >= 0 ? buildNumber : null; |
47 | 37 |
48 String get shortBuildName => '$botName/$stepName'; | 38 String get shortBuildName => '$botName/$stepName'; |
49 | 39 |
50 String get buildName => | 40 String get buildName => |
51 '/builders/$botName/builds/$buildNumber/steps/$stepName'; | 41 '/builders/$botName/builds/$buildNumber/steps/$stepName'; |
52 | 42 |
53 String get path => '$prefix$buildName/logs/$suffix'; | 43 String get path => '/p/client.dart$buildName/logs/stdio/text'; |
54 | 44 |
55 /// Returns the path used in logdog for this build uri. | 45 /// Returns the path used in logdog for this build uri. |
56 /// | 46 /// |
57 /// Since logdog only supports absolute build numbers, [buildNumber] must be | 47 /// Since logdog only supports absolute build numbers, [buildNumber] must be |
58 /// non-negative. A [StateError] is thrown, otherwise. | 48 /// non-negative. A [StateError] is thrown, otherwise. |
59 String get logdogPath { | 49 String get logdogPath { |
60 if (buildNumber < 0) | 50 if (buildNumber < 0) |
61 throw new StateError('BuildUri $buildName must have a non-negative build ' | 51 throw new StateError('BuildUri $buildName must have a non-negative build ' |
62 'number to a valid logdog path.'); | 52 'number to a valid logdog path.'); |
63 return 'chromium/bb/client.dart/$botName/$buildNumber/+/recipes/steps/' | 53 return 'chromium/bb/client.dart/$botName/$buildNumber/+/recipes/steps/' |
64 '${stepName.replaceAll(' ', '_')}/0/stdout'; | 54 '${stepName.replaceAll(' ', '_')}/0/stdout'; |
65 } | 55 } |
66 | 56 |
67 /// Creates the [Uri] for this build step stdio log. | 57 /// Creates the [Uri] for this build step stdio log. |
68 Uri toUri() { | 58 Uri toUri() { |
69 return new Uri(scheme: scheme, host: host, path: path); | 59 return new Uri(scheme: 'https', host: 'build.chromium.org', path: path); |
70 } | 60 } |
71 | 61 |
72 /// Returns the [BuildUri] the previous build of this build step. | 62 /// Returns the [BuildUri] the previous build of this build step. |
73 BuildUri prev() { | 63 BuildUri prev() { |
74 return new BuildUri.internal( | 64 return new BuildUri.fromData(botName, buildNumber - 1, stepName); |
75 scheme, host, prefix, botName, buildNumber - 1, stepName, suffix); | |
76 } | 65 } |
77 | 66 |
78 String toString() { | 67 String toString() { |
79 return buildName; | 68 return buildName; |
80 } | 69 } |
81 } | 70 } |
82 | 71 |
83 /// Id for a test on a specific configuration, for instance | 72 /// Id for a test on a specific configuration, for instance |
84 /// `dart2js-chrome release_x64 co19/Language/Metadata/before_function_t07`. | 73 /// `dart2js-chrome release_x64 co19/Language/Metadata/before_function_t07`. |
85 class TestConfiguration { | 74 class TestConfiguration { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 218 |
230 /// The result of a single test for a single test step. | 219 /// The result of a single test for a single test step. |
231 class TestStatus { | 220 class TestStatus { |
232 final TestConfiguration config; | 221 final TestConfiguration config; |
233 final String status; | 222 final String status; |
234 | 223 |
235 TestStatus(this.config, this.status); | 224 TestStatus(this.config, this.status); |
236 | 225 |
237 String toString() => '$config: $status'; | 226 String toString() => '$config: $status'; |
238 } | 227 } |
OLD | NEW |