Chromium Code Reviews| 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 testing.multitest; | 5 library testing.multitest; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Stream, | 8 Stream, |
| 9 StreamTransformer; | 9 StreamTransformer; |
| 10 | 10 |
| 11 import 'dart:io' show | 11 import 'dart:io' show |
| 12 Directory, | 12 Directory, |
| 13 File; | 13 File; |
| 14 | 14 |
| 15 import 'log.dart' show | 15 import 'log.dart' show |
| 16 splitLines; | 16 splitLines; |
| 17 | 17 |
| 18 import 'test_description.dart' show | 18 import 'test_description.dart' show |
| 19 TestDescription; | 19 TestDescription; |
| 20 | 20 |
| 21 bool isError(Set<String> expectations) { | |
| 22 if (expectations.contains("compile-time error")) return true; | |
| 23 if (expectations.contains("runtime error")) return true; | |
| 24 if (expectations.contains("dynamic type error")) return true; | |
|
karlklose
2017/01/16 07:57:58
Is this annotation intended for strong mode? We di
ahe
2017/01/16 08:37:44
Not sure. I assumed it was for checked mode. Perha
ahe
2017/01/18 11:25:31
Following up in CL 2641833002.
| |
| 25 return false; | |
| 26 } | |
| 27 | |
| 28 bool isCheckedModeError(Set<String> expectations) { | |
| 29 if (expectations.contains("checked mode compile-time error")) return true; | |
| 30 return isError(expectations); | |
| 31 } | |
| 32 | |
| 21 class MultitestTransformer | 33 class MultitestTransformer |
| 22 implements StreamTransformer<TestDescription, TestDescription> { | 34 implements StreamTransformer<TestDescription, TestDescription> { |
| 23 static const String multitestMarker = "///"; | 35 static const String multitestMarker = "///"; |
| 24 | 36 |
| 25 static const List<String> validOutcomesList = const <String>[ | 37 static const List<String> validOutcomesList = const <String>[ |
| 26 'ok', | 38 "ok", |
| 27 'compile-time error', | 39 "compile-time error", |
| 28 'runtime error', | 40 "runtime error", |
| 29 'static type warning', | 41 "static type warning", |
| 30 'dynamic type error', | 42 "dynamic type error", |
| 31 'checked mode compile-time error', | 43 "checked mode compile-time error", |
| 32 ]; | 44 ]; |
| 33 | 45 |
| 34 static final Set<String> validOutcomes = | 46 static final Set<String> validOutcomes = |
| 35 new Set<String>.from(validOutcomesList); | 47 new Set<String>.from(validOutcomesList); |
| 36 | 48 |
| 37 Stream<TestDescription> bind(Stream<TestDescription> stream) async* { | 49 Stream<TestDescription> bind(Stream<TestDescription> stream) async* { |
| 38 List<String> errors = <String>[]; | 50 List<String> errors = <String>[]; |
| 39 reportError(String error) { | 51 reportError(String error) { |
| 40 errors.add(error); | 52 errors.add(error); |
| 41 print(error); | 53 print(error); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 } | 118 } |
| 107 } | 119 } |
| 108 Uri root = Uri.base.resolve("generated/"); | 120 Uri root = Uri.base.resolve("generated/"); |
| 109 Directory generated = new Directory.fromUri(root.resolve(test.shortName)); | 121 Directory generated = new Directory.fromUri(root.resolve(test.shortName)); |
| 110 generated = await generated.create(recursive: true); | 122 generated = await generated.create(recursive: true); |
| 111 for (String name in testsAsLines.keys) { | 123 for (String name in testsAsLines.keys) { |
| 112 List<String> lines = testsAsLines[name]; | 124 List<String> lines = testsAsLines[name]; |
| 113 Uri uri = generated.uri.resolve("${name}_generated.dart"); | 125 Uri uri = generated.uri.resolve("${name}_generated.dart"); |
| 114 TestDescription subtest = | 126 TestDescription subtest = |
| 115 new TestDescription(root, new File.fromUri(uri)); | 127 new TestDescription(root, new File.fromUri(uri)); |
| 128 subtest.multitestExpectations = outcomes[name]; | |
| 116 await subtest.file.writeAsString(lines.join("")); | 129 await subtest.file.writeAsString(lines.join("")); |
| 117 yield subtest; | 130 yield subtest; |
| 118 } | 131 } |
| 119 } | 132 } |
| 120 if (errors.isNotEmpty) { | 133 if (errors.isNotEmpty) { |
| 121 throw "Error: ${errors.join("\n")}"; | 134 throw "Error: ${errors.join("\n")}"; |
| 122 } | 135 } |
| 123 } | 136 } |
| 124 } | 137 } |
| OLD | NEW |