| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 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 file. | |
| 4 | |
| 5 import 'dart:async'; | |
| 6 import 'package:async_helper/async_helper.dart'; | |
| 7 import 'package:expect/expect.dart'; | |
| 8 import 'sourcemap_helper.dart'; | |
| 9 | |
| 10 main(List<String> arguments) { | |
| 11 Set<String> configurations = new Set<String>(); | |
| 12 Set<String> files = new Set<String>(); | |
| 13 for (String argument in arguments) { | |
| 14 if (!parseArgument(argument, configurations, files)) { | |
| 15 return; | |
| 16 } | |
| 17 } | |
| 18 | |
| 19 if (configurations.isEmpty) { | |
| 20 configurations.addAll(TEST_CONFIGURATIONS.keys); | |
| 21 configurations.remove('old'); | |
| 22 } | |
| 23 if (files.isEmpty) { | |
| 24 files.addAll(TEST_FILES.keys); | |
| 25 } | |
| 26 | |
| 27 asyncTest(() async { | |
| 28 bool missingCodePointsFound = false; | |
| 29 for (String config in configurations) { | |
| 30 List<String> options = TEST_CONFIGURATIONS[config]; | |
| 31 for (String file in files) { | |
| 32 String filename = TEST_FILES[file]; | |
| 33 TestResult result = await runTests(config, filename, options); | |
| 34 if (result.failureMap.isNotEmpty) { | |
| 35 result.failureMap.forEach((info, missingCodePoints) { | |
| 36 print("Missing code points for ${info.element} in '$filename' " | |
| 37 "in config '$config':"); | |
| 38 for (CodePoint codePoint in missingCodePoints) { | |
| 39 print(" $codePoint"); | |
| 40 } | |
| 41 }); | |
| 42 missingCodePointsFound = true; | |
| 43 } | |
| 44 } | |
| 45 } | |
| 46 Expect.isFalse(missingCodePointsFound, | |
| 47 "Missing code points found. " | |
| 48 "Run the test with a URI option, " | |
| 49 "`source_mapping_test_viewer [--out=<uri>] [configs] [tests]`, to " | |
| 50 "create a html visualization of the missing code points."); | |
| 51 }); | |
| 52 } | |
| 53 | |
| 54 /// Parse [argument] for a valid configuration or test-file option. | |
| 55 /// | |
| 56 /// On success, the configuration name is added to [configurations] or the | |
| 57 /// test-file name is added to [files], and `true` is returned. | |
| 58 /// On failure, a message is printed and `false` is returned. | |
| 59 /// | |
| 60 bool parseArgument(String argument, | |
| 61 Set<String> configurations, | |
| 62 Set<String> files) { | |
| 63 if (TEST_CONFIGURATIONS.containsKey(argument)) { | |
| 64 configurations.add(argument); | |
| 65 } else if (TEST_FILES.containsKey(argument)) { | |
| 66 files.add(argument); | |
| 67 } else { | |
| 68 print("Unknown configuration or file '$argument'. " | |
| 69 "Must be one of '${TEST_CONFIGURATIONS.keys.join("', '")}' or " | |
| 70 "'${TEST_FILES.keys.join("', '")}'."); | |
| 71 return false; | |
| 72 } | |
| 73 return true; | |
| 74 } | |
| 75 | |
| 76 const Map<String, List<String>> TEST_CONFIGURATIONS = const { | |
| 77 'ssa': const ['--use-new-source-info', ], | |
| 78 'cps': const ['--use-new-source-info', '--use-cps-ir'], | |
| 79 'old': const [], | |
| 80 }; | |
| 81 | |
| 82 const Map<String, String> TEST_FILES = const <String, String>{ | |
| 83 'invokes': 'tests/compiler/dart2js/sourcemaps/invokes_test_file.dart', | |
| 84 'operators': 'tests/compiler/dart2js/sourcemaps/operators_test_file.dart', | |
| 85 }; | |
| 86 | |
| 87 Future<TestResult> runTests( | |
| 88 String config, | |
| 89 String filename, | |
| 90 List<String> options, | |
| 91 {bool verbose: true}) async { | |
| 92 SourceMapProcessor processor = new SourceMapProcessor(filename); | |
| 93 List<SourceMapInfo> infoList = await processor.process( | |
| 94 ['--csp', '--disable-inlining'] | |
| 95 ..addAll(options), | |
| 96 verbose: verbose); | |
| 97 TestResult result = new TestResult(config, filename, processor); | |
| 98 for (SourceMapInfo info in infoList) { | |
| 99 if (info.element.library.isPlatformLibrary) continue; | |
| 100 result.userInfoList.add(info); | |
| 101 Iterable<CodePoint> missingCodePoints = | |
| 102 info.codePoints.where((c) => c.isMissing); | |
| 103 if (missingCodePoints.isNotEmpty) { | |
| 104 result.failureMap[info] = missingCodePoints; | |
| 105 } | |
| 106 } | |
| 107 return result; | |
| 108 } | |
| 109 | |
| 110 class TestResult { | |
| 111 final String config; | |
| 112 final String file; | |
| 113 final SourceMapProcessor processor; | |
| 114 List<SourceMapInfo> userInfoList = <SourceMapInfo>[]; | |
| 115 Map<SourceMapInfo, Iterable<CodePoint>> failureMap = | |
| 116 <SourceMapInfo, Iterable<CodePoint>>{}; | |
| 117 | |
| 118 TestResult(this.config, this.file, this.processor); | |
| 119 } | |
| OLD | NEW |