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

Side by Side Diff: pkg/analyzer/test/src/task/strong/strong_test_helper.dart

Issue 1468623002: Revert "Fix test failures on the bots" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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) 2015, the Dart project authors. Please see the AUTHORS file 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 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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 library test.src.task.strong.strong_test_helper; 7 library test.src.task.strong.strong_test_helper;
8 8
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/src/context/context.dart' show SdkAnalysisContext; 11 import 'package:analyzer/src/context/context.dart' show SdkAnalysisContext;
12 import 'package:analyzer/src/generated/ast.dart'; 12 import 'package:analyzer/src/generated/ast.dart';
13 import 'package:analyzer/src/generated/element.dart'; 13 import 'package:analyzer/src/generated/element.dart';
14 import 'package:analyzer/src/generated/engine.dart' hide SdkAnalysisContext; 14 import 'package:analyzer/src/generated/engine.dart' hide SdkAnalysisContext;
15 import 'package:analyzer/src/generated/error.dart'; 15 import 'package:analyzer/src/generated/error.dart';
16 import 'package:analyzer/src/generated/sdk.dart'; 16 import 'package:analyzer/src/generated/sdk.dart';
17 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
18 import 'package:analyzer/src/task/strong/checker.dart'; 18 import 'package:analyzer/src/task/strong/checker.dart';
19 import 'package:analyzer/src/task/strong/rules.dart'; 19 import 'package:analyzer/src/task/strong/rules.dart';
20 import 'package:logging/logging.dart'; // TODO(jmesserly): remove 20 import 'package:logging/logging.dart'; // TODO(jmesserly): remove
21 import 'package:source_span/source_span.dart'; // TODO(jmesserly): remove 21 import 'package:source_span/source_span.dart'; // TODO(jmesserly): remove
22 import 'package:unittest/unittest.dart'; 22 import 'package:unittest/unittest.dart';
23 import 'package:plugin/manager.dart';
24 23
25 /// Run the checker on a program with files contents as indicated in 24 /// Run the checker on a program with files contents as indicated in
26 /// [testFiles]. 25 /// [testFiles].
27 /// 26 ///
28 /// This function makes several assumptions to make it easier to describe error 27 /// This function makes several assumptions to make it easier to describe error
29 /// expectations: 28 /// expectations:
30 /// 29 ///
31 /// * a file named `/main.dart` exists in [testFiles]. 30 /// * a file named `/main.dart` exists in [testFiles].
32 /// * all expected failures are listed in the source code using comments 31 /// * all expected failures are listed in the source code using comments
33 /// immediately in front of the AST node that should contain the error. 32 /// immediately in front of the AST node that should contain the error.
34 /// * errors are formatted as a token `level:Type`, where `level` is the 33 /// * errors are formatted as a token `level:Type`, where `level` is the
35 /// logging level were the error would be reported at, and `Type` is the 34 /// logging level were the error would be reported at, and `Type` is the
36 /// concrete subclass of [StaticInfo] that denotes the error. 35 /// concrete subclass of [StaticInfo] that denotes the error.
37 /// 36 ///
38 /// For example, to check that an assignment produces a warning about a boxing 37 /// For example, to check that an assignment produces a warning about a boxing
39 /// conversion, you can describe the test as follows: 38 /// conversion, you can describe the test as follows:
40 /// 39 ///
41 /// testChecker({ 40 /// testChecker({
42 /// '/main.dart': ''' 41 /// '/main.dart': '''
43 /// testMethod() { 42 /// testMethod() {
44 /// dynamic x = /*warning:Box*/3; 43 /// dynamic x = /*warning:Box*/3;
45 /// } 44 /// }
46 /// ''' 45 /// '''
47 /// }); 46 /// });
48 /// 47 ///
49 void testChecker(String name, Map<String, String> testFiles) { 48 void testChecker(String name, Map<String, String> testFiles) {
50 test(name, () { 49 test(name, () {
51 ExtensionManager extensionManager = new ExtensionManager();
52 extensionManager.processPlugins(AnalysisEngine.instance.supportedPlugins);
53
54 expect(testFiles.containsKey('/main.dart'), isTrue, 50 expect(testFiles.containsKey('/main.dart'), isTrue,
55 reason: '`/main.dart` is missing in testFiles'); 51 reason: '`/main.dart` is missing in testFiles');
56 52
57 var provider = new MemoryResourceProvider(); 53 var provider = new MemoryResourceProvider();
58 testFiles.forEach((key, value) { 54 testFiles.forEach((key, value) {
59 var scheme = 'package:'; 55 var scheme = 'package:';
60 if (key.startsWith(scheme)) { 56 if (key.startsWith(scheme)) {
61 key = '/packages/${key.substring(scheme.length)}'; 57 key = '/packages/${key.substring(scheme.length)}';
62 } 58 }
63 provider.newFile(key, value); 59 provider.newFile(key, value);
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 if (levelName == 'warning') return _MAGENTA_COLOR; 491 if (levelName == 'warning') return _MAGENTA_COLOR;
496 if (levelName == 'info') return _CYAN_COLOR; 492 if (levelName == 'info') return _CYAN_COLOR;
497 return null; 493 return null;
498 } 494 }
499 495
500 const String _RED_COLOR = '\u001b[31m'; 496 const String _RED_COLOR = '\u001b[31m';
501 const String _MAGENTA_COLOR = '\u001b[35m'; 497 const String _MAGENTA_COLOR = '\u001b[35m';
502 const String _CYAN_COLOR = '\u001b[36m'; 498 const String _CYAN_COLOR = '\u001b[36m';
503 const String GREEN_COLOR = '\u001b[32m'; 499 const String GREEN_COLOR = '\u001b[32m';
504 const String NO_COLOR = '\u001b[0m'; 500 const String NO_COLOR = '\u001b[0m';
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/summary_test.dart ('k') | pkg/analyzer/tool/task_dependency_graph/generate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698