| OLD | NEW |
| 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 library test.domain.analysis; | 5 library test.domain.analysis; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/domain_analysis.dart'; | 11 import 'package:analysis_server/src/domain_analysis.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analysis_server/src/resource.dart'; | 13 import 'package:analysis_server/src/resource.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 15 import 'package:path/path.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 16 import 'package:unittest/unittest.dart'; |
| 16 | 17 |
| 17 import 'mocks.dart'; | 18 import 'mocks.dart'; |
| 18 import 'analysis_abstract.dart'; | 19 import 'analysis_abstract.dart'; |
| 19 import 'reflective_tests.dart'; | 20 import 'reflective_tests.dart'; |
| 20 | 21 |
| 21 | 22 |
| 22 main() { | 23 main() { |
| 23 groupSep = ' | '; | 24 groupSep = ' | '; |
| 24 | 25 |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 '''); | 587 '''); |
| 587 // create project and wait for analysis | 588 // create project and wait for analysis |
| 588 createProject(); | 589 createProject(); |
| 589 return waitForTasksFinished().then((_) { | 590 return waitForTasksFinished().then((_) { |
| 590 // if 'package:pkgA/libA.dart' was resolved, then there are no errors | 591 // if 'package:pkgA/libA.dart' was resolved, then there are no errors |
| 591 expect(filesErrors[testFile], isEmpty); | 592 expect(filesErrors[testFile], isEmpty); |
| 592 // packages file also was resolved | 593 // packages file also was resolved |
| 593 expect(filesErrors[pkgFile], isEmpty); | 594 expect(filesErrors[pkgFile], isEmpty); |
| 594 }); | 595 }); |
| 595 } | 596 } |
| 597 |
| 598 test_packageMapDependencies() { |
| 599 // Prepare a source file that has errors because it refers to an unknown |
| 600 // package. |
| 601 String pkgFile = '/packages/pkgA/libA.dart'; |
| 602 resourceProvider.newFile(pkgFile, ''' |
| 603 library lib_a; |
| 604 class A {} |
| 605 '''); |
| 606 addTestFile(''' |
| 607 import 'package:pkgA/libA.dart'; |
| 608 f(A a) { |
| 596 } | 609 } |
| 610 '''); |
| 611 String pkgDependency = posix.join(projectPath, 'package_dep'); |
| 612 resourceProvider.newFile(pkgDependency, 'contents'); |
| 613 packageMapProvider.dependencies.add(pkgDependency); |
| 614 // Create project and wait for analysis |
| 615 createProject(); |
| 616 return waitForTasksFinished().then((_) { |
| 617 expect(filesErrors[testFile], isNot(isEmpty)); |
| 618 // Add the package to the package map and tickle the package dependency. |
| 619 packageMapProvider.packageMap = { |
| 620 'pkgA': [resourceProvider.getResource('/packages/pkgA')] }; |
| 621 resourceProvider.modifyFile(pkgDependency, 'new contents'); |
| 622 // Let the server time to notice the file has changed, then let |
| 623 // analysis omplete. There should now be no error. |
| 624 return pumpEventQueue().then((_) => waitForTasksFinished()).then((_) { |
| 625 expect(filesErrors[testFile], isEmpty); |
| 626 }); |
| 627 }); |
| 628 } |
| 629 } |
| OLD | NEW |