| OLD | NEW |
| 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 import 'package:analysis_server/src/services/dependencies/library_dependencies.d
art'; | 5 import 'package:analysis_server/src/services/dependencies/library_dependencies.d
art'; |
| 6 import 'package:test/test.dart'; | 6 import 'package:test/test.dart'; |
| 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 | 8 |
| 9 import '../../abstract_context.dart'; | 9 import '../../abstract_context.dart'; |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 defineReflectiveSuite(() { | 12 defineReflectiveSuite(() { |
| 13 defineReflectiveTests(LibraryDependenciesTest); | 13 defineReflectiveTests(LibraryDependenciesTest); |
| 14 }); | 14 }); |
| 15 } | 15 } |
| 16 | 16 |
| 17 @reflectiveTest | 17 @reflectiveTest |
| 18 class LibraryDependenciesTest extends AbstractContextTest { | 18 class LibraryDependenciesTest extends AbstractContextTest { |
| 19 @failingTest | 19 @failingTest |
| 20 test_LibraryDependencies() { | 20 test_LibraryDependencies() { |
| 21 // See https://github.com/dart-lang/sdk/issues/29310 | 21 // See https://github.com/dart-lang/sdk/issues/29310 |
| 22 addSource('/lib1.dart', 'import "lib2.dart";'); | 22 addSource('/lib1.dart', 'import "lib2.dart";'); |
| 23 addSource('/lib2.dart', 'import "lib1.dart";'); | 23 addSource('/lib2.dart', 'import "lib1.dart";'); |
| 24 addSource('/lib3.dart', 'import "lib2.dart";'); | 24 addSource('/lib3.dart', 'import "lib2.dart";'); |
| 25 addSource('/lib4.dart', 'import "lib5.dart";'); | 25 addSource('/lib4.dart', 'import "lib5.dart";'); |
| 26 provider.newFile('/lib5.dart', 'import "lib6.dart";'); | 26 provider.newFile('/lib5.dart', 'import "lib6.dart";'); |
| 27 provider.newFile('/lib6.dart', ''); | 27 provider.newFile('/lib6.dart', ''); |
| 28 | 28 |
| 29 _performAnalysis(); | 29 var libs = new LibraryDependencyCollector([]).collectLibraryDependencies(); |
| 30 | |
| 31 var libs = | |
| 32 new LibraryDependencyCollector([context]).collectLibraryDependencies(); | |
| 33 | 30 |
| 34 // Cycles | 31 // Cycles |
| 35 expect(libs, contains('/lib1.dart')); | 32 expect(libs, contains('/lib1.dart')); |
| 36 expect(libs, contains('/lib2.dart')); | 33 expect(libs, contains('/lib2.dart')); |
| 37 // Regular sources | 34 // Regular sources |
| 38 expect(libs, contains('/lib3.dart')); | 35 expect(libs, contains('/lib3.dart')); |
| 39 expect(libs, contains('/lib4.dart')); | 36 expect(libs, contains('/lib4.dart')); |
| 40 // Non-source, referenced by source | 37 // Non-source, referenced by source |
| 41 expect(libs, contains('/lib5.dart')); | 38 expect(libs, contains('/lib5.dart')); |
| 42 // Non-source, referenced by non-source | 39 // Non-source, referenced by non-source |
| 43 expect(libs, contains('/lib6.dart')); | 40 expect(libs, contains('/lib6.dart')); |
| 44 } | 41 } |
| 45 | 42 |
| 46 test_PackageMaps() { | 43 test_PackageMaps() { |
| 47 //TODO(pquitslund): add test | 44 //TODO(pquitslund): add test |
| 48 } | 45 } |
| 49 | |
| 50 void _performAnalysis() { | |
| 51 while (context.performAnalysisTask().hasMoreWork) {} | |
| 52 } | |
| 53 } | 46 } |
| OLD | NEW |