| 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 /// Collects the test results for all build bots in [buildGroups] for tests | 5 /// Collects the test results for all build bots in [buildGroups] for tests |
| 6 /// that mention one of the test names given as argument. | 6 /// that mention one of the test names given as argument. |
| 7 /// | 7 /// |
| 8 /// The results are currently pulled from the second to last build since the | 8 /// The results are currently pulled from the second to last build since the |
| 9 /// last build might not have completed yet. | 9 /// last build might not have completed yet. |
| 10 | 10 |
| 11 import 'dart:math' hide log; | 11 import 'dart:math' hide log; |
| 12 import 'dart:io'; | 12 import 'dart:io'; |
| 13 | 13 |
| 14 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
| 15 import 'package:gardening/src/bot.dart'; | 15 import 'package:gardening/src/bot.dart'; |
| 16 import 'package:gardening/src/buildbot_data.dart'; | 16 import 'package:gardening/src/buildbot_data.dart'; |
| 17 import 'package:gardening/src/buildbot_structures.dart'; | 17 import 'package:gardening/src/buildbot_structures.dart'; |
| 18 import 'package:gardening/src/util.dart'; | 18 import 'package:gardening/src/util.dart'; |
| 19 | 19 |
| 20 void help(ArgParser argParser) { | 20 void help(ArgParser argParser) { |
| 21 print('Displays the current status of specific tests on the buildbot'); | 21 print('Displays the current status of specific tests on the buildbot'); |
| 22 print('Only prints output for failing tests.'); | |
| 23 print('The test-names may be fully qualified (such as in '); | 22 print('The test-names may be fully qualified (such as in '); |
| 24 print('"pkg/front_end/test/token_test") or just be a substring of the fully'); | 23 print('"pkg/front_end/test/token_test") or just be a substring of the fully'); |
| 25 print(' qualified name.'); | 24 print(' qualified name.'); |
| 26 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); | 25 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); |
| 27 print('where options are:'); | 26 print('where options are:'); |
| 28 print(argParser.usage); | 27 print(argParser.usage); |
| 29 } | 28 } |
| 30 | 29 |
| 31 /// Checks that [haystack] contains substring [needle], case insensitive. | |
| 32 /// Throws an exception if either parameter is `null`. | |
| 33 bool containsIgnoreCase(String haystack, String needle) { | |
| 34 if (haystack == null) { | |
| 35 throw "Unexpected null as the first paramter value of containsIgnoreCase"; | |
| 36 } | |
| 37 if (needle == null) { | |
| 38 throw "Unexpected null as the second parameter value of containsIgnoreCase"; | |
| 39 } | |
| 40 return haystack.toLowerCase().contains(needle.toLowerCase()); | |
| 41 } | |
| 42 | |
| 43 main(List<String> args) async { | 30 main(List<String> args) async { |
| 44 ArgParser argParser = createArgParser(); | 31 ArgParser argParser = createArgParser(); |
| 45 argParser.addOption('group', | 32 argParser.addOption('group', |
| 46 help: "Restricts the build groups\n" | 33 help: "Restricts the build groups\n" |
| 47 "to be searched for the results of the given test\n" | 34 "to be searched for the results of the given test\n" |
| 48 "to those containing the given substring, case insensitive."); | 35 "to those containing the given substring, case insensitive."); |
| 49 ArgResults argResults = argParser.parse(args); | 36 ArgResults argResults = argParser.parse(args); |
| 50 processArgResults(argResults); | 37 processArgResults(argResults); |
| 51 | 38 |
| 52 Bot bot = new Bot(logdog: argResults['logdog']); | 39 Bot bot = new Bot(logdog: argResults['logdog']); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 for (BuildGroup group in buildGroups) { | 54 for (BuildGroup group in buildGroups) { |
| 68 if (argResults['group'] != null && | 55 if (argResults['group'] != null && |
| 69 !containsIgnoreCase(group.groupName, argResults['group'])) { | 56 !containsIgnoreCase(group.groupName, argResults['group'])) { |
| 70 log('Skipping group $group'); | 57 log('Skipping group $group'); |
| 71 continue; | 58 continue; |
| 72 } | 59 } |
| 73 // TODO(johnniwinther): Support reading a partially completed shard from | 60 // TODO(johnniwinther): Support reading a partially completed shard from |
| 74 // http, i.e. always use build number `-1`. | 61 // http, i.e. always use build number `-1`. |
| 75 List<BuildUri> uriList = group.createUris(bot.mostRecentBuildNumber); | 62 List<BuildUri> uriList = group.createUris(bot.mostRecentBuildNumber); |
| 76 if (uriList.isEmpty) continue; | 63 if (uriList.isEmpty) continue; |
| 77 print('Fetching ${uriList.first} + ${uriList.length - 1} more ...'); | 64 print('Fetching "${uriList.first}" + ${uriList.length - 1} more ...'); |
| 78 List<BuildResult> results = await bot.readResults(uriList); | 65 List<BuildResult> results = await bot.readResults(uriList); |
| 79 bool testsFoundInGroup = false; | 66 bool testsFoundInGroup = false; |
| 80 for (BuildResult buildResult in results) { | 67 for (BuildResult buildResult in results) { |
| 81 if (buildResult == null) continue; | 68 if (buildResult == null) continue; |
| 82 var buildUri = buildResult.buildUri; | 69 var buildUri = buildResult.buildUri; |
| 83 for (TestStatus testStatus in buildResult.results) { | 70 for (TestStatus testStatus in buildResult.results) { |
| 84 String testName = testStatus.config.testName; | 71 String testName = testStatus.config.testName; |
| 85 for (String arg in argResults.rest) { | 72 for (String arg in argResults.rest) { |
| 86 if (testName.contains(arg) || arg.contains(testName)) { | 73 if (testName.contains(arg) || arg.contains(testName)) { |
| 87 testsFoundInGroup = true; | 74 testsFoundInGroup = true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (argResults.rest.length == 1) { | 112 if (argResults.rest.length == 1) { |
| 126 print("Test pattern '${argResults.rest.single}' not found " | 113 print("Test pattern '${argResults.rest.single}' not found " |
| 127 "in any build bot groups."); | 114 "in any build bot groups."); |
| 128 } else { | 115 } else { |
| 129 print("Test patterns '${argResults.rest.join("', '")}' not found " | 116 print("Test patterns '${argResults.rest.join("', '")}' not found " |
| 130 "in any build bot groups."); | 117 "in any build bot groups."); |
| 131 } | 118 } |
| 132 } | 119 } |
| 133 bot.close(); | 120 bot.close(); |
| 134 } | 121 } |
| OLD | NEW |