| 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 27 matching lines...) Expand all Loading... |
| 38 // corresponding output file. | 38 // corresponding output file. |
| 39 Stream<TestDescription> readTestsFromStream(Stream<List<int>> input) async* { | 39 Stream<TestDescription> readTestsFromStream(Stream<List<int>> input) async* { |
| 40 Stream<String> lines = input | 40 Stream<String> lines = input |
| 41 .transform(UTF8.decoder) | 41 .transform(UTF8.decoder) |
| 42 .transform(new LineSplitter()); | 42 .transform(new LineSplitter()); |
| 43 await for (String line in lines) { | 43 await for (String line in lines) { |
| 44 int splitPoint = line.indexOf(' '); | 44 int splitPoint = line.indexOf(' '); |
| 45 if (splitPoint < 0) { | 45 if (splitPoint < 0) { |
| 46 print("Skipping garbage in input file: $line"); | 46 print("Skipping garbage in input file: $line"); |
| 47 } else { | 47 } else { |
| 48 Uri input = Uri.parse(line.substring(0, splitPoint)); | 48 Uri input = Uri.base.resolve(line.substring(0, splitPoint)); |
| 49 Uri output = Uri.parse(line.substring(splitPoint + 1)); | 49 Uri output = Uri.base.resolve(line.substring(splitPoint + 1)); |
| 50 yield new TestDescription(new File.fromUri(input), output: output); | 50 yield new TestDescription(new File.fromUri(input), output: output); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 class RunBatch extends Rastask { | 55 class RunBatch extends Rastask { |
| 56 RunBatch(CustomCompiler compiler, Stopwatch wallClock, Options options) | 56 RunBatch(CustomCompiler compiler, Stopwatch wallClock, Options options) |
| 57 : super(compiler, wallClock, options); | 57 : super(compiler, wallClock, options); |
| 58 | 58 |
| 59 Future<Null> run() async { | 59 Future<Null> run() async { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 File inputFile = new File.fromUri(testUri); | 76 File inputFile = new File.fromUri(testUri); |
| 77 tests = await inputFile.exists() | 77 tests = await inputFile.exists() |
| 78 ? readTestsFromStream(inputFile.openRead()) | 78 ? readTestsFromStream(inputFile.openRead()) |
| 79 : listTests(<Uri>[testUri], pattern: globalOptions.pattern); | 79 : listTests(<Uri>[testUri], pattern: globalOptions.pattern); |
| 80 } | 80 } |
| 81 | 81 |
| 82 await for (TestDescription description in tests) { | 82 await for (TestDescription description in tests) { |
| 83 assert(kernel.isInternalStateConsistent); | 83 assert(kernel.isInternalStateConsistent); |
| 84 count++; | 84 count++; |
| 85 | 85 |
| 86 int failuresBefore = compiler.elementsWithCompileTimeErrors.length; | |
| 87 Uri output = description.output; | 86 Uri output = description.output; |
| 88 output ??= description.uri.resolve("${description.uri.path}.dill"); | 87 output ??= description.uri.resolve("${description.uri.path}.dill"); |
| 89 | 88 |
| 90 Options options = new Options( | 89 Options options = new Options( |
| 91 description.uri, | 90 description.uri, |
| 92 output, | 91 output, |
| 93 dependenciesFile: null, | 92 dependenciesFile: null, |
| 94 generateLibrary: globalOptions.generateLibrary, | 93 generateLibrary: globalOptions.generateLibrary, |
| 95 isVerbose: globalOptions.isVerbose || batchFromStdin, | 94 isVerbose: globalOptions.isVerbose || batchFromStdin, |
| 96 isBatch: false, | 95 isBatch: false, |
| 97 pattern: null); | 96 pattern: null); |
| 98 | 97 |
| 99 try { | 98 try { |
| 100 await runOne(options); | 99 await runOne(options); |
| 101 } catch (e, s) { | 100 } catch (e, s) { |
| 102 kernel.recoverFromCrash(); | 101 kernel.recoverFromCrash(); |
| 103 if (options.isVerbose) { | 102 if (options.isVerbose) { |
| 104 print("${description.uri} failed: $e\n$s\n\n"); | 103 print("${description.uri} failed: $e\n$s\n\n"); |
| 105 } | 104 } |
| 106 failures.add(description); | 105 failures.add(description); |
| 107 if (batchFromStdin) print(">>> TEST CRASH"); | 106 if (batchFromStdin) print(">>> TEST CRASH"); |
| 108 } | 107 } |
| 109 | 108 |
| 110 if (batchFromStdin) { | 109 if (batchFromStdin) { |
| 111 int failuresAfter = compiler.elementsWithCompileTimeErrors.length; | 110 if (!hasCompileTimeErrors) { |
| 112 if (failuresAfter == failuresBefore) { | |
| 113 print(">>> TEST OK"); | 111 print(">>> TEST OK"); |
| 114 } else { | 112 } else { |
| 115 print(">>> TEST FAIL"); | 113 print(">>> TEST FAIL"); |
| 116 } | 114 } |
| 117 stderr.writeln(">>> EOF STDERR"); | 115 stderr.writeln(">>> EOF STDERR"); |
| 118 } else { | 116 } else { |
| 119 String averageTimeMs = | 117 String averageTimeMs = |
| 120 (wallClock.elapsedMilliseconds / count).toStringAsFixed(3); | 118 (wallClock.elapsedMilliseconds / count).toStringAsFixed(3); |
| 121 String successes = padTo(count - failures.length, 5); | 119 String successes = padTo(count - failures.length, 5); |
| 122 String failuresPadded = padTo(failures.length, 5); | 120 String failuresPadded = padTo(failures.length, 5); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 Failures: ${failures.length} | 147 Failures: ${failures.length} |
| 150 Average time per test: ${averageTimeMs}ms | 148 Average time per test: ${averageTimeMs}ms |
| 151 Success rate: ${(100 - failures.length * 100/count).toStringAsFixed(2)}%"""); | 149 Success rate: ${(100 - failures.length * 100/count).toStringAsFixed(2)}%"""); |
| 152 } | 150 } |
| 153 } | 151 } |
| 154 | 152 |
| 155 String padTo(int i, int pad) { | 153 String padTo(int i, int pad) { |
| 156 String result = (" " * pad) + "$i"; | 154 String result = (" " * pad) + "$i"; |
| 157 return result.substring(result.length - pad); | 155 return result.substring(result.length - pad); |
| 158 } | 156 } |
| OLD | NEW |