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

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1413273002: Library Cycle invalidation (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix some comments Created 5 years, 2 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) 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 library test.src.task.dart_test; 5 library test.src.task.dart_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 } 1464 }
1465 1465
1466 @reflectiveTest 1466 @reflectiveTest
1467 class ComputeLibraryCycleTaskTest extends _AbstractDartTaskTest { 1467 class ComputeLibraryCycleTaskTest extends _AbstractDartTaskTest {
1468 @override 1468 @override
1469 void setUp() { 1469 void setUp() {
1470 super.setUp(); 1470 super.setUp();
1471 enableStrongMode(); 1471 enableStrongMode();
1472 } 1472 }
1473 1473
1474 void test_library_cycle_incremental() {
1475 enableStrongMode();
1476 Source lib1Source = newSource(
1477 '/my_lib1.dart',
1478 '''
1479 library my_lib1;
1480 ''');
1481 Source lib2Source = newSource(
1482 '/my_lib2.dart',
1483 '''
1484 library my_lib2;
1485 import 'my_lib1.dart';
1486 ''');
1487 Source lib3Source = newSource(
1488 '/my_lib3.dart',
1489 '''
1490 library my_lib3;
1491 import 'my_lib2.dart';
1492 ''');
1493 AnalysisTarget lib1Target = new LibrarySpecificUnit(lib1Source, lib1Source);
1494 AnalysisTarget lib2Target = new LibrarySpecificUnit(lib2Source, lib2Source);
1495 AnalysisTarget lib3Target = new LibrarySpecificUnit(lib3Source, lib3Source);
1496 computeResult(lib1Target, LIBRARY_CYCLE);
1497 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1498 computeResult(lib2Target, LIBRARY_CYCLE);
1499 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1500 computeResult(lib3Target, LIBRARY_CYCLE);
1501 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1502
1503 // complete the cycle
1504 context.setContents(
1505 lib1Source,
1506 '''
1507 library my_lib1;
1508 import 'my_lib3.dart';
1509 ''');
1510 computeResult(lib1Target, LIBRARY_CYCLE);
1511 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1512 computeResult(lib2Target, LIBRARY_CYCLE);
1513 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1514 computeResult(lib3Target, LIBRARY_CYCLE);
1515 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1516
1517 // break the cycle again
1518 context.setContents(
1519 lib1Source,
1520 '''
1521 library my_lib1;
1522 ''');
1523 computeResult(lib1Target, LIBRARY_CYCLE);
1524 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1525 computeResult(lib2Target, LIBRARY_CYCLE);
1526 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1527 computeResult(lib3Target, LIBRARY_CYCLE);
1528 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1529 }
1530
1531 void test_library_cycle_incremental_partial() {
1532 enableStrongMode();
1533 Source lib1Source = newSource(
1534 '/my_lib1.dart',
1535 '''
1536 library my_lib1;
1537 ''');
1538 Source lib2Source = newSource(
1539 '/my_lib2.dart',
1540 '''
1541 library my_lib2;
1542 import 'my_lib1.dart';
1543 ''');
1544 Source lib3Source = newSource(
1545 '/my_lib3.dart',
1546 '''
1547 library my_lib3;
1548 import 'my_lib2.dart';
1549 ''');
1550 AnalysisTarget lib1Target = new LibrarySpecificUnit(lib1Source, lib1Source);
1551 AnalysisTarget lib2Target = new LibrarySpecificUnit(lib2Source, lib2Source);
1552 AnalysisTarget lib3Target = new LibrarySpecificUnit(lib3Source, lib3Source);
1553 computeResult(lib1Target, LIBRARY_CYCLE);
1554 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1555 computeResult(lib2Target, LIBRARY_CYCLE);
1556 expect(outputs[LIBRARY_CYCLE], hasLength(1));
1557 // lib3 is not reachable, so we have not yet computed its library
1558 // cycles
1559
1560 // complete the cycle, via lib3
1561 context.setContents(
1562 lib1Source,
1563 '''
1564 library my_lib1;
1565 import 'my_lib3.dart';
1566 ''');
1567 // Ensure that invalidation correctly invalidated everything reachable
1568 // through lib3
1569 computeResult(lib1Target, LIBRARY_CYCLE);
1570 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1571 computeResult(lib2Target, LIBRARY_CYCLE);
1572 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1573 computeResult(lib3Target, LIBRARY_CYCLE);
1574 expect(outputs[LIBRARY_CYCLE], hasLength(3));
1575 }
1576
1474 void test_library_cycle_linear() { 1577 void test_library_cycle_linear() {
1475 List<Source> sources = newSources({ 1578 List<Source> sources = newSources({
1476 '/a.dart': ''' 1579 '/a.dart': '''
1477 ''', 1580 ''',
1478 '/b.dart': ''' 1581 '/b.dart': '''
1479 import 'a.dart'; 1582 import 'a.dart';
1480 ''' 1583 '''
1481 }); 1584 });
1482 List<Map<ResultDescriptor, dynamic>> results = 1585 List<Map<ResultDescriptor, dynamic>> results =
1483 computeLibraryResultsMap(sources, LIBRARY_CYCLE); 1586 computeLibraryResultsMap(sources, LIBRARY_CYCLE);
(...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 /** 4412 /**
4310 * Fill [errorListener] with [result] errors in the current [task]. 4413 * Fill [errorListener] with [result] errors in the current [task].
4311 */ 4414 */
4312 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4415 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4313 List<AnalysisError> errors = task.outputs[result]; 4416 List<AnalysisError> errors = task.outputs[result];
4314 expect(errors, isNotNull, reason: result.name); 4417 expect(errors, isNotNull, reason: result.name);
4315 errorListener = new GatheringErrorListener(); 4418 errorListener = new GatheringErrorListener();
4316 errorListener.addAll(errors); 4419 errorListener.addAll(errors);
4317 } 4420 }
4318 } 4421 }
OLDNEW
« pkg/analyzer/lib/src/task/driver.dart ('K') | « pkg/analyzer/lib/task/model.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698