Skip to content

Commit 724d9e5

Browse files
author
Dart CI
committed
Version 2.12.0-223.0.dev
Merge commit 'e77605459608700c908d3453b24cf54c1a7ff639' into 'dev'
2 parents 010633e + e776054 commit 724d9e5

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

pkg/test_runner/tool/convert_multitest.dart

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ import 'update_static_error_tests.dart' show runAnalyzer, runCfe;
2222

2323
Future<List<StaticError>> getErrors(
2424
List<String> options, String filePath) async {
25-
return [
26-
...await runAnalyzer(filePath, options),
27-
...await runCfe(filePath, options)
28-
];
25+
var analyzerErrors = await runAnalyzer(filePath, options);
26+
if (analyzerErrors == null) {
27+
exit(1);
28+
}
29+
var cfeErrors = await runCfe(filePath, options);
30+
if (cfeErrors == null) {
31+
exit(1);
32+
}
33+
return [...analyzerErrors, ...cfeErrors];
2934
}
3035

3136
bool areSameErrors(List<StaticError> first, List<StaticError> second) {
@@ -142,18 +147,8 @@ ${cleanedMultiTest.text}""";
142147
}
143148
}
144149

145-
Future<void> main(List<String> arguments) async {
146-
var parser = ArgParser();
147-
parser.addFlag("verbose", abbr: "v", help: "print additional information");
148-
parser.addFlag("write", abbr: "w", help: "write output to input file");
149-
var results = parser.parse(arguments);
150-
if (results.rest.length != 1) {
151-
print("Usage: convert_multi_test.dart [-v] [-w] <input file>");
152-
exitCode = 1;
153-
return;
154-
}
155-
var verbose = results["verbose"] as bool;
156-
var testFilePath = Uri.base.resolve(results.rest.single).toFilePath();
150+
Future<void> convertFile(String testFilePath, bool writeToFile, bool verbose,
151+
List<String> experiments) async {
157152
var testFile = File(testFilePath);
158153
if (!await testFile.exists()) {
159154
print("File '${testFile.uri.toFilePath()}' not found");
@@ -190,6 +185,9 @@ Future<void> main(List<String> arguments) async {
190185
// Get the reported errors for the multi-test and all generated sub-tests
191186
// from the analyser and the common front-end.
192187
var options = test.sharedOptions;
188+
if (experiments.isNotEmpty) {
189+
options.add("--enable-experiment=${experiments.join(',')}");
190+
}
193191
var errors = <List<StaticError>>[];
194192
for (var test in tests) {
195193
if (verbose) {
@@ -198,7 +196,7 @@ Future<void> main(List<String> arguments) async {
198196
errors.add(await getErrors(options, test.path.toNativePath()));
199197
}
200198
if (errors[1].isNotEmpty) {
201-
throw "internal error: errors in '/none' test";
199+
throw UnableToConvertException("internal error: errors in '/none' test");
202200
}
203201
// Check that the multi-test generates the same errors as all sub-tests
204202
// together - otherwise converting the test would be unsound.
@@ -217,7 +215,6 @@ Future<void> main(List<String> arguments) async {
217215
// and output the result.
218216
var annotatedContent =
219217
updateErrorExpectations(contentWithoutMarkers, errors[0]);
220-
var writeToFile = results["write"] as bool;
221218
if (writeToFile) {
222219
await testFile.writeAsString(annotatedContent);
223220
print("Converted test '${test.path.toNativePath()}'.");
@@ -245,3 +242,27 @@ Future<void> main(List<String> arguments) async {
245242
outputDirectory.delete(recursive: true);
246243
}
247244
}
245+
246+
Future<void> main(List<String> arguments) async {
247+
var parser = ArgParser();
248+
parser.addFlag("verbose", abbr: "v", help: "print additional information");
249+
parser.addFlag("write", abbr: "w", help: "write output to input file");
250+
parser.addOption("enable-experiment",
251+
help: "Enable one or more experimental features", allowMultiple: true);
252+
253+
var results = parser.parse(arguments);
254+
if (results.rest.isEmpty) {
255+
print("Usage: convert_multi_test.dart [-v] [-w] <input files>");
256+
print(parser.getUsage());
257+
exitCode = 1;
258+
return;
259+
}
260+
var verbose = results["verbose"] as bool;
261+
var filePaths =
262+
results.rest.map((path) => Uri.base.resolve(path).toFilePath());
263+
var writeToFile = results["write"] as bool;
264+
for (var testFilePath in filePaths) {
265+
await convertFile(testFilePath, writeToFile, verbose,
266+
(results["enable-experiment"] as List).cast<String>());
267+
}
268+
}

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 12
2929
PATCH 0
30-
PRERELEASE 222
30+
PRERELEASE 223
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)