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

Side by Side Diff: test/dependency_graph_test.dart

Issue 1266483003: format with dart_style 0.2.0-rc.3 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « test/codegen_test.dart ('k') | test/report_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dev_compiler.test.dependency_graph_test; 5 library dev_compiler.test.dependency_graph_test;
6 6
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 expect(node.scripts.first, nodeOf('/a2.dart')); 105 expect(node.scripts.first, nodeOf('/a2.dart'));
106 }); 106 });
107 107
108 test('add more deps', () { 108 test('add more deps', () {
109 // After initial load, dependencies are 1: 109 // After initial load, dependencies are 1:
110 var node = nodeOf('/index2.html'); 110 var node = nodeOf('/index2.html');
111 node.update(); 111 node.update();
112 expect(node.scripts.length, 1); 112 expect(node.scripts.length, 1);
113 expect(node.scripts.first, nodeOf('/a1.dart')); 113 expect(node.scripts.first, nodeOf('/a1.dart'));
114 114
115 updateFile(node.source, node.source.contents.data + 115 updateFile(
116 '<script type="application/dart" src="a2.dart"></script>'); 116 node.source,
117 node.source.contents.data +
118 '<script type="application/dart" src="a2.dart"></script>');
117 expect(node.scripts.length, 1); 119 expect(node.scripts.length, 1);
118 node.update(); 120 node.update();
119 expect(node.scripts.length, 2); 121 expect(node.scripts.length, 2);
120 expect(node.scripts.first, nodeOf('/a1.dart')); 122 expect(node.scripts.first, nodeOf('/a1.dart'));
121 expect(node.scripts.last, nodeOf('/a2.dart')); 123 expect(node.scripts.last, nodeOf('/a2.dart'));
122 }); 124 });
123 125
124 test('remove all deps', () { 126 test('remove all deps', () {
125 // After initial load, dependencies are 1: 127 // After initial load, dependencies are 1:
126 var node = nodeOf('/index2.html'); 128 var node = nodeOf('/index2.html');
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 var node = nodeOf('/a2.dart'); 210 var node = nodeOf('/a2.dart');
209 node.update(); 211 node.update();
210 expect(node.imports.length, 2); 212 expect(node.imports.length, 2);
211 expect(node.exports.length, 1); 213 expect(node.exports.length, 1);
212 expect(node.parts.length, 1); 214 expect(node.parts.length, 1);
213 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue); 215 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue);
214 expect(node.imports.contains(nodeOf('/a4.dart')), isTrue); 216 expect(node.imports.contains(nodeOf('/a4.dart')), isTrue);
215 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue); 217 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue);
216 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue); 218 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue);
217 219
218 updateFile(node.source, ''' 220 updateFile(
221 node.source,
222 '''
219 library a2; 223 library a2;
220 import 'a3.dart'; 224 import 'a3.dart';
221 import 'a4.dart'; 225 import 'a4.dart';
222 export 'a5.dart'; 226 export 'a5.dart';
223 import 'a6.dart'; // changed from part 227 import 'a6.dart'; // changed from part
224 '''); 228 ''');
225 var a6 = nodeOf('/a6.dart'); 229 var a6 = nodeOf('/a6.dart');
226 updateFile(a6.source, ''); 230 updateFile(a6.source, '');
227 node.update(); 231 node.update();
228 232
(...skipping 20 matching lines...) Expand all
249 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue); 253 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue);
250 expect(node.imports.contains(nodeOf('/a4.dart')), isTrue); 254 expect(node.imports.contains(nodeOf('/a4.dart')), isTrue);
251 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue); 255 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue);
252 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue); 256 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue);
253 257
254 a4.update(); 258 a4.update();
255 expect(a4.imports.length, 0); 259 expect(a4.imports.length, 0);
256 expect(a4.exports.length, 1); 260 expect(a4.exports.length, 1);
257 expect(a4.parts.length, 0); 261 expect(a4.parts.length, 0);
258 262
259 updateFile(node.source, ''' 263 updateFile(
264 node.source,
265 '''
260 library a2; 266 library a2;
261 import 'a3.dart'; 267 import 'a3.dart';
262 part 'a4.dart'; // changed from export 268 part 'a4.dart'; // changed from export
263 export 'a5.dart'; 269 export 'a5.dart';
264 part 'a6.dart'; 270 part 'a6.dart';
265 '''); 271 ''');
266 node.update(); 272 node.update();
267 273
268 expect(node.imports.length, 1); 274 expect(node.imports.length, 1);
269 expect(node.exports.length, 1); 275 expect(node.exports.length, 1);
270 expect(node.parts.length, 2); 276 expect(node.parts.length, 2);
271 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue); 277 expect(node.imports.contains(nodeOf('/a3.dart')), isTrue);
272 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue); 278 expect(node.exports.contains(nodeOf('/a5.dart')), isTrue);
273 expect(node.parts.contains(nodeOf('/a4.dart')), isTrue); 279 expect(node.parts.contains(nodeOf('/a4.dart')), isTrue);
274 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue); 280 expect(node.parts.contains(nodeOf('/a6.dart')), isTrue);
275 281
276 // Note, technically we never modified the contents of a4 and it contains 282 // Note, technically we never modified the contents of a4 and it contains
277 // an export. This is invalid Dart, but we'll let the analyzer report that 283 // an export. This is invalid Dart, but we'll let the analyzer report that
278 // error instead of doing so ourselves. 284 // error instead of doing so ourselves.
279 expect(a4.imports.length, 0); 285 expect(a4.imports.length, 0);
280 expect(a4.exports.length, 1); 286 expect(a4.exports.length, 1);
281 expect(a4.parts.length, 0); 287 expect(a4.parts.length, 0);
282 288
283 // And change it back. 289 // And change it back.
284 updateFile(node.source, ''' 290 updateFile(
291 node.source,
292 '''
285 library a2; 293 library a2;
286 import 'a3.dart'; 294 import 'a3.dart';
287 import 'a4.dart'; // changed again 295 import 'a4.dart'; // changed again
288 export 'a5.dart'; 296 export 'a5.dart';
289 part 'a6.dart'; 297 part 'a6.dart';
290 '''); 298 ''');
291 node.update(); 299 node.update();
292 expect(node.imports.contains(a4), isTrue); 300 expect(node.imports.contains(a4), isTrue);
293 expect(a4.imports.length, 0); 301 expect(a4.imports.length, 0);
294 expect(a4.exports.length, 1); 302 expect(a4.exports.length, 1);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 node.update(); 398 node.update();
391 expect(node.structureChanged, isFalse); 399 expect(node.structureChanged, isFalse);
392 400
393 // This change will not include new script tags: 401 // This change will not include new script tags:
394 updateFile(node.source, node.source.contents.data + '<div></div>'); 402 updateFile(node.source, node.source.contents.data + '<div></div>');
395 expect(node.structureChanged, isFalse); 403 expect(node.structureChanged, isFalse);
396 node.update(); 404 node.update();
397 expect(node.structureChanged, isFalse); 405 expect(node.structureChanged, isFalse);
398 expect(node.scripts.length, 1); 406 expect(node.scripts.length, 1);
399 407
400 updateFile(node.source, node.source.contents.data + 408 updateFile(
401 '<script type="application/dart" src="a4.dart"></script>'); 409 node.source,
410 node.source.contents.data +
411 '<script type="application/dart" src="a4.dart"></script>');
402 expect(node.structureChanged, isFalse); 412 expect(node.structureChanged, isFalse);
403 node.update(); 413 node.update();
404 expect(node.structureChanged, isTrue); 414 expect(node.structureChanged, isTrue);
405 expect(node.scripts.length, 2); 415 expect(node.scripts.length, 2);
406 }); 416 });
407 417
408 test('no mod in Dart', () { 418 test('no mod in Dart', () {
409 var node = nodeOf('/a2.dart'); 419 var node = nodeOf('/a2.dart');
410 var importNode = nodeOf('/a3.dart'); 420 var importNode = nodeOf('/a3.dart');
411 var exportNode = nodeOf('/a5.dart'); 421 var exportNode = nodeOf('/a5.dart');
(...skipping 19 matching lines...) Expand all
431 test('same directives, different order', () { 441 test('same directives, different order', () {
432 var node = nodeOf('/a2.dart'); 442 var node = nodeOf('/a2.dart');
433 node.update(); 443 node.update();
434 expect(node.structureChanged, isTrue); 444 expect(node.structureChanged, isTrue);
435 node.structureChanged = false; 445 node.structureChanged = false;
436 446
437 node.update(); 447 node.update();
438 expect(node.structureChanged, isFalse); 448 expect(node.structureChanged, isFalse);
439 449
440 // modified order of imports, but structure stays the same: 450 // modified order of imports, but structure stays the same:
441 updateFile(node.source, 'import "a4.dart"; import "a3.dart"; ' 451 updateFile(
452 node.source,
453 'import "a4.dart"; import "a3.dart"; '
442 'export "a5.dart"; part "a6.dart";'); 454 'export "a5.dart"; part "a6.dart";');
443 node.update(); 455 node.update();
444 456
445 expect(node.structureChanged, isFalse); 457 expect(node.structureChanged, isFalse);
446 node.update(); 458 node.update();
447 expect(node.structureChanged, isFalse); 459 expect(node.structureChanged, isFalse);
448 }); 460 });
449 461
450 test('changed parts', () { 462 test('changed parts', () {
451 var node = nodeOf('/a2.dart'); 463 var node = nodeOf('/a2.dart');
452 node.update(); 464 node.update();
453 expect(node.structureChanged, isTrue); 465 expect(node.structureChanged, isTrue);
454 node.structureChanged = false; 466 node.structureChanged = false;
455 467
456 node.update(); 468 node.update();
457 expect(node.structureChanged, isFalse); 469 expect(node.structureChanged, isFalse);
458 470
459 // added one. 471 // added one.
460 updateFile(node.source, 'import "a4.dart"; import "a3.dart"; ' 472 updateFile(
473 node.source,
474 'import "a4.dart"; import "a3.dart"; '
461 'export "a5.dart"; part "a6.dart"; part "a7.dart";'); 475 'export "a5.dart"; part "a6.dart"; part "a7.dart";');
462 expect(node.structureChanged, isFalse); 476 expect(node.structureChanged, isFalse);
463 node.update(); 477 node.update();
464 expect(node.structureChanged, isTrue); 478 expect(node.structureChanged, isTrue);
465 479
466 // no change 480 // no change
467 node.structureChanged = false; 481 node.structureChanged = false;
468 updateFile(node.source); 482 updateFile(node.source);
469 node.update(); 483 node.update();
470 expect(node.structureChanged, isFalse); 484 expect(node.structureChanged, isFalse);
471 485
472 // removed one 486 // removed one
473 updateFile(node.source); 487 updateFile(node.source);
474 updateFile(node.source, 'import "a4.dart"; import "a3.dart"; ' 488 updateFile(
489 node.source,
490 'import "a4.dart"; import "a3.dart"; '
475 'export "a5.dart"; part "a7.dart";'); 491 'export "a5.dart"; part "a7.dart";');
476 expect(node.structureChanged, isFalse); 492 expect(node.structureChanged, isFalse);
477 node.update(); 493 node.update();
478 expect(node.structureChanged, isTrue); 494 expect(node.structureChanged, isTrue);
479 }); 495 });
480 496
481 test('changed import', () { 497 test('changed import', () {
482 var node = nodeOf('/a2.dart'); 498 var node = nodeOf('/a2.dart');
483 node.update(); 499 node.update();
484 expect(node.structureChanged, isTrue); 500 expect(node.structureChanged, isTrue);
485 node.structureChanged = false; 501 node.structureChanged = false;
486 502
487 node.update(); 503 node.update();
488 expect(node.structureChanged, isFalse); 504 expect(node.structureChanged, isFalse);
489 505
490 // added one. 506 // added one.
491 updateFile(node.source, 507 updateFile(
508 node.source,
492 'import "a4.dart"; import "a3.dart"; import "a7.dart";' 509 'import "a4.dart"; import "a3.dart"; import "a7.dart";'
493 'export "a5.dart"; part "a6.dart";'); 510 'export "a5.dart"; part "a6.dart";');
494 expect(node.structureChanged, isFalse); 511 expect(node.structureChanged, isFalse);
495 node.update(); 512 node.update();
496 expect(node.structureChanged, isTrue); 513 expect(node.structureChanged, isTrue);
497 514
498 // no change 515 // no change
499 node.structureChanged = false; 516 node.structureChanged = false;
500 updateFile(node.source); 517 updateFile(node.source);
501 node.update(); 518 node.update();
502 expect(node.structureChanged, isFalse); 519 expect(node.structureChanged, isFalse);
503 520
504 // removed one 521 // removed one
505 updateFile(node.source, 'import "a4.dart"; import "a7.dart"; ' 522 updateFile(
523 node.source,
524 'import "a4.dart"; import "a7.dart"; '
506 'export "a5.dart"; part "a6.dart";'); 525 'export "a5.dart"; part "a6.dart";');
507 expect(node.structureChanged, isFalse); 526 expect(node.structureChanged, isFalse);
508 node.update(); 527 node.update();
509 expect(node.structureChanged, isTrue); 528 expect(node.structureChanged, isTrue);
510 }); 529 });
511 530
512 test('changed exports', () { 531 test('changed exports', () {
513 var node = nodeOf('/a2.dart'); 532 var node = nodeOf('/a2.dart');
514 node.update(); 533 node.update();
515 expect(node.structureChanged, isTrue); 534 expect(node.structureChanged, isTrue);
516 node.structureChanged = false; 535 node.structureChanged = false;
517 536
518 node.update(); 537 node.update();
519 expect(node.structureChanged, isFalse); 538 expect(node.structureChanged, isFalse);
520 539
521 // added one. 540 // added one.
522 updateFile(node.source, 'import "a4.dart"; import "a3.dart";' 541 updateFile(
542 node.source,
543 'import "a4.dart"; import "a3.dart";'
523 'export "a5.dart"; export "a9.dart"; part "a6.dart";'); 544 'export "a5.dart"; export "a9.dart"; part "a6.dart";');
524 expect(node.structureChanged, isFalse); 545 expect(node.structureChanged, isFalse);
525 node.update(); 546 node.update();
526 expect(node.structureChanged, isTrue); 547 expect(node.structureChanged, isTrue);
527 548
528 // no change 549 // no change
529 node.structureChanged = false; 550 node.structureChanged = false;
530 updateFile(node.source); 551 updateFile(node.source);
531 node.update(); 552 node.update();
532 expect(node.structureChanged, isFalse); 553 expect(node.structureChanged, isFalse);
533 554
534 // removed one 555 // removed one
535 updateFile(node.source, 'import "a4.dart"; import "a3.dart"; ' 556 updateFile(
557 node.source,
558 'import "a4.dart"; import "a3.dart"; '
536 'export "a5.dart"; part "a6.dart";'); 559 'export "a5.dart"; part "a6.dart";');
537 expect(node.structureChanged, isFalse); 560 expect(node.structureChanged, isFalse);
538 node.update(); 561 node.update();
539 expect(node.structureChanged, isTrue); 562 expect(node.structureChanged, isTrue);
540 }); 563 });
541 }); 564 });
542 }); 565 });
543 566
544 group('refresh structure and marks', () { 567 group('refresh structure and marks', () {
545 test('initial marks', () { 568 test('initial marks', () {
546 var node = nodeOf('/index3.html'); 569 var node = nodeOf('/index3.html');
547 expectGraph(node, ''' 570 expectGraph(
571 node,
572 '''
548 index3.html 573 index3.html
549 $_RUNTIME_GRAPH 574 $_RUNTIME_GRAPH
550 '''); 575 ''');
551 refreshStructureAndMarks(node); 576 refreshStructureAndMarks(node);
552 expectGraph(node, ''' 577 expectGraph(
578 node,
579 '''
553 index3.html [needs-rebuild] [structure-changed] 580 index3.html [needs-rebuild] [structure-changed]
554 |-- a2.dart [needs-rebuild] [structure-changed] 581 |-- a2.dart [needs-rebuild] [structure-changed]
555 | |-- a3.dart [needs-rebuild] 582 | |-- a3.dart [needs-rebuild]
556 | |-- a4.dart [needs-rebuild] [structure-changed] 583 | |-- a4.dart [needs-rebuild] [structure-changed]
557 | | |-- a10.dart [needs-rebuild] 584 | | |-- a10.dart [needs-rebuild]
558 | |-- a5.dart [needs-rebuild] 585 | |-- a5.dart [needs-rebuild]
559 | |-- a6.dart (part) [needs-rebuild] 586 | |-- a6.dart (part) [needs-rebuild]
560 $_RUNTIME_GRAPH_REBUILD 587 $_RUNTIME_GRAPH_REBUILD
561 '''); 588 ''');
562 }); 589 });
563 590
564 test('cleared marks stay clear', () { 591 test('cleared marks stay clear', () {
565 var node = nodeOf('/index3.html'); 592 var node = nodeOf('/index3.html');
566 refreshStructureAndMarks(node); 593 refreshStructureAndMarks(node);
567 expectGraph(node, ''' 594 expectGraph(
595 node,
596 '''
568 index3.html [needs-rebuild] [structure-changed] 597 index3.html [needs-rebuild] [structure-changed]
569 |-- a2.dart [needs-rebuild] [structure-changed] 598 |-- a2.dart [needs-rebuild] [structure-changed]
570 | |-- a3.dart [needs-rebuild] 599 | |-- a3.dart [needs-rebuild]
571 | |-- a4.dart [needs-rebuild] [structure-changed] 600 | |-- a4.dart [needs-rebuild] [structure-changed]
572 | | |-- a10.dart [needs-rebuild] 601 | | |-- a10.dart [needs-rebuild]
573 | |-- a5.dart [needs-rebuild] 602 | |-- a5.dart [needs-rebuild]
574 | |-- a6.dart (part) [needs-rebuild] 603 | |-- a6.dart (part) [needs-rebuild]
575 $_RUNTIME_GRAPH_REBUILD 604 $_RUNTIME_GRAPH_REBUILD
576 '''); 605 ''');
577 clearMarks(node); 606 clearMarks(node);
578 expectGraph(node, ''' 607 expectGraph(
608 node,
609 '''
579 index3.html 610 index3.html
580 |-- a2.dart 611 |-- a2.dart
581 | |-- a3.dart 612 | |-- a3.dart
582 | |-- a4.dart 613 | |-- a4.dart
583 | | |-- a10.dart 614 | | |-- a10.dart
584 | |-- a5.dart 615 | |-- a5.dart
585 | |-- a6.dart (part) 616 | |-- a6.dart (part)
586 $_RUNTIME_GRAPH 617 $_RUNTIME_GRAPH
587 '''); 618 ''');
588 619
589 refreshStructureAndMarks(node); 620 refreshStructureAndMarks(node);
590 expectGraph(node, ''' 621 expectGraph(
622 node,
623 '''
591 index3.html 624 index3.html
592 |-- a2.dart 625 |-- a2.dart
593 | |-- a3.dart 626 | |-- a3.dart
594 | |-- a4.dart 627 | |-- a4.dart
595 | | |-- a10.dart 628 | | |-- a10.dart
596 | |-- a5.dart 629 | |-- a5.dart
597 | |-- a6.dart (part) 630 | |-- a6.dart (part)
598 $_RUNTIME_GRAPH 631 $_RUNTIME_GRAPH
599 '''); 632 ''');
600 }); 633 });
601 634
602 test('needsRebuild mark updated on local modifications', () { 635 test('needsRebuild mark updated on local modifications', () {
603 var node = nodeOf('/index3.html'); 636 var node = nodeOf('/index3.html');
604 refreshStructureAndMarks(node); 637 refreshStructureAndMarks(node);
605 clearMarks(node); 638 clearMarks(node);
606 var a3 = nodeOf('/a3.dart'); 639 var a3 = nodeOf('/a3.dart');
607 updateFile(a3.source); 640 updateFile(a3.source);
608 641
609 refreshStructureAndMarks(node); 642 refreshStructureAndMarks(node);
610 expectGraph(node, ''' 643 expectGraph(
644 node,
645 '''
611 index3.html 646 index3.html
612 |-- a2.dart 647 |-- a2.dart
613 | |-- a3.dart [needs-rebuild] 648 | |-- a3.dart [needs-rebuild]
614 | |-- a4.dart 649 | |-- a4.dart
615 | | |-- a10.dart 650 | | |-- a10.dart
616 | |-- a5.dart 651 | |-- a5.dart
617 | |-- a6.dart (part) 652 | |-- a6.dart (part)
618 $_RUNTIME_GRAPH 653 $_RUNTIME_GRAPH
619 '''); 654 ''');
620 }); 655 });
621 656
622 test('structuredChanged mark updated on structure modifications', () { 657 test('structuredChanged mark updated on structure modifications', () {
623 var node = nodeOf('/index3.html'); 658 var node = nodeOf('/index3.html');
624 refreshStructureAndMarks(node); 659 refreshStructureAndMarks(node);
625 clearMarks(node); 660 clearMarks(node);
626 var a5 = nodeOf('/a5.dart'); 661 var a5 = nodeOf('/a5.dart');
627 updateFile(a5.source, 'import "a8.dart";'); 662 updateFile(a5.source, 'import "a8.dart";');
628 663
629 refreshStructureAndMarks(node); 664 refreshStructureAndMarks(node);
630 expectGraph(node, ''' 665 expectGraph(
666 node,
667 '''
631 index3.html 668 index3.html
632 |-- a2.dart 669 |-- a2.dart
633 | |-- a3.dart 670 | |-- a3.dart
634 | |-- a4.dart 671 | |-- a4.dart
635 | | |-- a10.dart 672 | | |-- a10.dart
636 | |-- a5.dart [needs-rebuild] [structure-changed] 673 | |-- a5.dart [needs-rebuild] [structure-changed]
637 | | |-- a8.dart [needs-rebuild] [structure-changed] 674 | | |-- a8.dart [needs-rebuild] [structure-changed]
638 | | | |-- a8.dart... 675 | | | |-- a8.dart...
639 | |-- a6.dart (part) 676 | |-- a6.dart (part)
640 $_RUNTIME_GRAPH 677 $_RUNTIME_GRAPH
641 '''); 678 ''');
642 }); 679 });
643 }); 680 });
644 681
645 group('server-mode', () { 682 group('server-mode', () {
646 setUp(() { 683 setUp(() {
647 var opts = new CompilerOptions( 684 var opts = new CompilerOptions(
648 runtimeDir: '/dev_compiler_runtime/', 685 runtimeDir: '/dev_compiler_runtime/',
649 sourceOptions: new SourceResolverOptions(useMockSdk: true), 686 sourceOptions: new SourceResolverOptions(useMockSdk: true),
650 serverMode: true); 687 serverMode: true);
651 context = createAnalysisContextWithSources( 688 context = createAnalysisContextWithSources(
652 opts.strongOptions, opts.sourceOptions, 689 opts.strongOptions, opts.sourceOptions,
653 fileResolvers: [testUriResolver]); 690 fileResolvers: [testUriResolver]);
654 graph = new SourceGraph(context, new LogReporter(context), opts); 691 graph = new SourceGraph(context, new LogReporter(context), opts);
655 }); 692 });
656 693
657 test('messages widget is automatically included', () { 694 test('messages widget is automatically included', () {
658 var node = nodeOf('/index3.html'); 695 var node = nodeOf('/index3.html');
659 expectGraph(node, ''' 696 expectGraph(
697 node,
698 '''
660 index3.html 699 index3.html
661 $_RUNTIME_GRAPH 700 $_RUNTIME_GRAPH
662 |-- messages_widget.js 701 |-- messages_widget.js
663 |-- messages.css 702 |-- messages.css
664 '''); 703 ''');
665 refreshStructureAndMarks(node); 704 refreshStructureAndMarks(node);
666 expectGraph(node, ''' 705 expectGraph(
706 node,
707 '''
667 index3.html [needs-rebuild] [structure-changed] 708 index3.html [needs-rebuild] [structure-changed]
668 |-- a2.dart [needs-rebuild] [structure-changed] 709 |-- a2.dart [needs-rebuild] [structure-changed]
669 | |-- a3.dart [needs-rebuild] 710 | |-- a3.dart [needs-rebuild]
670 | |-- a4.dart [needs-rebuild] [structure-changed] 711 | |-- a4.dart [needs-rebuild] [structure-changed]
671 | | |-- a10.dart [needs-rebuild] 712 | | |-- a10.dart [needs-rebuild]
672 | |-- a5.dart [needs-rebuild] 713 | |-- a5.dart [needs-rebuild]
673 | |-- a6.dart (part) [needs-rebuild] 714 | |-- a6.dart (part) [needs-rebuild]
674 $_RUNTIME_GRAPH_REBUILD 715 $_RUNTIME_GRAPH_REBUILD
675 |-- messages_widget.js [needs-rebuild] 716 |-- messages_widget.js [needs-rebuild]
676 |-- messages.css [needs-rebuild] 717 |-- messages.css [needs-rebuild]
(...skipping 21 matching lines...) Expand all
698 739
699 test('everything build on first run', () { 740 test('everything build on first run', () {
700 var node = nodeOf('/index3.html'); 741 var node = nodeOf('/index3.html');
701 rebuild(node, buildNoTransitiveChange); 742 rebuild(node, buildNoTransitiveChange);
702 // Note: a6.dart is not included because it built as part of a2.dart 743 // Note: a6.dart is not included because it built as part of a2.dart
703 expect(results, ['a3.dart', 'a10.dart', 'a4.dart', 'a5.dart', 'a2.dart'] 744 expect(results, ['a3.dart', 'a10.dart', 'a4.dart', 'a5.dart', 'a2.dart']
704 ..addAll(runtimeFilesWithoutPath) 745 ..addAll(runtimeFilesWithoutPath)
705 ..add('index3.html')); 746 ..add('index3.html'));
706 747
707 // Marks are removed automatically by rebuild 748 // Marks are removed automatically by rebuild
708 expectGraph(node, ''' 749 expectGraph(
750 node,
751 '''
709 index3.html 752 index3.html
710 |-- a2.dart 753 |-- a2.dart
711 | |-- a3.dart 754 | |-- a3.dart
712 | |-- a4.dart 755 | |-- a4.dart
713 | | |-- a10.dart 756 | | |-- a10.dart
714 | |-- a5.dart 757 | |-- a5.dart
715 | |-- a6.dart (part) 758 | |-- a6.dart (part)
716 $_RUNTIME_GRAPH 759 $_RUNTIME_GRAPH
717 '''); 760 ''');
718 }); 761 });
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 // (b) change directive from part to import (or viceversa) 890 // (b) change directive from part to import (or viceversa)
848 // These could happen in any order and we should reach a consistent state 891 // These could happen in any order and we should reach a consistent state
849 // in the end. 892 // in the end.
850 893
851 test('convert part to a library before updating the import', () { 894 test('convert part to a library before updating the import', () {
852 var node = nodeOf('/index3.html'); 895 var node = nodeOf('/index3.html');
853 var a2 = nodeOf('/a2.dart'); 896 var a2 = nodeOf('/a2.dart');
854 var a6 = nodeOf('/a6.dart'); 897 var a6 = nodeOf('/a6.dart');
855 rebuild(node, buildNoTransitiveChange); 898 rebuild(node, buildNoTransitiveChange);
856 899
857 expectGraph(node, ''' 900 expectGraph(
901 node,
902 '''
858 index3.html 903 index3.html
859 |-- a2.dart 904 |-- a2.dart
860 | |-- a3.dart 905 | |-- a3.dart
861 | |-- a4.dart 906 | |-- a4.dart
862 | | |-- a10.dart 907 | | |-- a10.dart
863 | |-- a5.dart 908 | |-- a5.dart
864 | |-- a6.dart (part) 909 | |-- a6.dart (part)
865 $_RUNTIME_GRAPH 910 $_RUNTIME_GRAPH
866 '''); 911 ''');
867 912
868 // Modify the file first: 913 // Modify the file first:
869 updateFile(a6.source, 'library a6; import "a5.dart";'); 914 updateFile(a6.source, 'library a6; import "a5.dart";');
870 results = []; 915 results = [];
871 rebuild(node, buildNoTransitiveChange); 916 rebuild(node, buildNoTransitiveChange);
872 917
873 // Looks to us like a change in a part, we'll report errors that the 918 // Looks to us like a change in a part, we'll report errors that the
874 // part is not really a part-file. Note that a6.dart is not included 919 // part is not really a part-file. Note that a6.dart is not included
875 // below, because we don't build it as a library. 920 // below, because we don't build it as a library.
876 expect(results, ['a2.dart']); 921 expect(results, ['a2.dart']);
877 expectGraph(node, ''' 922 expectGraph(
923 node,
924 '''
878 index3.html 925 index3.html
879 |-- a2.dart 926 |-- a2.dart
880 | |-- a3.dart 927 | |-- a3.dart
881 | |-- a4.dart 928 | |-- a4.dart
882 | | |-- a10.dart 929 | | |-- a10.dart
883 | |-- a5.dart 930 | |-- a5.dart
884 | |-- a6.dart (part) 931 | |-- a6.dart (part)
885 $_RUNTIME_GRAPH 932 $_RUNTIME_GRAPH
886 '''); 933 ''');
887 934
888 updateFile(a2.source, ''' 935 updateFile(
936 a2.source,
937 '''
889 library a2; 938 library a2;
890 import 'a3.dart'; 939 import 'a3.dart';
891 import 'a4.dart'; 940 import 'a4.dart';
892 import 'a6.dart'; // properly import it 941 import 'a6.dart'; // properly import it
893 export 'a5.dart'; 942 export 'a5.dart';
894 '''); 943 ''');
895 results = []; 944 results = [];
896 rebuild(node, buildNoTransitiveChange); 945 rebuild(node, buildNoTransitiveChange);
897 // Note that a6 is now included, because we haven't built it as a 946 // Note that a6 is now included, because we haven't built it as a
898 // library until now: 947 // library until now:
899 expect(results, ['a6.dart', 'a2.dart', 'index3.html']); 948 expect(results, ['a6.dart', 'a2.dart', 'index3.html']);
900 949
901 updateFile(a6.source); 950 updateFile(a6.source);
902 results = []; 951 results = [];
903 rebuild(node, buildNoTransitiveChange); 952 rebuild(node, buildNoTransitiveChange);
904 expect(results, ['a6.dart']); 953 expect(results, ['a6.dart']);
905 954
906 expectGraph(node, ''' 955 expectGraph(
956 node,
957 '''
907 index3.html 958 index3.html
908 |-- a2.dart 959 |-- a2.dart
909 | |-- a3.dart 960 | |-- a3.dart
910 | |-- a4.dart 961 | |-- a4.dart
911 | | |-- a10.dart 962 | | |-- a10.dart
912 | |-- a6.dart 963 | |-- a6.dart
913 | | |-- a5.dart 964 | | |-- a5.dart
914 | |-- a5.dart... 965 | |-- a5.dart...
915 $_RUNTIME_GRAPH 966 $_RUNTIME_GRAPH
916 '''); 967 ''');
917 }); 968 });
918 969
919 test('convert part to a library after updating the import', () { 970 test('convert part to a library after updating the import', () {
920 var node = nodeOf('/index3.html'); 971 var node = nodeOf('/index3.html');
921 var a2 = nodeOf('/a2.dart'); 972 var a2 = nodeOf('/a2.dart');
922 var a6 = nodeOf('/a6.dart'); 973 var a6 = nodeOf('/a6.dart');
923 rebuild(node, buildNoTransitiveChange); 974 rebuild(node, buildNoTransitiveChange);
924 975
925 expectGraph(node, ''' 976 expectGraph(
977 node,
978 '''
926 index3.html 979 index3.html
927 |-- a2.dart 980 |-- a2.dart
928 | |-- a3.dart 981 | |-- a3.dart
929 | |-- a4.dart 982 | |-- a4.dart
930 | | |-- a10.dart 983 | | |-- a10.dart
931 | |-- a5.dart 984 | |-- a5.dart
932 | |-- a6.dart (part) 985 | |-- a6.dart (part)
933 $_RUNTIME_GRAPH 986 $_RUNTIME_GRAPH
934 '''); 987 ''');
935 988
936 updateFile(a2.source, ''' 989 updateFile(
990 a2.source,
991 '''
937 library a2; 992 library a2;
938 import 'a3.dart'; 993 import 'a3.dart';
939 import 'a4.dart'; 994 import 'a4.dart';
940 import 'a6.dart'; // properly import it 995 import 'a6.dart'; // properly import it
941 export 'a5.dart'; 996 export 'a5.dart';
942 '''); 997 ''');
943 results = []; 998 results = [];
944 rebuild(node, buildNoTransitiveChange); 999 rebuild(node, buildNoTransitiveChange);
945 expect(results, ['a6.dart', 'a2.dart', 'index3.html']); 1000 expect(results, ['a6.dart', 'a2.dart', 'index3.html']);
946 expectGraph(node, ''' 1001 expectGraph(
1002 node,
1003 '''
947 index3.html 1004 index3.html
948 |-- a2.dart 1005 |-- a2.dart
949 | |-- a3.dart 1006 | |-- a3.dart
950 | |-- a4.dart 1007 | |-- a4.dart
951 | | |-- a10.dart 1008 | | |-- a10.dart
952 | |-- a6.dart 1009 | |-- a6.dart
953 | |-- a5.dart 1010 | |-- a5.dart
954 $_RUNTIME_GRAPH 1011 $_RUNTIME_GRAPH
955 '''); 1012 ''');
956 1013
957 updateFile(a6.source, 'library a6; import "a5.dart";'); 1014 updateFile(a6.source, 'library a6; import "a5.dart";');
958 results = []; 1015 results = [];
959 rebuild(node, buildNoTransitiveChange); 1016 rebuild(node, buildNoTransitiveChange);
960 expect(results, ['a6.dart', 'index3.html']); 1017 expect(results, ['a6.dart', 'index3.html']);
961 expectGraph(node, ''' 1018 expectGraph(
1019 node,
1020 '''
962 index3.html 1021 index3.html
963 |-- a2.dart 1022 |-- a2.dart
964 | |-- a3.dart 1023 | |-- a3.dart
965 | |-- a4.dart 1024 | |-- a4.dart
966 | | |-- a10.dart 1025 | | |-- a10.dart
967 | |-- a6.dart 1026 | |-- a6.dart
968 | | |-- a5.dart 1027 | | |-- a5.dart
969 | |-- a5.dart... 1028 | |-- a5.dart...
970 $_RUNTIME_GRAPH 1029 $_RUNTIME_GRAPH
971 '''); 1030 ''');
972 }); 1031 });
973 1032
974 test('disconnect part making it a library', () { 1033 test('disconnect part making it a library', () {
975 var node = nodeOf('/index3.html'); 1034 var node = nodeOf('/index3.html');
976 var a2 = nodeOf('/a2.dart'); 1035 var a2 = nodeOf('/a2.dart');
977 var a6 = nodeOf('/a6.dart'); 1036 var a6 = nodeOf('/a6.dart');
978 rebuild(node, buildNoTransitiveChange); 1037 rebuild(node, buildNoTransitiveChange);
979 1038
980 expectGraph(node, ''' 1039 expectGraph(
1040 node,
1041 '''
981 index3.html 1042 index3.html
982 |-- a2.dart 1043 |-- a2.dart
983 | |-- a3.dart 1044 | |-- a3.dart
984 | |-- a4.dart 1045 | |-- a4.dart
985 | | |-- a10.dart 1046 | | |-- a10.dart
986 | |-- a5.dart 1047 | |-- a5.dart
987 | |-- a6.dart (part) 1048 | |-- a6.dart (part)
988 $_RUNTIME_GRAPH 1049 $_RUNTIME_GRAPH
989 '''); 1050 ''');
990 1051
991 updateFile(a2.source, ''' 1052 updateFile(
1053 a2.source,
1054 '''
992 library a2; 1055 library a2;
993 import 'a3.dart'; 1056 import 'a3.dart';
994 import 'a4.dart'; 1057 import 'a4.dart';
995 export 'a5.dart'; 1058 export 'a5.dart';
996 '''); 1059 ''');
997 updateFile(a6.source, 'library a6; import "a5.dart";'); 1060 updateFile(a6.source, 'library a6; import "a5.dart";');
998 results = []; 1061 results = [];
999 rebuild(node, buildNoTransitiveChange); 1062 rebuild(node, buildNoTransitiveChange);
1000 // a6 is not here, it's not reachable so we don't build it. 1063 // a6 is not here, it's not reachable so we don't build it.
1001 expect(results, ['a2.dart', 'index3.html']); 1064 expect(results, ['a2.dart', 'index3.html']);
1002 expectGraph(node, ''' 1065 expectGraph(
1066 node,
1067 '''
1003 index3.html 1068 index3.html
1004 |-- a2.dart 1069 |-- a2.dart
1005 | |-- a3.dart 1070 | |-- a3.dart
1006 | |-- a4.dart 1071 | |-- a4.dart
1007 | | |-- a10.dart 1072 | | |-- a10.dart
1008 | |-- a5.dart 1073 | |-- a5.dart
1009 $_RUNTIME_GRAPH 1074 $_RUNTIME_GRAPH
1010 '''); 1075 ''');
1011 }); 1076 });
1012 1077
1013 test('convert a library to a part', () { 1078 test('convert a library to a part', () {
1014 var node = nodeOf('/index3.html'); 1079 var node = nodeOf('/index3.html');
1015 var a2 = nodeOf('/a2.dart'); 1080 var a2 = nodeOf('/a2.dart');
1016 var a5 = nodeOf('/a5.dart'); 1081 var a5 = nodeOf('/a5.dart');
1017 rebuild(node, buildNoTransitiveChange); 1082 rebuild(node, buildNoTransitiveChange);
1018 1083
1019 expectGraph(node, ''' 1084 expectGraph(
1085 node,
1086 '''
1020 index3.html 1087 index3.html
1021 |-- a2.dart 1088 |-- a2.dart
1022 | |-- a3.dart 1089 | |-- a3.dart
1023 | |-- a4.dart 1090 | |-- a4.dart
1024 | | |-- a10.dart 1091 | | |-- a10.dart
1025 | |-- a5.dart 1092 | |-- a5.dart
1026 | |-- a6.dart (part) 1093 | |-- a6.dart (part)
1027 $_RUNTIME_GRAPH 1094 $_RUNTIME_GRAPH
1028 '''); 1095 ''');
1029 1096
1030 updateFile(a2.source, ''' 1097 updateFile(
1098 a2.source,
1099 '''
1031 library a2; 1100 library a2;
1032 import 'a3.dart'; 1101 import 'a3.dart';
1033 import 'a4.dart'; 1102 import 'a4.dart';
1034 part 'a5.dart'; // make it a part 1103 part 'a5.dart'; // make it a part
1035 part 'a6.dart'; 1104 part 'a6.dart';
1036 '''); 1105 ''');
1037 results = []; 1106 results = [];
1038 rebuild(node, buildNoTransitiveChange); 1107 rebuild(node, buildNoTransitiveChange);
1039 expect(results, ['a2.dart', 'index3.html']); 1108 expect(results, ['a2.dart', 'index3.html']);
1040 expectGraph(node, ''' 1109 expectGraph(
1110 node,
1111 '''
1041 index3.html 1112 index3.html
1042 |-- a2.dart 1113 |-- a2.dart
1043 | |-- a3.dart 1114 | |-- a3.dart
1044 | |-- a4.dart 1115 | |-- a4.dart
1045 | | |-- a10.dart 1116 | | |-- a10.dart
1046 | |-- a5.dart (part) 1117 | |-- a5.dart (part)
1047 | |-- a6.dart (part) 1118 | |-- a6.dart (part)
1048 $_RUNTIME_GRAPH 1119 $_RUNTIME_GRAPH
1049 '''); 1120 ''');
1050 1121
1051 updateFile(a5.source, 'part of a2;'); 1122 updateFile(a5.source, 'part of a2;');
1052 results = []; 1123 results = [];
1053 rebuild(node, buildNoTransitiveChange); 1124 rebuild(node, buildNoTransitiveChange);
1054 expect(results, ['a2.dart']); 1125 expect(results, ['a2.dart']);
1055 expectGraph(node, ''' 1126 expectGraph(
1127 node,
1128 '''
1056 index3.html 1129 index3.html
1057 |-- a2.dart 1130 |-- a2.dart
1058 | |-- a3.dart 1131 | |-- a3.dart
1059 | |-- a4.dart 1132 | |-- a4.dart
1060 | | |-- a10.dart 1133 | | |-- a10.dart
1061 | |-- a5.dart (part) 1134 | |-- a5.dart (part)
1062 | |-- a6.dart (part) 1135 | |-- a6.dart (part)
1063 $_RUNTIME_GRAPH 1136 $_RUNTIME_GRAPH
1064 '''); 1137 ''');
1065 }); 1138 });
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 helper(node); 1243 helper(node);
1171 return sb.toString(); 1244 return sb.toString();
1172 } 1245 }
1173 1246
1174 final runtimeFilesWithoutPath = defaultRuntimeFiles 1247 final runtimeFilesWithoutPath = defaultRuntimeFiles
1175 .map((f) => f.replaceAll('dart/', '')) 1248 .map((f) => f.replaceAll('dart/', ''))
1176 .toList(growable: false); 1249 .toList(growable: false);
1177 final _RUNTIME_GRAPH = runtimeFilesWithoutPath.map((s) => '|-- $s').join('\n'); 1250 final _RUNTIME_GRAPH = runtimeFilesWithoutPath.map((s) => '|-- $s').join('\n');
1178 final _RUNTIME_GRAPH_REBUILD = 1251 final _RUNTIME_GRAPH_REBUILD =
1179 runtimeFilesWithoutPath.map((s) => '|-- $s [needs-rebuild]').join('\n'); 1252 runtimeFilesWithoutPath.map((s) => '|-- $s [needs-rebuild]').join('\n');
OLDNEW
« no previous file with comments | « test/codegen_test.dart ('k') | test/report_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698