OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// Tests code generation. | 5 /// Tests code generation. |
6 /// | 6 /// |
7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks | 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks |
8 /// that the output is what we expected. | 8 /// that the output is what we expected. |
9 library dev_compiler.test.codegen_test; | 9 library dev_compiler.test.codegen_test; |
10 | 10 |
11 // TODO(rnystrom): This doesn't actually run any tests any more. It just | 11 // TODO(rnystrom): This doesn't actually run any tests any more. It just |
12 // compiles stuff. This should be changed to not use unittest and just be a | 12 // compiles stuff. This should be changed to not use unittest and just be a |
13 // regular program that outputs files. | 13 // regular program that outputs files. |
14 | 14 |
| 15 import 'dart:convert'; |
15 import 'dart:io' show Directory, File, Platform; | 16 import 'dart:io' show Directory, File, Platform; |
16 import 'package:analyzer/analyzer.dart' | 17 import 'package:analyzer/analyzer.dart' |
17 show | 18 show |
18 ExportDirective, | 19 ExportDirective, |
19 ImportDirective, | 20 ImportDirective, |
20 StringLiteral, | 21 StringLiteral, |
21 UriBasedDirective, | 22 UriBasedDirective, |
22 parseDirectives; | 23 parseDirectives; |
23 import 'package:analyzer/src/command_line/arguments.dart' | 24 import 'package:analyzer/src/command_line/arguments.dart' |
24 show defineAnalysisArguments; | 25 show defineAnalysisArguments; |
25 import 'package:analyzer/src/dart/ast/ast.dart'; | 26 import 'package:analyzer/src/dart/ast/ast.dart'; |
26 import 'package:analyzer/src/generated/source.dart' show Source; | 27 import 'package:analyzer/src/generated/source.dart' show Source; |
27 import 'package:args/args.dart' show ArgParser, ArgResults; | 28 import 'package:args/args.dart' show ArgParser, ArgResults; |
28 import 'package:dev_compiler/src/analyzer/context.dart'; | 29 import 'package:dev_compiler/src/analyzer/context.dart'; |
29 import 'package:dev_compiler/src/compiler/compiler.dart' | 30 import 'package:dev_compiler/src/compiler/compiler.dart' |
30 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler; | 31 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler; |
31 import 'package:dev_compiler/src/compiler/module_builder.dart' | 32 import 'package:dev_compiler/src/compiler/module_builder.dart' |
32 show ModuleFormat, addModuleFormatOptions, parseModuleFormatOption; | 33 show ModuleFormat, addModuleFormatOptions, parseModuleFormatOption; |
33 import 'package:path/path.dart' as path; | 34 import 'package:path/path.dart' as path; |
34 import 'package:test/test.dart' show expect, isFalse, isTrue, test; | 35 import 'package:test/test.dart' show expect, isFalse, isTrue, test; |
| 36 import 'package:status_file/expectation.dart'; |
| 37 import 'package:test_dart/path.dart' as test_dart; |
| 38 import 'package:test_dart/test_suite.dart' show StandardTestSuite; |
| 39 import 'package:test_dart/utils.dart'; |
| 40 import 'package:test_dart/options.dart'; |
35 | 41 |
36 import '../tool/build_sdk.dart' as build_sdk; | 42 import '../tool/build_sdk.dart' as build_sdk; |
37 import 'compile_error_tests.dart'; | |
38 import 'multitest.dart' show extractTestsFromMultitest, isMultiTest; | 43 import 'multitest.dart' show extractTestsFromMultitest, isMultiTest; |
39 import 'testing.dart' show repoDirectory, testDirectory; | 44 import 'testing.dart' show repoDirectory, testDirectory; |
40 | 45 |
41 final ArgParser argParser = new ArgParser() | 46 final ArgParser argParser = new ArgParser() |
42 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null); | 47 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null); |
43 | 48 |
44 /// The `test/codegen` directory. | 49 /// The `test/codegen` directory. |
45 final codegenDir = path.join(testDirectory, 'codegen'); | 50 final codegenDir = path.join(testDirectory, 'codegen'); |
46 | 51 |
47 /// The `test/codegen/expect` directory. | 52 /// The `test/codegen/expect` directory. |
(...skipping 27 matching lines...) Expand all Loading... |
75 | 80 |
76 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg')) | 81 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg')) |
77 .listSync() | 82 .listSync() |
78 .map((e) => e.path) | 83 .map((e) => e.path) |
79 .where((p) => p.endsWith('.sum')) | 84 .where((p) => p.endsWith('.sum')) |
80 .toList(); | 85 .toList(); |
81 | 86 |
82 var sharedCompiler = new ModuleCompiler(new AnalyzerOptions.basic( | 87 var sharedCompiler = new ModuleCompiler(new AnalyzerOptions.basic( |
83 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths)); | 88 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths)); |
84 | 89 |
85 var testDirs = [ | 90 var testDirs = ['language', 'corelib', 'lib']; |
86 'language', | |
87 'corelib', | |
88 path.join('lib', 'async'), | |
89 path.join('lib', 'collection'), | |
90 path.join('lib', 'convert'), | |
91 path.join('lib', 'html'), | |
92 path.join('lib', 'math'), | |
93 path.join('lib', 'mirrors'), | |
94 path.join('lib', 'typed_data'), | |
95 ]; | |
96 | 91 |
97 // Copy all of the test files and expanded multitest files to | 92 // Copy all of the test files and expanded multitest files to |
98 // gen/codegen_tests. We'll compile from there. | 93 // gen/codegen_tests. We'll compile from there. |
| 94 TestUtils.setDartDirUri(Platform.script.resolve('../../..')); |
99 var testFiles = _setUpTests(testDirs); | 95 var testFiles = _setUpTests(testDirs); |
| 96 _writeRuntimeStatus(testFiles); |
100 | 97 |
101 // Our default compiler options. Individual tests can override these. | 98 // Our default compiler options. Individual tests can override these. |
102 var defaultOptions = ['--no-source-map', '--no-summarize']; | 99 var defaultOptions = ['--no-source-map', '--no-summarize']; |
103 var compileArgParser = new ArgParser(); | 100 var compileArgParser = new ArgParser(); |
104 defineAnalysisArguments(compileArgParser, ddc: true); | 101 defineAnalysisArguments(compileArgParser, ddc: true); |
105 AnalyzerOptions.addArguments(compileArgParser); | 102 AnalyzerOptions.addArguments(compileArgParser); |
106 CompilerOptions.addArguments(compileArgParser); | 103 CompilerOptions.addArguments(compileArgParser); |
107 addModuleFormatOptions(compileArgParser); | 104 addModuleFormatOptions(compileArgParser); |
108 | 105 |
109 var testFileOptionsMatcher = | 106 var testFileOptionsMatcher = |
110 new RegExp(r'// (compile options: |SharedOptions=)(.*)', multiLine: true); | 107 new RegExp(r'// (compile options: |SharedOptions=)(.*)', multiLine: true); |
111 | 108 |
112 // Ignore dart2js options that we don't support in DDC. | 109 // Ignore dart2js options that we don't support in DDC. |
113 var ignoreOptions = [ | 110 var ignoreOptions = [ |
114 '--enable-enum', | 111 '--enable-enum', |
115 '--experimental-trust-js-interop-type-annotations', | 112 '--experimental-trust-js-interop-type-annotations', |
116 '--trust-type-annotations', | 113 '--trust-type-annotations', |
117 '--supermixin' | 114 '--supermixin' |
118 ]; | 115 ]; |
119 | 116 |
120 // Compile each test file to JS and put the result in gen/codegen_output. | 117 // Compile each test file to JS and put the result in gen/codegen_output. |
121 for (var testFile in testFiles) { | 118 testFiles.forEach((testFile, status) { |
122 var relativePath = path.relative(testFile, from: codegenTestDir); | 119 var relativePath = path.relative(testFile, from: codegenTestDir); |
123 | 120 |
124 // Only compile the top-level files for generating coverage. | 121 // Only compile the top-level files for generating coverage. |
125 bool isTopLevelTest = path.dirname(relativePath) == "."; | 122 bool isTopLevelTest = path.dirname(relativePath) == "."; |
126 if (codeCoverage && !isTopLevelTest) continue; | 123 if (codeCoverage && !isTopLevelTest) return; |
| 124 |
| 125 if (status.contains(Expectation.skip) || |
| 126 status.contains(Expectation.skipByDesign)) { |
| 127 return; |
| 128 } |
127 | 129 |
128 var name = path.withoutExtension(relativePath); | 130 var name = path.withoutExtension(relativePath); |
129 test('dartdevc $name', () { | 131 test('dartdevc $name', () { |
130 // Check if we need to use special compile options. | 132 // Check if we need to use special compile options. |
131 var contents = new File(testFile).readAsStringSync(); | 133 var contents = new File(testFile).readAsStringSync(); |
132 var match = testFileOptionsMatcher.firstMatch(contents); | 134 var match = testFileOptionsMatcher.firstMatch(contents); |
133 | 135 |
134 var args = defaultOptions.toList(); | 136 var args = defaultOptions.toList(); |
135 if (match != null) { | 137 if (match != null) { |
136 var matchedArgs = match.group(2).split(' '); | 138 var matchedArgs = match.group(2).split(' '); |
(...skipping 25 matching lines...) Expand all Loading... |
162 } catch (e, st) { | 164 } catch (e, st) { |
163 exception = e; | 165 exception = e; |
164 stackTrace = st; | 166 stackTrace = st; |
165 } | 167 } |
166 | 168 |
167 // This covers tests where the intent of the test is to validate that | 169 // This covers tests where the intent of the test is to validate that |
168 // some static error is produced. | 170 // some static error is produced. |
169 var intentionalCompileError = contents.contains(': compile-time error') || | 171 var intentionalCompileError = contents.contains(': compile-time error') || |
170 contents.contains('/*@compile-error='); | 172 contents.contains('/*@compile-error='); |
171 | 173 |
172 // This covers tests that should not produce a static error but that | 174 var crashing = status.contains(Expectation.crash); |
173 // currently do due to issues in our implementation. | |
174 var knownCompileError = compileErrorTests.contains(name); | |
175 | |
176 var crashing = _crashingTests.contains(name); | |
177 var inconsistent = _inconsistentTests.contains(name); | |
178 | |
179 if (module == null) { | 175 if (module == null) { |
180 expect(crashing, isTrue, | 176 expect(crashing, isTrue, |
181 reason: "test $name crashes during compilation.\n" | 177 reason: "test $name crashes during compilation.\n" |
182 "$exception\n$stackTrace"); | 178 "$exception\n$stackTrace"); |
183 return; | 179 return; |
184 } | 180 } |
185 | 181 |
186 // Write out JavaScript and/or compilation errors/warnings. | 182 // Write out JavaScript and/or compilation errors/warnings. |
187 _writeModule( | 183 _writeModule( |
188 path.join(codegenOutputDir, name), | 184 path.join(codegenOutputDir, name), |
189 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 185 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
190 moduleFormat, | 186 moduleFormat, |
191 module); | 187 module); |
192 | 188 |
193 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 189 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
194 | 190 |
195 if (inconsistent) { | 191 var knownCompileError = status.contains(Expectation.compileTimeError); |
196 // An inconsistent test will only compile on some platforms (see | 192 if (module.isValid) { |
197 // comment below). It should not crash however. | |
198 } else if (module.isValid) { | |
199 // TODO(vsm): We don't seem to trip on non-strong errors? | |
200 // expect(expectedCompileTimeError, isFalse, | |
201 // reason: "test $name expected compilation errors, but compiled."); | |
202 expect(knownCompileError, isFalse, | 193 expect(knownCompileError, isFalse, |
203 reason: "test $name expected static errors, but compiled."); | 194 reason: "test $name expected static errors, but compiled."); |
204 } else { | 195 } else { |
205 var reason = intentionalCompileError ? "intended" : "unexpected"; | 196 var reason = intentionalCompileError ? "intended" : "unexpected"; |
206 expect(intentionalCompileError || knownCompileError, isTrue, | 197 expect(intentionalCompileError || knownCompileError, isTrue, |
207 reason: "test $name failed to compile due to $reason errors:" | 198 reason: "test $name failed to compile due to $reason errors:" |
208 "\n\n${module.errors.join('\n')}."); | 199 "\n\n${module.errors.join('\n')}."); |
209 } | 200 } |
210 }); | 201 }); |
211 } | 202 }); |
212 | 203 |
213 if (filePattern.hasMatch('sunflower')) { | 204 if (filePattern.hasMatch('sunflower')) { |
214 test('sunflower', () { | 205 test('sunflower', () { |
215 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); | 206 _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir); |
216 }); | 207 }); |
217 } | 208 } |
218 | 209 |
219 if (codeCoverage) { | 210 if (codeCoverage) { |
220 test('build_sdk code coverage', () { | 211 test('build_sdk code coverage', () { |
221 return build_sdk.main(['--dart-sdk', sdkDir, '-o', codegenOutputDir]); | 212 return build_sdk.main(['--dart-sdk', sdkDir, '-o', codegenOutputDir]); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 260 } |
270 | 261 |
271 String _moduleForLibrary(Source source) { | 262 String _moduleForLibrary(Source source) { |
272 var scheme = source.uri.scheme; | 263 var scheme = source.uri.scheme; |
273 if (scheme == 'package') { | 264 if (scheme == 'package') { |
274 return source.uri.pathSegments.first; | 265 return source.uri.pathSegments.first; |
275 } | 266 } |
276 throw new Exception('Module not found for library "${source.fullName}"'); | 267 throw new Exception('Module not found for library "${source.fullName}"'); |
277 } | 268 } |
278 | 269 |
279 List<String> _setUpTests(List<String> testDirs) { | 270 void _writeRuntimeStatus(Map<String, Set<Expectation>> testFiles) { |
280 var testFiles = <String>[]; | 271 var runtimeStatus = <String, String>{}; |
| 272 testFiles.forEach((name, status) { |
| 273 name = path.withoutExtension(path.relative(name, from: codegenTestDir)); |
| 274 // Skip tests that we don't expect to compile. |
| 275 if (status.contains(Expectation.compileTimeError) || |
| 276 status.contains(Expectation.crash) || |
| 277 status.contains(Expectation.skip) || |
| 278 status.contains(Expectation.skipByDesign)) { |
| 279 return; |
| 280 } |
| 281 // Normalize the expectations for the Karma language_test.js runner. |
| 282 if (status.remove(Expectation.ok)) assert(status.isNotEmpty); |
| 283 if (status.remove(Expectation.missingCompileTimeError) || |
| 284 status.remove(Expectation.missingRuntimeError)) { |
| 285 status.add(Expectation.pass); |
| 286 } |
281 | 287 |
| 288 // Don't include status for passing tests, as that is the default. |
| 289 // TODO(jmesserly): we could record these for extra sanity checks. |
| 290 if (status.length == 1 && status.contains(Expectation.pass)) { |
| 291 return; |
| 292 } |
| 293 |
| 294 runtimeStatus[name] = status.map((s) => '$s').join(','); |
| 295 }); |
| 296 new File(path.join(codegenOutputDir, 'test_status.js')).writeAsStringSync(''' |
| 297 define([], function() { |
| 298 'use strict'; |
| 299 return ${new JsonEncoder.withIndent(' ').convert(runtimeStatus)}; |
| 300 }); |
| 301 '''); |
| 302 } |
| 303 |
| 304 Map<String, Set<Expectation>> _setUpTests(List<String> testDirs) { |
| 305 var testFiles = <String, Set<Expectation>>{}; |
282 for (var testDir in testDirs) { | 306 for (var testDir in testDirs) { |
283 // TODO(rnystrom): Simplify this when the Dart 2.0 test migration is | 307 // TODO(rnystrom): Simplify this when the Dart 2.0 test migration is |
284 // complete (#30183). | 308 // complete (#30183). |
285 // Look for the tests in the "_strong" and "_2" directories in the SDK's | 309 // Look for the tests in the "_strong" and "_2" directories in the SDK's |
286 // main "tests" directory. | 310 // main "tests" directory. |
287 var dirParts = path.split(testDir); | 311 var dirParts = path.split(testDir); |
288 | 312 |
289 for (var suffix in const ["_2", "_strong"]) { | 313 for (var suffix in const ["_2", "_strong"]) { |
290 var sdkTestDir = | 314 var sdkTestDir = path.join( |
291 path.join(dirParts[0] + suffix, path.joinAll(dirParts.skip(1))); | 315 'tests', dirParts[0] + suffix, path.joinAll(dirParts.skip(1))); |
292 var inputPath = | 316 var inputPath = path.join(testDirectory, '..', '..', '..', sdkTestDir); |
293 path.join(testDirectory, '..', '..', '..', 'tests', sdkTestDir); | |
294 | 317 |
295 if (!new Directory(inputPath).existsSync()) continue; | 318 if (!new Directory(inputPath).existsSync()) continue; |
296 | 319 |
| 320 var browsers = Platform.environment['DDC_BROWSERS']; |
| 321 var runtime = browsers == 'Firefox' ? 'firefox' : 'chrome'; |
| 322 var config = new OptionsParser() |
| 323 .parse('-m release -c dartdevc --use-sdk --strong'.split(' ') |
| 324 ..addAll(['-r', runtime, '--suite_dir', sdkTestDir])) |
| 325 .single; |
| 326 |
| 327 var testSuite = new StandardTestSuite.forDirectory( |
| 328 config, new test_dart.Path(sdkTestDir)); |
| 329 var expectations = testSuite.readExpectations(); |
| 330 |
297 for (var file in _listFiles(inputPath, recursive: true)) { | 331 for (var file in _listFiles(inputPath, recursive: true)) { |
298 var relativePath = path.relative(file, from: inputPath); | 332 var relativePath = path.relative(file, from: inputPath); |
299 var outputPath = path.join(codegenTestDir, testDir, relativePath); | 333 var outputPath = path.join(codegenTestDir, testDir, relativePath); |
300 | 334 |
301 _ensureDirectory(path.dirname(outputPath)); | 335 _ensureDirectory(path.dirname(outputPath)); |
302 | 336 |
303 if (file.endsWith("_test.dart")) { | 337 if (file.endsWith("_test.dart")) { |
| 338 var statusPath = path.withoutExtension(relativePath); |
304 | 339 |
305 void _writeTest(String outputPath, String contents) { | 340 void _writeTest(String outputPath, String contents) { |
306 if (contents.contains('package:unittest/')) { | 341 if (contents.contains('package:unittest/')) { |
307 // TODO(jmesserly): we could use directive parsing, but that | 342 // TODO(jmesserly): we could use directive parsing, but that |
308 // feels like overkill. | 343 // feels like overkill. |
309 // Alternatively, we could detect "unittest" use at runtime. | 344 // Alternatively, we could detect "unittest" use at runtime. |
310 // We really need a better solution for Karma+mocha+unittest | 345 // We really need a better solution for Karma+mocha+unittest |
311 // integration. | 346 // integration. |
312 contents += '\nfinal _usesUnittestPackage = true;\n'; | 347 contents += '\nfinal _usesUnittestPackage = true;\n'; |
313 } | 348 } |
314 new File(outputPath).writeAsStringSync(contents); | 349 new File(outputPath).writeAsStringSync(contents); |
315 } | 350 } |
316 | 351 |
317 var contents = new File(file).readAsStringSync(); | 352 var contents = new File(file).readAsStringSync(); |
318 if (isMultiTest(contents)) { | 353 if (isMultiTest(contents)) { |
319 // It's a multitest, so expand it and add all of the variants. | 354 // It's a multitest, so expand it and add all of the variants. |
320 var tests = <String, String>{}; | 355 var tests = <String, String>{}; |
321 var outcomes = <String, Set<String>>{}; | 356 extractTestsFromMultitest(file, contents, tests); |
322 extractTestsFromMultitest(file, contents, tests, outcomes); | |
323 | 357 |
324 var fileName = path.basenameWithoutExtension(file); | 358 var fileName = path.basenameWithoutExtension(file); |
325 var outputDir = path.dirname(outputPath); | 359 var outputDir = path.dirname(outputPath); |
326 tests.forEach((name, contents) { | 360 tests.forEach((name, contents) { |
327 var multiFile = | 361 var multiFile = |
328 path.join(outputDir, '${fileName}_${name}_multi.dart'); | 362 path.join(outputDir, '${fileName}_${name}_multi.dart'); |
329 testFiles.add(multiFile); | 363 testFiles[multiFile] = |
| 364 expectations.expectations("$statusPath/$name"); |
330 | 365 |
331 _writeTest(multiFile, contents); | 366 _writeTest(multiFile, contents); |
332 }); | 367 }); |
333 } else { | 368 } else { |
334 // It's a single test suite. | 369 // It's a single test suite. |
335 testFiles.add(outputPath); | 370 testFiles[outputPath] = expectations.expectations(statusPath); |
336 } | 371 } |
337 | 372 |
338 // Write the test file. | 373 // Write the test file. |
339 // | 374 // |
340 // We do this even for multitests because import_self_test | 375 // We do this even for multitests because import_self_test |
341 // is a multitest, yet imports its own unexpanded form (!). | 376 // is a multitest, yet imports its own unexpanded form (!). |
342 _writeTest(outputPath, contents); | 377 _writeTest(outputPath, contents); |
343 | |
344 } else { | 378 } else { |
345 // Copy the non-test file over, in case it is used as an import. | 379 // Copy the non-test file over, in case it is used as an import. |
346 new File(file).copySync(outputPath); | 380 new File(file).copySync(outputPath); |
347 } | 381 } |
348 } | 382 } |
349 } | 383 } |
350 } | 384 } |
351 | 385 |
352 // Also include the other special files that live at the top level directory. | 386 // Also include the other special files that live at the top level directory. |
353 for (var file in _listFiles(codegenDir)) { | 387 for (var file in _listFiles(codegenDir)) { |
354 var relativePath = path.relative(file, from: codegenDir); | 388 var relativePath = path.relative(file, from: codegenDir); |
355 var outputPath = path.join(codegenTestDir, relativePath); | 389 var outputPath = path.join(codegenTestDir, relativePath); |
356 | 390 |
357 new File(file).copySync(outputPath); | 391 new File(file).copySync(outputPath); |
358 if (file.endsWith(".dart")) { | 392 if (file.endsWith(".dart")) { |
359 testFiles.add(outputPath); | 393 testFiles[outputPath] = new Set()..add(Expectation.pass); |
360 } | 394 } |
361 } | 395 } |
362 | 396 |
363 return testFiles; | 397 return testFiles; |
364 } | 398 } |
365 | 399 |
366 /// Recursively creates [dir] if it doesn't exist. | 400 /// Recursively creates [dir] if it doesn't exist. |
367 void _ensureDirectory(String dir) { | 401 void _ensureDirectory(String dir) { |
368 new Directory(dir).createSync(recursive: true); | 402 new Directory(dir).createSync(recursive: true); |
369 } | 403 } |
370 | 404 |
371 /// Lists all of the files within [dir] that match [filePattern]. | 405 /// Lists all of the files within [dir] that match [filePattern]. |
372 Iterable<String> _listFiles(String dir, {bool recursive: false}) { | 406 Iterable<String> _listFiles(String dir, {bool recursive: false}) { |
373 return new Directory(dir) | 407 return new Directory(dir) |
374 .listSync(recursive: recursive, followLinks: false) | 408 .listSync(recursive: recursive, followLinks: false) |
375 .where((entry) { | 409 .where((e) => e is File && filePattern.hasMatch(e.path)) |
376 if (entry is! File) return false; | 410 .map((f) => f.path); |
377 | |
378 var filePath = entry.path; | |
379 if (!filePattern.hasMatch(filePath)) return false; | |
380 | |
381 return true; | |
382 }).map((file) => file.path); | |
383 } | 411 } |
384 | 412 |
385 /// Parse directives from [contents] and find the complete set of transitive | 413 /// Parse directives from [contents] and find the complete set of transitive |
386 /// imports, reading files as needed. | 414 /// imports, reading files as needed. |
387 /// | 415 /// |
388 /// This will not include dart:* libraries, as those are implicitly available. | 416 /// This will not include dart:* libraries, as those are implicitly available. |
389 void _collectTransitiveImports(String contents, Set<String> libraries, | 417 void _collectTransitiveImports(String contents, Set<String> libraries, |
390 {String packageRoot, String from}) { | 418 {String packageRoot, String from}) { |
391 var uri = from; | 419 var uri = from; |
392 if (packageRoot != null && path.isWithin(packageRoot, from)) { | 420 if (packageRoot != null && path.isWithin(packageRoot, from)) { |
(...skipping 25 matching lines...) Expand all Loading... |
418 StringLiteral uriLiteral = directive.uri; | 446 StringLiteral uriLiteral = directive.uri; |
419 String uriContent = uriLiteral.stringValue; | 447 String uriContent = uriLiteral.stringValue; |
420 if (uriContent != null) { | 448 if (uriContent != null) { |
421 uriContent = uriContent.trim(); | 449 uriContent = uriContent.trim(); |
422 directive.uriContent = uriContent; | 450 directive.uriContent = uriContent; |
423 } | 451 } |
424 return (directive as UriBasedDirectiveImpl).validate() == null | 452 return (directive as UriBasedDirectiveImpl).validate() == null |
425 ? uriContent | 453 ? uriContent |
426 : null; | 454 : null; |
427 } | 455 } |
428 | |
429 /// Tests that, due to bugs, are strong-mode clean only on some platforms. | |
430 final _inconsistentTests = new Set<String>.from([ | |
431 // This test is clean on windows, but not linux/mac due to newline encoding. | |
432 // See: https://github.com/dart-lang/sdk/issues/27224 | |
433 'language/multiline_newline_test_02_multi', | |
434 ].map((p) => p.replaceAll('/', path.separator))); | |
435 | |
436 final _crashingTests = new Set<String>.from([ | |
437 // TODO(vsm): Fix these - they import files from a different directory | |
438 // - this triggers an invalid library root build error. | |
439 'lib/html/custom/attribute_changed_callback_test', | |
440 'lib/html/custom/constructor_calls_created_synchronously_test', | |
441 'lib/html/custom/entered_left_view_test', | |
442 'lib/html/custom/js_custom_test', | |
443 'lib/html/custom/mirrors_test', | |
444 'lib/html/custom/regress_194523002_test', | |
445 ].map((p) => p.replaceAll('/', path.separator))); | |
OLD | NEW |