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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:front_end/compiler_options.dart'; | 7 import 'package:front_end/compiler_options.dart'; |
8 import 'package:front_end/dependency_grapher.dart'; | 8 import 'package:front_end/dependency_grapher.dart'; |
9 import 'package:front_end/memory_file_system.dart'; | 9 import 'package:front_end/memory_file_system.dart'; |
10 import 'package:path/path.dart' as pathos; | 10 import 'package:path/path.dart' as pathos; |
(...skipping 17 matching lines...) Expand all Loading... |
28 unorderedEquals(dependencies)); | 28 unorderedEquals(dependencies)); |
29 expect(library.parts.map((part) => '$part'), unorderedEquals(parts)); | 29 expect(library.parts.map((part) => '$part'), unorderedEquals(parts)); |
30 return library; | 30 return library; |
31 } | 31 } |
32 | 32 |
33 Future<List<LibraryCycleNode>> getCycles(Map<String, String> contents, | 33 Future<List<LibraryCycleNode>> getCycles(Map<String, String> contents, |
34 {List<String> startingPoints, String packagesFilePath = ''}) async { | 34 {List<String> startingPoints, String packagesFilePath = ''}) async { |
35 // If no starting points given, assume the first entry in [contents] is the | 35 // If no starting points given, assume the first entry in [contents] is the |
36 // single starting point. | 36 // single starting point. |
37 startingPoints ??= [contents.keys.first]; | 37 startingPoints ??= [contents.keys.first]; |
38 var fileSystem = new MemoryFileSystem(pathos.posix, Uri.parse('file:///')); | 38 var fileSystem = new MemoryFileSystem(Uri.parse('file:///')); |
39 contents.forEach((path, text) { | 39 contents.forEach((path, text) { |
40 fileSystem.entityForUri(pathos.posix.toUri(path)).writeAsStringSync(text); | 40 fileSystem.entityForUri(pathos.posix.toUri(path)).writeAsStringSync(text); |
41 }); | 41 }); |
42 // TODO(paulberry): implement and test other option possibilities. | 42 // TODO(paulberry): implement and test other option possibilities. |
43 var options = new CompilerOptions() | 43 var options = new CompilerOptions() |
44 ..fileSystem = fileSystem | 44 ..fileSystem = fileSystem |
45 ..chaseDependencies = true | 45 ..chaseDependencies = true |
46 ..packagesFileUri = packagesFilePath == '' | 46 ..packagesFileUri = packagesFilePath == '' |
47 ? new Uri() | 47 ? new Uri() |
48 : pathos.posix.toUri(packagesFilePath); | 48 : pathos.posix.toUri(packagesFilePath); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 expect(bar.dependencies[0], same(foo)); | 186 expect(bar.dependencies[0], same(foo)); |
187 } | 187 } |
188 | 188 |
189 test_singleFile() async { | 189 test_singleFile() async { |
190 var cycles = await getCycles({'/foo.dart': ''}); | 190 var cycles = await getCycles({'/foo.dart': ''}); |
191 expect(cycles, hasLength(1)); | 191 expect(cycles, hasLength(1)); |
192 expect(cycles[0].libraries, hasLength(1)); | 192 expect(cycles[0].libraries, hasLength(1)); |
193 checkLibrary(cycles[0], 'file:///foo.dart'); | 193 checkLibrary(cycles[0], 'file:///foo.dart'); |
194 } | 194 } |
195 } | 195 } |
OLD | NEW |