Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
|
floitsch
2014/11/03 17:55:54
2014
Johnni Winther
2014/11/04 12:24:33
Done.
| |
| 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 // Test that dart2js produces the expected static type warnings for these | |
| 6 // language tests. This ensures that the analyzer and dart2js agrees on the | |
| 7 // tests. | |
| 8 | |
| 9 import 'dart:async'; | |
| 10 | |
| 11 import 'package:expect/expect.dart'; | |
| 12 import 'package:async_helper/async_helper.dart'; | |
| 13 | |
| 14 import 'memory_compiler.dart'; | |
| 15 | |
| 16 import '../../../tools/testing/dart/multitest.dart' | |
| 17 show ExtractTestsFromMultitest; | |
| 18 import '../../../tools/testing/dart/utils.dart' | |
| 19 show Path; | |
| 20 | |
| 21 void check(List<String> testFiles, | |
| 22 {List<String> arguments: const <String>[], | |
| 23 List<String> options: const <String>[]}) { | |
| 24 bool outcomeMismatch = false; | |
| 25 bool verbose = arguments.contains('-v'); | |
| 26 var cachedCompiler; | |
| 27 asyncTest(() => Future.forEach(testFiles, (String testFile) { | |
| 28 Map<String, String> testSources = {}; | |
| 29 Map<String, Set<String>> testOutcomes = {}; | |
| 30 String fileName = 'tests/$testFile'; | |
| 31 ExtractTestsFromMultitest(new Path(fileName), testSources, testOutcomes); | |
| 32 return Future.forEach(testSources.keys, (String testName) { | |
| 33 String testFileName = '$fileName/$testName'; | |
| 34 Set<String> expectedOutcome = testOutcomes[testName]; | |
| 35 DiagnosticCollector collector = new DiagnosticCollector(); | |
| 36 var compiler = compilerFor( | |
| 37 {testFileName: testSources[testName]}, | |
| 38 diagnosticHandler: collector, | |
| 39 options: ['--analyze-only']..addAll(options), | |
| 40 showDiagnostics: verbose, | |
| 41 cachedCompiler: cachedCompiler); | |
| 42 return compiler.run(Uri.parse('memory:$testFileName')).then((_) { | |
| 43 if (expectedOutcome.contains('compile-time error')) { | |
| 44 if (collector.errors.isEmpty) { | |
| 45 print('$testFileName: Missing compile-time error.'); | |
| 46 outcomeMismatch = true; | |
| 47 } | |
| 48 } else if (expectedOutcome.contains('static type warning')) { | |
| 49 if (collector.warnings.isEmpty) { | |
| 50 print('$testFileName: Missing static type warning.'); | |
| 51 outcomeMismatch = true; | |
| 52 } | |
| 53 } else { | |
| 54 // Expect ok. | |
| 55 if (!collector.errors.isEmpty || | |
| 56 !collector.warnings.isEmpty) { | |
| 57 collector.errors.forEach((message) { | |
| 58 print('$testFileName: Unexpected error: ${message.message}'); | |
| 59 }); | |
| 60 collector.warnings.forEach((message) { | |
| 61 print('$testFileName: Unexpected warning: ${message.message}'); | |
| 62 }); | |
| 63 outcomeMismatch = true; | |
| 64 } | |
| 65 } | |
| 66 cachedCompiler = compiler; | |
| 67 }); | |
| 68 }); | |
| 69 }).then((_) { | |
| 70 Expect.isFalse(outcomeMismatch, 'Outcome mismatch'); | |
| 71 })); | |
| 72 } | |
| OLD | NEW |