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

Side by Side Diff: pkg/barback/test/package_graph/source_test.dart

Issue 19473002: Fix a barback bug that triggered when an asset was removed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 barback.test.package_graph.source_test; 5 library barback.test.package_graph.source_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
11 11
12 import '../utils.dart'; 12 import '../utils.dart';
13 13
14 main() { 14 main() {
15 initConfig(); 15 initConfig();
16 test("gets a source asset", () { 16 test("gets a source asset", () {
17 initGraph(["app|foo.txt"]); 17 initGraph(["app|foo.txt"]);
18 updateSources(["app|foo.txt"]); 18 updateSources(["app|foo.txt"]);
19 expectAsset("app|foo.txt"); 19 expectAsset("app|foo.txt");
20 buildShouldSucceed();
20 }); 21 });
21 22
22 test("doesn't get an unknown source", () { 23 test("doesn't get an unknown source", () {
23 initGraph(); 24 initGraph();
24 expectNoAsset("app|unknown.txt"); 25 expectNoAsset("app|unknown.txt");
25 }); 26 });
26 27
27 test("doesn't get an unprovided source", () { 28 test("doesn't get an unprovided source", () {
28 initGraph(); 29 initGraph();
29 updateSources(["app|unknown.txt"]); 30 updateSources(["app|unknown.txt"]);
(...skipping 12 matching lines...) Expand all
42 expectNoAsset("app|foo.txt"); 43 expectNoAsset("app|foo.txt");
43 }); 44 });
44 45
45 test("gets a source asset if not transformed", () { 46 test("gets a source asset if not transformed", () {
46 initGraph(["app|foo.txt"], {"app": [ 47 initGraph(["app|foo.txt"], {"app": [
47 [new RewriteTransformer("nottxt", "whatever")] 48 [new RewriteTransformer("nottxt", "whatever")]
48 ]}); 49 ]});
49 50
50 updateSources(["app|foo.txt"]); 51 updateSources(["app|foo.txt"]);
51 expectAsset("app|foo.txt"); 52 expectAsset("app|foo.txt");
53 buildShouldSucceed();
52 }); 54 });
53 55
54 test("doesn't get a removed source", () { 56 test("doesn't get a removed source", () {
55 initGraph(["app|foo.txt"]); 57 initGraph(["app|foo.txt"]);
56 58
57 updateSources(["app|foo.txt"]); 59 updateSources(["app|foo.txt"]);
58 expectAsset("app|foo.txt"); 60 expectAsset("app|foo.txt");
61 buildShouldSucceed();
59 62
60 schedule(() { 63 schedule(() {
61 removeSources(["app|foo.txt"]); 64 removeSources(["app|foo.txt"]);
62 }); 65 });
63 66
64 expectNoAsset("app|foo.txt"); 67 expectNoAsset("app|foo.txt");
68 buildShouldSucceed();
65 }); 69 });
66 70
67 test("collapses redundant updates", () { 71 test("collapses redundant updates", () {
68 var transformer = new RewriteTransformer("blub", "blab"); 72 var transformer = new RewriteTransformer("blub", "blab");
69 initGraph(["app|foo.blub"], {"app": [[transformer]]}); 73 initGraph(["app|foo.blub"], {"app": [[transformer]]});
70 74
71 schedule(() { 75 schedule(() {
72 // Make a bunch of synchronous update calls. 76 // Make a bunch of synchronous update calls.
73 updateSources(["app|foo.blub"]); 77 updateSources(["app|foo.blub"]);
74 updateSources(["app|foo.blub"]); 78 updateSources(["app|foo.blub"]);
75 updateSources(["app|foo.blub"]); 79 updateSources(["app|foo.blub"]);
76 updateSources(["app|foo.blub"]); 80 updateSources(["app|foo.blub"]);
77 }); 81 });
78 82
79 expectAsset("app|foo.blab", "foo.blab"); 83 expectAsset("app|foo.blab", "foo.blab");
84 buildShouldSucceed();
80 85
81 schedule(() { 86 schedule(() {
82 expect(transformer.numRuns, equals(1)); 87 expect(transformer.numRuns, equals(1));
83 }); 88 });
84 }); 89 });
85 90
86 test("a removal cancels out an update", () { 91 test("a removal cancels out an update", () {
87 initGraph(["app|foo.txt"]); 92 initGraph(["app|foo.txt"]);
88 93
89 schedule(() { 94 schedule(() {
90 updateSources(["app|foo.txt"]); 95 updateSources(["app|foo.txt"]);
91 removeSources(["app|foo.txt"]); 96 removeSources(["app|foo.txt"]);
92 }); 97 });
93 98
94 expectNoAsset("app|foo.txt"); 99 expectNoAsset("app|foo.txt");
100 buildShouldSucceed();
95 }); 101 });
96 102
97 test("an update cancels out a removal", () { 103 test("an update cancels out a removal", () {
98 initGraph(["app|foo.txt"]); 104 initGraph(["app|foo.txt"]);
99 105
100 schedule(() { 106 schedule(() {
101 removeSources(["app|foo.txt"]); 107 removeSources(["app|foo.txt"]);
102 updateSources(["app|foo.txt"]); 108 updateSources(["app|foo.txt"]);
103 }); 109 });
104 110
105 expectAsset("app|foo.txt"); 111 expectAsset("app|foo.txt");
112 buildShouldSucceed();
106 }); 113 });
107 114
108 test("restarts a build if a source is updated while sources are loading", () { 115 test("restarts a build if a source is updated while sources are loading", () {
109 var transformer = new RewriteTransformer("txt", "out"); 116 var transformer = new RewriteTransformer("txt", "out");
110 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]}); 117 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]});
111 118
112 // Run the whole graph so all nodes are clean. 119 // Run the whole graph so all nodes are clean.
113 updateSources(["app|foo.txt", "app|other.bar"]); 120 updateSources(["app|foo.txt", "app|other.bar"]);
114 expectAsset("app|foo.out", "foo.out"); 121 expectAsset("app|foo.out", "foo.out");
115 expectAsset("app|other.bar"); 122 expectAsset("app|other.bar");
(...skipping 16 matching lines...) Expand all
132 resumeProvider(); 139 resumeProvider();
133 140
134 buildShouldSucceed(); 141 buildShouldSucceed();
135 waitForBuild(); 142 waitForBuild();
136 143
137 schedule(() { 144 schedule(() {
138 expect(transformer.numRuns, equals(2)); 145 expect(transformer.numRuns, equals(2));
139 }); 146 });
140 }); 147 });
141 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698