| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library rasta.run_batch; | 5 library rasta.run_batch; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future, | 8 Future, |
| 9 Stream; | 9 Stream; |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 Uri testDirectory = compiler.translateUri(null, options.input); | 61 Uri testDirectory = compiler.translateUri(null, options.input); |
| 62 | 62 |
| 63 // TODO(ahe): This lists all tests in [testDirectory] and generates Kernel | 63 // TODO(ahe): This lists all tests in [testDirectory] and generates Kernel |
| 64 // IR for them all. However, batch mode should be a server that is | 64 // IR for them all. However, batch mode should be a server that is |
| 65 // controlled by test.dart. | 65 // controlled by test.dart. |
| 66 // TODO(ahe): Share more code with RunSingle. | 66 // TODO(ahe): Share more code with RunSingle. |
| 67 | 67 |
| 68 List<TestDescription> failures = <TestDescription>[]; | 68 List<TestDescription> failures = <TestDescription>[]; |
| 69 | 69 |
| 70 int count = 1; | 70 int count = 0; |
| 71 print("\n"); | 71 print("\n"); |
| 72 Stream<TestDescription> tests = | 72 Stream<TestDescription> tests = |
| 73 listTests(<Uri>[testDirectory], pattern: options.pattern); | 73 listTests(<Uri>[testDirectory], pattern: options.pattern); |
| 74 await for (TestDescription description in tests) { | 74 await for (TestDescription description in tests) { |
| 75 count++; |
| 75 try { | 76 try { |
| 76 Options options = new Options( | 77 Options options = new Options( |
| 77 description.uri, | 78 description.uri, |
| 78 description.uri.resolve("${description.uri.path}.bart"), | 79 description.uri.resolve("${description.uri.path}.bart"), |
| 79 generateLibrary: this.options.generateLibrary); | 80 generateLibrary: this.options.generateLibrary); |
| 80 | 81 |
| 81 ir.Library library = await kernel.loadLibrary(options.input); | 82 ir.Library library = await kernel.loadLibrary(options.input); |
| 82 kernel.processWorkQueue(targetLibrary: options.input); | 83 kernel.processWorkQueue(targetLibrary: options.input); |
| 83 | 84 |
| 84 if (options.generateLibrary == true) { | 85 if (options.generateLibrary == true) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 110 String successes = padTo(count - failures.length, 5); | 111 String successes = padTo(count - failures.length, 5); |
| 111 String failuresPadded = padTo(failures.length, 5); | 112 String failuresPadded = padTo(failures.length, 5); |
| 112 print( | 113 print( |
| 113 "\u001b[1A" | 114 "\u001b[1A" |
| 114 "\u001b[2K" | 115 "\u001b[2K" |
| 115 "\u001b[1A" | 116 "\u001b[1A" |
| 116 "\u001b[2K" | 117 "\u001b[2K" |
| 117 "Average time per test: ${averageTimeMs}ms\n" | 118 "Average time per test: ${averageTimeMs}ms\n" |
| 118 "[${wallClock.elapsed} | --% | +$successes | -$failuresPadded ]" | 119 "[${wallClock.elapsed} | --% | +$successes | -$failuresPadded ]" |
| 119 ); | 120 ); |
| 120 count++; | |
| 121 } | 121 } |
| 122 wallClock.stop(); | 122 wallClock.stop(); |
| 123 String averageTimeMs = | 123 String averageTimeMs = |
| 124 (wallClock.elapsedMilliseconds / count).toStringAsFixed(3); | 124 (wallClock.elapsedMilliseconds / count).toStringAsFixed(3); |
| 125 | 125 |
| 126 if (failures.isNotEmpty) { | 126 if (failures.isNotEmpty) { |
| 127 print("\n=== Failures ===\n"); | 127 print("\n=== Failures ===\n"); |
| 128 for (TestDescription description in failures) { | 128 for (TestDescription description in failures) { |
| 129 print("${relativize(Uri.base, description.uri, false)}: Fail"); | 129 print("${relativize(Uri.base, description.uri, false)}: Fail"); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 print( | 133 print( |
| 134 """ | 134 """ |
| 135 | 135 |
| 136 === Summary === | 136 === Summary === |
| 137 Total: $count | 137 Total: $count |
| 138 Failures: ${failures.length} | 138 Failures: ${failures.length} |
| 139 Average time per test: ${averageTimeMs}ms | 139 Average time per test: ${averageTimeMs}ms |
| 140 Success rate: ${(100 - failures.length * 100/count).toStringAsFixed(2)}%"""); | 140 Success rate: ${(100 - failures.length * 100/count).toStringAsFixed(2)}%"""); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 String padTo(int i, int pad) { | 144 String padTo(int i, int pad) { |
| 145 String result = (" " * pad) + "$i"; | 145 String result = (" " * pad) + "$i"; |
| 146 return result.substring(result.length - pad); | 146 return result.substring(result.length - pad); |
| 147 } | 147 } |
| OLD | NEW |