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

Side by Side Diff: tests/compiler/dart2js/incremental/hello_test.dart

Issue 2346053002: dart2js: fix tests after moving to .packages in the SDK repo (Closed)
Patch Set: 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 // Test a sequence of modifications to hello-world which used to cause problems 5 // Test a sequence of modifications to hello-world which used to cause problems
6 // on Try Dart. 6 // on Try Dart.
7 7
8 import 'dart:io' show 8 import 'dart:io' show Platform;
9 Platform;
10 9
11 import 'dart:async' show 10 import 'dart:async' show Future;
12 Future;
13 11
14 import 'package:dart2js_incremental/dart2js_incremental.dart' show 12 import 'package:dart2js_incremental/dart2js_incremental.dart'
15 IncrementalCompiler; 13 show IncrementalCompiler;
16 14
17 import 'package:compiler/compiler.dart' show 15 import 'package:compiler/compiler.dart' show Diagnostic;
18 Diagnostic;
19 16
20 import 'package:compiler/src/null_compiler_output.dart' show 17 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput;
21 NullCompilerOutput;
22 18
23 import 'package:compiler/src/old_to_new_api.dart' show 19 import 'package:compiler/src/old_to_new_api.dart'
24 LegacyCompilerDiagnostics; 20 show LegacyCompilerDiagnostics;
25 21
26 import 'package:async_helper/async_helper.dart' show 22 import 'package:async_helper/async_helper.dart' show asyncTest;
27 asyncTest;
28 23
29 import 'package:expect/expect.dart' show 24 import 'package:expect/expect.dart' show Expect;
30 Expect;
31 25
32 import '../memory_source_file_helper.dart' show 26 import '../memory_source_file_helper.dart' show MemorySourceFileProvider;
33 MemorySourceFileProvider;
34 27
35 var tests = { 28 var tests = {
36 '/test1.dart': 29 '/test1.dart': '''
37 '''
38 var greeting = "Hello, World!"; 30 var greeting = "Hello, World!";
39 31
40 void main() { 32 void main() {
41 print(greeting); 33 print(greeting);
42 } 34 }
43 ''', 35 ''',
44 '/test2.dart': 36 '/test2.dart': '''
45 '''
46 va greeting = "Hello, World!"; 37 va greeting = "Hello, World!";
47 38
48 void main() { 39 void main() {
49 print(greeting); 40 print(greeting);
50 } 41 }
51 ''', 42 ''',
52 '/test3.dart': 43 '/test3.dart': '''
53 '''
54 greeting = "Hello, World!"; 44 greeting = "Hello, World!";
55 45
56 void main() { 46 void main() {
57 print(greeting); 47 print(greeting);
58 } 48 }
59 ''', 49 ''',
60 '/test4.dart': 50 '/test4.dart': '''
61 '''
62 in greeting = "Hello, World!"; 51 in greeting = "Hello, World!";
63 52
64 void main() { 53 void main() {
65 print(greeting); 54 print(greeting);
66 } 55 }
67 ''', 56 ''',
68 '/test5.dart': 57 '/test5.dart': '''
69 '''
70 int greeting = "Hello, World!"; 58 int greeting = "Hello, World!";
71 59
72 void main() { 60 void main() {
73 print(greeting); 61 print(greeting);
74 } 62 }
75 ''', 63 ''',
76 }; 64 };
77 65
78 var testResults = { 66 var testResults = {
79 '/test1.dart': true, 67 '/test1.dart': true,
80 '/test2.dart': true, 68 '/test2.dart': true,
81 '/test3.dart': false, 69 '/test3.dart': false,
82 '/test4.dart': false, 70 '/test4.dart': false,
83 '/test5.dart': true, 71 '/test5.dart': true,
84 }; 72 };
85 73
86 main() { 74 main() {
87 Uri libraryRoot = Uri.base.resolve('sdk/'); 75 Uri libraryRoot = Uri.base.resolve('sdk/');
88 Uri packageRoot = Uri.base.resolve(Platform.packageRoot); 76 Uri packageConfig = Uri.base.resolve('.packages');
89 MemorySourceFileProvider provider = 77 MemorySourceFileProvider provider = new MemorySourceFileProvider(tests);
90 new MemorySourceFileProvider(tests); 78 asyncTest(() => runTests(libraryRoot, packageConfig, provider));
91 asyncTest(() => runTests(libraryRoot, packageRoot, provider));
92 } 79 }
93 80
94 Future runTests( 81 Future runTests(
95 Uri libraryRoot, 82 Uri libraryRoot, Uri packageConfig, MemorySourceFileProvider provider) {
96 Uri packageRoot,
97 MemorySourceFileProvider provider) {
98 IncrementalCompiler compiler = new IncrementalCompiler( 83 IncrementalCompiler compiler = new IncrementalCompiler(
99 diagnosticHandler: new LegacyCompilerDiagnostics(handler), 84 diagnosticHandler: new LegacyCompilerDiagnostics(handler),
100 inputProvider: provider, 85 inputProvider: provider,
101 outputProvider: const NullCompilerOutput(), 86 outputProvider: const NullCompilerOutput(),
102 options: ['--analyze-main'], 87 options: ['--analyze-main'],
103 libraryRoot: libraryRoot, 88 libraryRoot: libraryRoot,
104 packageRoot: packageRoot); 89 packageConfig: packageConfig);
105 90
106 return Future.forEach(tests.keys, (String testName) { 91 return Future.forEach(tests.keys, (String testName) {
107 Uri testUri = Uri.parse('memory:$testName'); 92 Uri testUri = Uri.parse('memory:$testName');
108 return compiler.compile(testUri).then((bool success) { 93 return compiler.compile(testUri).then((bool success) {
109 Expect.equals( 94 Expect.equals(testResults[testName], success,
110 testResults[testName], success,
111 'Compilation unexpectedly ${success ? "succeed" : "failed"}.'); 95 'Compilation unexpectedly ${success ? "succeed" : "failed"}.');
112 }); 96 });
113 }); 97 });
114 } 98 }
115 99
116 void handler(Uri uri, 100 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
117 int begin,
118 int end,
119 String message,
120 Diagnostic kind) {
121 if (kind != Diagnostic.VERBOSE_INFO) { 101 if (kind != Diagnostic.VERBOSE_INFO) {
122 print('$uri:$begin:$end:$message:$kind'); 102 print('$uri:$begin:$end:$message:$kind');
123 } 103 }
124 } 104 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/import_test.dart ('k') | tests/compiler/dart2js/library_resolution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698