Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/compiler/dart2js/frontend_checker.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Checks that dart2js produces the expected static type warnings and 5 // Checks that dart2js produces the expected static type warnings and
6 // compile-time errors for the provided multitests. 6 // compile-time errors for the provided multitests.
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:async_helper/async_helper.dart'; 11 import 'package:async_helper/async_helper.dart';
12 import 'package:compiler/src/commandline_options.dart'; 12 import 'package:compiler/src/commandline_options.dart';
13 import 'package:compiler/src/util/uri_extras.dart' 13 import 'package:compiler/src/util/uri_extras.dart' show relativize;
14 show relativize;
15 import 'memory_compiler.dart'; 14 import 'memory_compiler.dart';
16 15
17 import '../../../tools/testing/dart/multitest.dart' 16 import '../../../tools/testing/dart/multitest.dart'
18 show ExtractTestsFromMultitest; 17 show ExtractTestsFromMultitest;
19 import '../../../tools/testing/dart/path.dart' 18 import '../../../tools/testing/dart/path.dart' show Path;
20 show Path;
21
22 19
23 /// Check the analysis of the multitests in [testFiles] to result in the 20 /// Check the analysis of the multitests in [testFiles] to result in the
24 /// expected static warnings and compile-time errors. 21 /// expected static warnings and compile-time errors.
25 /// 22 ///
26 /// [testFiles] is a map of the test files to be checked together with their 23 /// [testFiles] is a map of the test files to be checked together with their
27 /// associated white listing. 24 /// associated white listing.
28 /// 25 ///
29 /// For instance if [testFiles] contain the mapping 26 /// For instance if [testFiles] contain the mapping
30 /// 'language/async_await_syntax_test.dart': const ['a03b', 'a04b'] 27 /// 'language/async_await_syntax_test.dart': const ['a03b', 'a04b']
31 /// the multitests in 'language/async_await_syntax_test.dart' are checked but 28 /// the multitests in 'language/async_await_syntax_test.dart' are checked but
32 /// the subtests 'a03b' and 'a04c' are expected to fail. 29 /// the subtests 'a03b' and 'a04c' are expected to fail.
33 void check(Map<String, List<String>> testFiles, 30 void check(Map<String, List<String>> testFiles,
34 {List<String> arguments: const <String>[], 31 {List<String> arguments: const <String>[],
35 List<String> options: const <String>[]}) { 32 List<String> options: const <String>[]}) {
36 bool outcomeMismatch = false; 33 bool outcomeMismatch = false;
37 bool verbose = arguments.contains('-v'); 34 bool verbose = arguments.contains('-v');
38 var cachedCompiler; 35 var cachedCompiler;
39 asyncTest(() => Future.forEach(testFiles.keys, (String testFile) { 36 asyncTest(() => Future.forEach(testFiles.keys, (String testFile) {
40 Map<String, String> testSources = {}; 37 Map<String, String> testSources = {};
41 Map<String, Set<String>> testOutcomes = {}; 38 Map<String, Set<String>> testOutcomes = {};
42 String fileName = 'tests/$testFile'; 39 String fileName = 'tests/$testFile';
43 ExtractTestsFromMultitest(new Path(fileName), testSources, testOutcomes); 40 ExtractTestsFromMultitest(
44 return Future.forEach(testSources.keys, (String testName) async { 41 new Path(fileName), testSources, testOutcomes);
45 String testFileName = '$fileName/$testName'; 42 return Future.forEach(testSources.keys, (String testName) async {
46 Set<String> expectedOutcome = testOutcomes[testName]; 43 String testFileName = '$fileName/$testName';
47 bool expectFailure = testFiles[testFile].contains(testName); 44 Set<String> expectedOutcome = testOutcomes[testName];
48 DiagnosticCollector collector = new DiagnosticCollector(); 45 bool expectFailure = testFiles[testFile].contains(testName);
49 CompilationResult result = await runCompiler( 46 DiagnosticCollector collector = new DiagnosticCollector();
50 entryPoint: Uri.parse('memory:$testFileName'), 47 CompilationResult result = await runCompiler(
51 memorySourceFiles: {testFileName: testSources[testName]}, 48 entryPoint: Uri.parse('memory:$testFileName'),
52 diagnosticHandler: collector, 49 memorySourceFiles: {testFileName: testSources[testName]},
53 options: [Flags.analyzeOnly]..addAll(options), 50 diagnosticHandler: collector,
54 showDiagnostics: verbose, 51 options: [Flags.analyzeOnly]..addAll(options),
55 cachedCompiler: cachedCompiler); 52 showDiagnostics: verbose,
56 var compiler = result.compiler; 53 cachedCompiler: cachedCompiler);
57 bool unexpectedResult = false; 54 var compiler = result.compiler;
58 if (expectedOutcome.contains('compile-time error')) { 55 bool unexpectedResult = false;
59 if (collector.errors.isEmpty) { 56 if (expectedOutcome.contains('compile-time error')) {
60 print('$testFileName: Missing compile-time error.'); 57 if (collector.errors.isEmpty) {
61 unexpectedResult = true; 58 print('$testFileName: Missing compile-time error.');
62 } 59 unexpectedResult = true;
63 } else if (expectedOutcome.contains('static type warning')) { 60 }
64 if (collector.warnings.isEmpty) { 61 } else if (expectedOutcome.contains('static type warning')) {
65 print('$testFileName: Missing static type warning.'); 62 if (collector.warnings.isEmpty) {
66 unexpectedResult = true; 63 print('$testFileName: Missing static type warning.');
67 } 64 unexpectedResult = true;
68 } else { 65 }
69 // Expect ok. 66 } else {
70 if (!collector.errors.isEmpty || 67 // Expect ok.
71 !collector.warnings.isEmpty) { 68 if (!collector.errors.isEmpty || !collector.warnings.isEmpty) {
72 collector.errors.forEach((message) { 69 collector.errors.forEach((message) {
73 print('$testFileName: Unexpected error: ${message.message}'); 70 print('$testFileName: Unexpected error: ${message.message}');
74 }); 71 });
75 collector.warnings.forEach((message) { 72 collector.warnings.forEach((message) {
76 print('$testFileName: Unexpected warning: ${message.message}'); 73 print('$testFileName: Unexpected warning: ${message.message}');
77 }); 74 });
78 unexpectedResult = true; 75 unexpectedResult = true;
79 } 76 }
80 } 77 }
81 if (expectFailure) { 78 if (expectFailure) {
82 if (unexpectedResult) { 79 if (unexpectedResult) {
83 unexpectedResult = false; 80 unexpectedResult = false;
84 } else { 81 } else {
85 print('$testFileName: The test is white-listed ' 82 print('$testFileName: The test is white-listed '
86 'and therefore expected to fail.'); 83 'and therefore expected to fail.');
87 unexpectedResult = true; 84 unexpectedResult = true;
88 } 85 }
89 } 86 }
90 if (unexpectedResult) { 87 if (unexpectedResult) {
91 outcomeMismatch = true; 88 outcomeMismatch = true;
92 } 89 }
93 cachedCompiler = compiler; 90 cachedCompiler = compiler;
94 }); 91 });
95 }).then((_) { 92 }).then((_) {
96 if (outcomeMismatch) { 93 if (outcomeMismatch) {
97 String testFileName = 94 String testFileName =
98 relativize(Uri.base, Platform.script, Platform.isWindows); 95 relativize(Uri.base, Platform.script, Platform.isWindows);
99 print(''' 96 print('''
100 97
101 === 98 ===
102 === ERROR: Unexpected result of analysis. 99 === ERROR: Unexpected result of analysis.
103 === 100 ===
104 === Please update the white-listing in $testFileName 101 === Please update the white-listing in $testFileName
105 === 102 ===
106 103
107 '''); 104 ''');
108 exit(1); 105 exit(1);
109 } 106 }
110 })); 107 }));
111 } 108 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/forloop_box_test.dart ('k') | tests/compiler/dart2js/generate_at_use_site_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698