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

Side by Side Diff: lib/src/testing.dart

Issue 1150143006: fixes #201, add support for custom URL mapping (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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) 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 library dev_compiler.src.testing; 5 library dev_compiler.src.testing;
6 6
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 /// }); 47 /// });
48 /// 48 ///
49 CheckerResults testChecker(Map<String, String> testFiles, 49 CheckerResults testChecker(Map<String, String> testFiles,
50 {bool allowConstCasts: true, String sdkDir, 50 {bool allowConstCasts: true, String sdkDir,
51 CheckerReporter createReporter(AnalysisContext context), 51 CheckerReporter createReporter(AnalysisContext context),
52 covariantGenerics: true, relaxedCasts: true, 52 covariantGenerics: true, relaxedCasts: true,
53 inferDownwards: RulesOptions.inferDownwardsDefault, 53 inferDownwards: RulesOptions.inferDownwardsDefault,
54 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 54 inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
55 inferTransitively: ResolverOptions.inferTransitivelyDefault, 55 inferTransitively: ResolverOptions.inferTransitivelyDefault,
56 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, 56 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES,
57 wrapClosures: RulesOptions.wrapClosuresDefault}) { 57 wrapClosures: RulesOptions.wrapClosuresDefault,
58 customUrlMappings: const {}}) {
58 expect(testFiles.containsKey('/main.dart'), isTrue, 59 expect(testFiles.containsKey('/main.dart'), isTrue,
59 reason: '`/main.dart` is missing in testFiles'); 60 reason: '`/main.dart` is missing in testFiles');
60 61
61 var provider = createTestResourceProvider(testFiles); 62 var provider = createTestResourceProvider(testFiles);
62 var uriResolver = new TestUriResolver(provider); 63 var uriResolver = new TestUriResolver(provider);
63 64
64 var options = new CompilerOptions( 65 var options = new CompilerOptions(
65 allowConstCasts: allowConstCasts, 66 allowConstCasts: allowConstCasts,
66 covariantGenerics: covariantGenerics, 67 covariantGenerics: covariantGenerics,
67 relaxedCasts: relaxedCasts, 68 relaxedCasts: relaxedCasts,
68 inferDownwards: inferDownwards, 69 inferDownwards: inferDownwards,
69 inferFromOverrides: inferFromOverrides, 70 inferFromOverrides: inferFromOverrides,
70 inferTransitively: inferTransitively, 71 inferTransitively: inferTransitively,
71 nonnullableTypes: nonnullableTypes, 72 nonnullableTypes: nonnullableTypes,
72 wrapClosures: wrapClosures, 73 wrapClosures: wrapClosures,
73 useMockSdk: sdkDir == null, 74 useMockSdk: sdkDir == null,
74 dartSdkPath: sdkDir, 75 dartSdkPath: sdkDir,
75 runtimeDir: '/dev_compiler_runtime/', 76 runtimeDir: '/dev_compiler_runtime/',
76 entryPointFile: '/main.dart'); 77 entryPointFile: '/main.dart',
78 customUrlMappings: customUrlMappings);
77 79
78 var context = createAnalysisContext(options, fileResolvers: [uriResolver]); 80 var context = createAnalysisContext(options, fileResolvers: [uriResolver]);
79 81
80 // Run the checker on /main.dart. 82 // Run the checker on /main.dart.
81 var mainFile = new Uri.file('/main.dart'); 83 var mainFile = new Uri.file('/main.dart');
82 TestReporter testReporter; 84 TestReporter testReporter;
83 CheckerReporter reporter; 85 CheckerReporter reporter;
84 if (createReporter == null) { 86 if (createReporter == null) {
85 reporter = testReporter = new TestReporter(context); 87 reporter = testReporter = new TestReporter(context);
86 } else { 88 } else {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 expect(tokens[1], "should", reason: 'invalid error descriptor'); 302 expect(tokens[1], "should", reason: 'invalid error descriptor');
301 expect(tokens[2], "be", reason: 'invalid error descriptor'); 303 expect(tokens[2], "be", reason: 'invalid error descriptor');
302 if (tokens[0] == "pass") return null; 304 if (tokens[0] == "pass") return null;
303 // TODO(leafp) For now, we just use whatever the current expectation is, 305 // TODO(leafp) For now, we just use whatever the current expectation is,
304 // eventually we could do more automated reporting here. 306 // eventually we could do more automated reporting here.
305 return _parse(tokens[0]); 307 return _parse(tokens[0]);
306 } 308 }
307 309
308 String toString() => '$level $type'; 310 String toString() => '$level $type';
309 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698