| Index: tests/compiler/dart2js/kernel/closed_world_tester.dart
|
| diff --git a/tests/compiler/dart2js/kernel/closed_world_tester.dart b/tests/compiler/dart2js/kernel/closed_world_tester.dart
|
| index aac7e5bc45bc959318b99f91252e1223665c32c4..e1710afac0f19c863b81837e3266e3c9a7116bee 100644
|
| --- a/tests/compiler/dart2js/kernel/closed_world_tester.dart
|
| +++ b/tests/compiler/dart2js/kernel/closed_world_tester.dart
|
| @@ -8,33 +8,131 @@
|
| import 'dart:async';
|
| import 'dart:io';
|
|
|
| +import 'package:args/args.dart';
|
| import 'package:compiler/src/filenames.dart';
|
| import 'closed_world2_test.dart';
|
|
|
| +const String ERROR_MARKER = '---';
|
| +
|
| main(List<String> args) async {
|
| - for (String arg in args) {
|
| + ArgParser parser = new ArgParser();
|
| + parser.addOption('log');
|
| +
|
| + ArgResults argsResults = parser.parse(args);
|
| + String logName = argsResults['log'];
|
| + IOSink log;
|
| + Map<String, Result> results;
|
| + if (logName != null) {
|
| + if (FileSystemEntity.isFileSync(logName)) {
|
| + // Log a previous log file if it exists and use it to only test files that
|
| + // previously failed.
|
| + results = readLogResults(logName);
|
| + }
|
| + log = new File(logName).openWrite();
|
| + }
|
| +
|
| + if (results != null) {
|
| + for (String fileName in results.keys) {
|
| + Result result = results[fileName];
|
| + if (result.kind == ResultKind.failure) {
|
| + if (FileSystemEntity.isFileSync(fileName)) {
|
| + await testFile(new File(fileName), log);
|
| + } else {
|
| + print("$fileName doesn't exist");
|
| + }
|
| + } else {
|
| + log?.writeln('${fileName}: ${result.kind}');
|
| + }
|
| + }
|
| + }
|
| +
|
| + for (String arg in argsResults.rest) {
|
| String path = nativeToUriPath(arg);
|
| if (FileSystemEntity.isDirectorySync(path)) {
|
| Directory dir = new Directory(path);
|
| for (FileSystemEntity file in dir.listSync(recursive: true)) {
|
| if (file is File && file.path.endsWith('.dart')) {
|
| - await testFile(file);
|
| + if (results == null || !results.containsKey(file.path)) {
|
| + await testFile(file, log);
|
| + }
|
| }
|
| }
|
| } else if (FileSystemEntity.isFileSync(path)) {
|
| - await testFile(new File(path));
|
| + if (results == null || !results.containsKey(path)) {
|
| + await testFile(new File(path), log);
|
| + }
|
| } else {
|
| print("$arg doesn't exist");
|
| }
|
| }
|
| +
|
| + await log?.close();
|
| +}
|
| +
|
| +/// Read the log file in [logName] and returns the map from test file name to
|
| +/// [Result] stored in the log file.
|
| +Map<String, Result> readLogResults(String logName) {
|
| + Map<String, Result> results = <String, Result>{};
|
| + String text = new File(logName).readAsStringSync();
|
| + // Make a backup of the log file.
|
| + new File('$logName~').writeAsStringSync(text);
|
| + List<String> lines = text.split('\n');
|
| + int index = 0;
|
| + while (index < lines.length) {
|
| + String line = lines[index];
|
| + int colonPos = line.lastIndexOf(':');
|
| + if (colonPos == -1) {
|
| + if (!line.isEmpty) {
|
| + print('Invalid log line @ $index: $line');
|
| + }
|
| + } else {
|
| + String fileName = line.substring(0, colonPos);
|
| + String kindName = line.substring(colonPos + 1).trim();
|
| + ResultKind kind =
|
| + ResultKind.values.firstWhere((kind) => '$kind' == kindName);
|
| + String error;
|
| + if (kind == ResultKind.failure) {
|
| + assert(lines[index + 1] == ERROR_MARKER);
|
| + index += 2;
|
| + StringBuffer sb = new StringBuffer();
|
| + while (lines[index] != ERROR_MARKER) {
|
| + sb.writeln(lines[index]);
|
| + index++;
|
| + }
|
| + error = sb.toString();
|
| + }
|
| + results[fileName] = new Result(kind, error);
|
| + }
|
| + index++;
|
| + }
|
| + return results;
|
| }
|
|
|
| -Future testFile(File file) async {
|
| +Future testFile(File file, IOSink log) async {
|
| print('====================================================================');
|
| print('testing ${file.path}');
|
| + ResultKind kind;
|
| + String error;
|
| try {
|
| - await mainInternal([file.path], skipWarnings: true, skipErrors: true);
|
| + kind =
|
| + await mainInternal([file.path], skipWarnings: true, skipErrors: true);
|
| } catch (e, s) {
|
| - print('$e:\n$s');
|
| + kind = ResultKind.failure;
|
| + error = '$e:\n$s';
|
| + print(error);
|
| + }
|
| + log?.writeln('${file.path}: ${kind}');
|
| + if (error != null) {
|
| + log?.writeln(ERROR_MARKER);
|
| + log?.writeln(error);
|
| + log?.writeln(ERROR_MARKER);
|
| }
|
| + await log.flush();
|
| +}
|
| +
|
| +class Result {
|
| + final ResultKind kind;
|
| + final String error;
|
| +
|
| + Result(this.kind, [this.error]);
|
| }
|
|
|