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

Side by Side Diff: test/testing.dart

Issue 1788973002: Remove code that requires whole-program compile (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merged Created 4 years, 9 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
« no previous file with comments | « test/report_test.dart ('k') | test/transformer/hello_app/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
11 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; 11 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl;
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:cli_util/cli_util.dart' show getSdkDir; 13 import 'package:cli_util/cli_util.dart' show getSdkDir;
14 import 'package:path/path.dart' as path; 14 import 'package:path/path.dart' as path;
15 15
16 import 'package:dev_compiler/src/analysis_context.dart'; 16 import 'package:dev_compiler/src/analysis_context.dart';
17
18 import 'package:dev_compiler/src/server/dependency_graph.dart'
19 show runtimeFilesForServerMode;
20 import 'package:dev_compiler/src/options.dart'; 17 import 'package:dev_compiler/src/options.dart';
21 18
22 /// Shared analysis context used for compilation. 19 /// Shared analysis context used for compilation.
23 final AnalysisContext realSdkContext = () { 20 final AnalysisContext realSdkContext = () {
24 var context = createAnalysisContextWithSources(new SourceResolverOptions( 21 var context = createAnalysisContextWithSources(new SourceResolverOptions(
25 dartSdkPath: getSdkDir().path, 22 dartSdkPath: getSdkDir().path,
26 customUrlMappings: { 23 customUrlMappings: {
27 'package:expect/expect.dart': _testCodegenPath('expect.dart'), 24 'package:expect/expect.dart': _testCodegenPath('expect.dart'),
28 'package:async_helper/async_helper.dart': 25 'package:async_helper/async_helper.dart':
29 _testCodegenPath('async_helper.dart'), 26 _testCodegenPath('async_helper.dart'),
30 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'), 27 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'),
31 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart') 28 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart')
32 })); 29 }));
33 (context.analysisOptions as AnalysisOptionsImpl).cacheSize = 512; 30 (context.analysisOptions as AnalysisOptionsImpl).cacheSize = 512;
34 return context; 31 return context;
35 }(); 32 }();
36 33
37 String _testCodegenPath(String p1, [String p2]) => 34 String _testCodegenPath(String p1, [String p2]) =>
38 path.join(testDirectory, 'codegen', p1, p2); 35 path.join(testDirectory, 'codegen', p1, p2);
39 36
40 final String testDirectory = 37 final String testDirectory =
41 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); 38 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path);
42 39
43 class _TestUtils {} 40 class _TestUtils {}
44 41
45 /// Creates a [MemoryResourceProvider] with test data
46 MemoryResourceProvider createTestResourceProvider(
47 Map<String, String> testFiles) {
48 var provider = new MemoryResourceProvider();
49 runtimeFilesForServerMode.forEach((filepath) {
50 testFiles['/dev_compiler_runtime/$filepath'] =
51 '/* test contents of $filepath */';
52 });
53 testFiles.forEach((key, value) {
54 var scheme = 'package:';
55 if (key.startsWith(scheme)) {
56 key = '/packages/${key.substring(scheme.length)}';
57 }
58 provider.newFile(key, value);
59 });
60 return provider;
61 }
62
63 class TestUriResolver extends ResourceUriResolver { 42 class TestUriResolver extends ResourceUriResolver {
64 final MemoryResourceProvider provider; 43 final MemoryResourceProvider provider;
65 TestUriResolver(provider) 44 TestUriResolver(provider)
66 : provider = provider, 45 : provider = provider,
67 super(provider); 46 super(provider);
68 47
69 @override 48 @override
70 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 49 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
71 if (uri.scheme == 'package') { 50 if (uri.scheme == 'package') {
72 return (provider.getResource('/packages/' + uri.path) as File) 51 return (provider.getResource('/packages/' + uri.path) as File)
73 .createSource(uri); 52 .createSource(uri);
74 } 53 }
75 return super.resolveAbsolute(uri, actualUri); 54 return super.resolveAbsolute(uri, actualUri);
76 } 55 }
77 } 56 }
OLDNEW
« no previous file with comments | « test/report_test.dart ('k') | test/transformer/hello_app/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698