| OLD | NEW |
| 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.transform_test; | 5 library barback.test.package_graph.transform_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 transformed asset with a different path", () { | 16 test("gets a transformed asset with a different path", () { |
| 17 initGraph(["app|foo.blub"], {"app": [ | 17 initGraph(["app|foo.blub"], {"app": [ |
| 18 [new RewriteTransformer("blub", "blab")] | 18 [new RewriteTransformer("blub", "blab")] |
| 19 ]}); | 19 ]}); |
| 20 updateSources(["app|foo.blub"]); | 20 updateSources(["app|foo.blub"]); |
| 21 expectAsset("app|foo.blab", "foo.blab"); | 21 expectAsset("app|foo.blab", "foo.blab"); |
| 22 buildShouldSucceed(); |
| 22 }); | 23 }); |
| 23 | 24 |
| 24 test("gets a transformed asset with the same path", () { | 25 test("gets a transformed asset with the same path", () { |
| 25 initGraph(["app|foo.blub"], {"app": [ | 26 initGraph(["app|foo.blub"], {"app": [ |
| 26 [new RewriteTransformer("blub", "blub")] | 27 [new RewriteTransformer("blub", "blub")] |
| 27 ]}); | 28 ]}); |
| 28 updateSources(["app|foo.blub"]); | 29 updateSources(["app|foo.blub"]); |
| 29 expectAsset("app|foo.blub", "foo.blub"); | 30 expectAsset("app|foo.blub", "foo.blub"); |
| 31 buildShouldSucceed(); |
| 30 }); | 32 }); |
| 31 | 33 |
| 32 test("doesn't find an output from a later phase", () { | 34 test("doesn't find an output from a later phase", () { |
| 33 initGraph(["app|foo.a"], {"app": [ | 35 initGraph(["app|foo.a"], {"app": [ |
| 34 [new RewriteTransformer("b", "c")], | 36 [new RewriteTransformer("b", "c")], |
| 35 [new RewriteTransformer("a", "b")] | 37 [new RewriteTransformer("a", "b")] |
| 36 ]}); | 38 ]}); |
| 37 updateSources(["app|foo.a"]); | 39 updateSources(["app|foo.a"]); |
| 38 expectNoAsset("app|foo.c"); | 40 expectNoAsset("app|foo.c"); |
| 41 buildShouldSucceed(); |
| 39 }); | 42 }); |
| 40 | 43 |
| 41 test("doesn't find an output from the same phase", () { | 44 test("doesn't find an output from the same phase", () { |
| 42 initGraph(["app|foo.a"], {"app": [ | 45 initGraph(["app|foo.a"], {"app": [ |
| 43 [ | 46 [ |
| 44 new RewriteTransformer("a", "b"), | 47 new RewriteTransformer("a", "b"), |
| 45 new RewriteTransformer("b", "c") | 48 new RewriteTransformer("b", "c") |
| 46 ] | 49 ] |
| 47 ]}); | 50 ]}); |
| 48 updateSources(["app|foo.a"]); | 51 updateSources(["app|foo.a"]); |
| 49 expectAsset("app|foo.b", "foo.b"); | 52 expectAsset("app|foo.b", "foo.b"); |
| 50 expectNoAsset("app|foo.c"); | 53 expectNoAsset("app|foo.c"); |
| 54 buildShouldSucceed(); |
| 51 }); | 55 }); |
| 52 | 56 |
| 53 test("finds the latest output before the transformer's phase", () { | 57 test("finds the latest output before the transformer's phase", () { |
| 54 initGraph(["app|foo.blub"], {"app": [ | 58 initGraph(["app|foo.blub"], {"app": [ |
| 55 [new RewriteTransformer("blub", "blub")], | 59 [new RewriteTransformer("blub", "blub")], |
| 56 [ | 60 [ |
| 57 new RewriteTransformer("blub", "blub"), | 61 new RewriteTransformer("blub", "blub"), |
| 58 new RewriteTransformer("blub", "done") | 62 new RewriteTransformer("blub", "done") |
| 59 ], | 63 ], |
| 60 [new RewriteTransformer("blub", "blub")] | 64 [new RewriteTransformer("blub", "blub")] |
| 61 ]}); | 65 ]}); |
| 62 updateSources(["app|foo.blub"]); | 66 updateSources(["app|foo.blub"]); |
| 63 expectAsset("app|foo.done", "foo.blub.done"); | 67 expectAsset("app|foo.done", "foo.blub.done"); |
| 68 buildShouldSucceed(); |
| 64 }); | 69 }); |
| 65 | 70 |
| 66 test("applies multiple transformations to an asset", () { | 71 test("applies multiple transformations to an asset", () { |
| 67 initGraph(["app|foo.a"], {"app": [ | 72 initGraph(["app|foo.a"], {"app": [ |
| 68 [new RewriteTransformer("a", "b")], | 73 [new RewriteTransformer("a", "b")], |
| 69 [new RewriteTransformer("b", "c")], | 74 [new RewriteTransformer("b", "c")], |
| 70 [new RewriteTransformer("c", "d")], | 75 [new RewriteTransformer("c", "d")], |
| 71 [new RewriteTransformer("d", "e")], | 76 [new RewriteTransformer("d", "e")], |
| 72 [new RewriteTransformer("e", "f")], | 77 [new RewriteTransformer("e", "f")], |
| 73 [new RewriteTransformer("f", "g")], | 78 [new RewriteTransformer("f", "g")], |
| 74 [new RewriteTransformer("g", "h")], | 79 [new RewriteTransformer("g", "h")], |
| 75 [new RewriteTransformer("h", "i")], | 80 [new RewriteTransformer("h", "i")], |
| 76 [new RewriteTransformer("i", "j")], | 81 [new RewriteTransformer("i", "j")], |
| 77 [new RewriteTransformer("j", "k")], | 82 [new RewriteTransformer("j", "k")], |
| 78 ]}); | 83 ]}); |
| 79 updateSources(["app|foo.a"]); | 84 updateSources(["app|foo.a"]); |
| 80 expectAsset("app|foo.k", "foo.b.c.d.e.f.g.h.i.j.k"); | 85 expectAsset("app|foo.k", "foo.b.c.d.e.f.g.h.i.j.k"); |
| 86 buildShouldSucceed(); |
| 81 }); | 87 }); |
| 82 | 88 |
| 83 test("only runs a transform once for all of its outputs", () { | 89 test("only runs a transform once for all of its outputs", () { |
| 84 var transformer = new RewriteTransformer("blub", "a b c"); | 90 var transformer = new RewriteTransformer("blub", "a b c"); |
| 85 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 91 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 86 updateSources(["app|foo.blub"]); | 92 updateSources(["app|foo.blub"]); |
| 87 expectAsset("app|foo.a", "foo.a"); | 93 expectAsset("app|foo.a", "foo.a"); |
| 88 expectAsset("app|foo.b", "foo.b"); | 94 expectAsset("app|foo.b", "foo.b"); |
| 89 expectAsset("app|foo.c", "foo.c"); | 95 expectAsset("app|foo.c", "foo.c"); |
| 96 buildShouldSucceed(); |
| 90 schedule(() { | 97 schedule(() { |
| 91 expect(transformer.numRuns, equals(1)); | 98 expect(transformer.numRuns, equals(1)); |
| 92 }); | 99 }); |
| 93 }); | 100 }); |
| 94 | 101 |
| 95 test("runs transforms in the same phase in parallel", () { | 102 test("runs transforms in the same phase in parallel", () { |
| 96 var transformerA = new RewriteTransformer("txt", "a"); | 103 var transformerA = new RewriteTransformer("txt", "a"); |
| 97 var transformerB = new RewriteTransformer("txt", "b"); | 104 var transformerB = new RewriteTransformer("txt", "b"); |
| 98 initGraph(["app|foo.txt"], {"app": [[transformerA, transformerB]]}); | 105 initGraph(["app|foo.txt"], {"app": [[transformerA, transformerB]]}); |
| 99 | 106 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 111 // They should both still be running. | 118 // They should both still be running. |
| 112 expect(transformerA.isRunning, isTrue); | 119 expect(transformerA.isRunning, isTrue); |
| 113 expect(transformerB.isRunning, isTrue); | 120 expect(transformerB.isRunning, isTrue); |
| 114 | 121 |
| 115 transformerA.complete(); | 122 transformerA.complete(); |
| 116 transformerB.complete(); | 123 transformerB.complete(); |
| 117 }); | 124 }); |
| 118 | 125 |
| 119 expectAsset("app|foo.a", "foo.a"); | 126 expectAsset("app|foo.a", "foo.a"); |
| 120 expectAsset("app|foo.b", "foo.b"); | 127 expectAsset("app|foo.b", "foo.b"); |
| 128 buildShouldSucceed(); |
| 121 }); | 129 }); |
| 122 | 130 |
| 123 test("does not reapply transform when inputs are not modified", () { | 131 test("does not reapply transform when inputs are not modified", () { |
| 124 var transformer = new RewriteTransformer("blub", "blab"); | 132 var transformer = new RewriteTransformer("blub", "blab"); |
| 125 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 133 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 126 updateSources(["app|foo.blub"]); | 134 updateSources(["app|foo.blub"]); |
| 127 expectAsset("app|foo.blab", "foo.blab"); | 135 expectAsset("app|foo.blab", "foo.blab"); |
| 128 expectAsset("app|foo.blab", "foo.blab"); | 136 expectAsset("app|foo.blab", "foo.blab"); |
| 129 expectAsset("app|foo.blab", "foo.blab"); | 137 expectAsset("app|foo.blab", "foo.blab"); |
| 138 buildShouldSucceed(); |
| 130 | 139 |
| 131 schedule(() { | 140 schedule(() { |
| 132 expect(transformer.numRuns, equals(1)); | 141 expect(transformer.numRuns, equals(1)); |
| 133 }); | 142 }); |
| 134 }); | 143 }); |
| 135 | 144 |
| 136 test("reapplies a transform when its input is modified", () { | 145 test("reapplies a transform when its input is modified", () { |
| 137 var transformer = new RewriteTransformer("blub", "blab"); | 146 var transformer = new RewriteTransformer("blub", "blab"); |
| 138 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 147 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 139 | 148 |
| 140 schedule(() { | 149 schedule(() { |
| 141 updateSources(["app|foo.blub"]); | 150 updateSources(["app|foo.blub"]); |
| 142 }); | 151 }); |
| 143 | 152 |
| 144 expectAsset("app|foo.blab", "foo.blab"); | 153 expectAsset("app|foo.blab", "foo.blab"); |
| 154 buildShouldSucceed(); |
| 145 | 155 |
| 146 schedule(() { | 156 schedule(() { |
| 147 updateSources(["app|foo.blub"]); | 157 updateSources(["app|foo.blub"]); |
| 148 }); | 158 }); |
| 149 | 159 |
| 150 expectAsset("app|foo.blab", "foo.blab"); | 160 expectAsset("app|foo.blab", "foo.blab"); |
| 161 buildShouldSucceed(); |
| 151 | 162 |
| 152 schedule(() { | 163 schedule(() { |
| 153 updateSources(["app|foo.blub"]); | 164 updateSources(["app|foo.blub"]); |
| 154 }); | 165 }); |
| 155 | 166 |
| 156 expectAsset("app|foo.blab", "foo.blab"); | 167 expectAsset("app|foo.blab", "foo.blab"); |
| 168 buildShouldSucceed(); |
| 157 | 169 |
| 158 schedule(() { | 170 schedule(() { |
| 159 expect(transformer.numRuns, equals(3)); | 171 expect(transformer.numRuns, equals(3)); |
| 160 }); | 172 }); |
| 161 }); | 173 }); |
| 162 | 174 |
| 163 test("does not reapply transform when a removed input is modified", () { | 175 test("does not reapply transform when a removed input is modified", () { |
| 164 var transformer = new ManyToOneTransformer("txt"); | 176 var transformer = new ManyToOneTransformer("txt"); |
| 165 initGraph({ | 177 initGraph({ |
| 166 "app|a.txt": "a.inc,b.inc", | 178 "app|a.txt": "a.inc,b.inc", |
| 167 "app|a.inc": "a", | 179 "app|a.inc": "a", |
| 168 "app|b.inc": "b" | 180 "app|b.inc": "b" |
| 169 }, {"app": [[transformer]]}); | 181 }, {"app": [[transformer]]}); |
| 170 | 182 |
| 171 updateSources(["app|a.txt", "app|a.inc", "app|b.inc"]); | 183 updateSources(["app|a.txt", "app|a.inc", "app|b.inc"]); |
| 172 | 184 |
| 173 expectAsset("app|a.out", "ab"); | 185 expectAsset("app|a.out", "ab"); |
| 186 buildShouldSucceed(); |
| 174 | 187 |
| 175 // Remove the dependency on the non-primary input. | 188 // Remove the dependency on the non-primary input. |
| 176 schedule(() { | 189 schedule(() { |
| 177 modifyAsset("app|a.txt", "a.inc"); | 190 modifyAsset("app|a.txt", "a.inc"); |
| 178 updateSources(["app|a.txt"]); | 191 updateSources(["app|a.txt"]); |
| 179 }); | 192 }); |
| 180 | 193 |
| 181 // Process it again. | 194 // Process it again. |
| 182 expectAsset("app|a.out", "a"); | 195 expectAsset("app|a.out", "a"); |
| 196 buildShouldSucceed(); |
| 183 | 197 |
| 184 // Now touch the removed input. It should not trigger another build. | 198 // Now touch the removed input. It should not trigger another build. |
| 185 schedule(() { | 199 schedule(() { |
| 186 updateSources(["app|b.inc"]); | 200 updateSources(["app|b.inc"]); |
| 187 }); | 201 }); |
| 188 | 202 |
| 189 expectAsset("app|a.out", "a"); | 203 expectAsset("app|a.out", "a"); |
| 204 buildShouldSucceed(); |
| 190 | 205 |
| 191 schedule(() { | 206 schedule(() { |
| 192 expect(transformer.numRuns, equals(2)); | 207 expect(transformer.numRuns, equals(2)); |
| 193 }); | 208 }); |
| 194 }); | 209 }); |
| 195 | 210 |
| 196 test("allows a transform to generate multiple outputs", () { | 211 test("allows a transform to generate multiple outputs", () { |
| 197 initGraph({"app|foo.txt": "a.out,b.out"}, {"app": [ | 212 initGraph({"app|foo.txt": "a.out,b.out"}, {"app": [ |
| 198 [new OneToManyTransformer("txt")] | 213 [new OneToManyTransformer("txt")] |
| 199 ]}); | 214 ]}); |
| 200 | 215 |
| 201 updateSources(["app|foo.txt"]); | 216 updateSources(["app|foo.txt"]); |
| 202 | 217 |
| 203 expectAsset("app|a.out", "spread txt"); | 218 expectAsset("app|a.out", "spread txt"); |
| 204 expectAsset("app|b.out", "spread txt"); | 219 expectAsset("app|b.out", "spread txt"); |
| 220 buildShouldSucceed(); |
| 205 }); | 221 }); |
| 206 | 222 |
| 207 test("does not rebuild transforms that don't use modified source", () { | 223 test("does not rebuild transforms that don't use modified source", () { |
| 208 var a = new RewriteTransformer("a", "aa"); | 224 var a = new RewriteTransformer("a", "aa"); |
| 209 var aa = new RewriteTransformer("aa", "aaa"); | 225 var aa = new RewriteTransformer("aa", "aaa"); |
| 210 var b = new RewriteTransformer("b", "bb"); | 226 var b = new RewriteTransformer("b", "bb"); |
| 211 var bb = new RewriteTransformer("bb", "bbb"); | 227 var bb = new RewriteTransformer("bb", "bbb"); |
| 212 initGraph(["app|foo.a", "app|foo.b"], {"app": [ | 228 initGraph(["app|foo.a", "app|foo.b"], {"app": [ |
| 213 [a, b], | 229 [a, b], |
| 214 [aa, bb], | 230 [aa, bb], |
| 215 ]}); | 231 ]}); |
| 216 | 232 |
| 217 updateSources(["app|foo.a"]); | 233 updateSources(["app|foo.a"]); |
| 218 updateSources(["app|foo.b"]); | 234 updateSources(["app|foo.b"]); |
| 219 | 235 |
| 220 expectAsset("app|foo.aaa", "foo.aa.aaa"); | 236 expectAsset("app|foo.aaa", "foo.aa.aaa"); |
| 221 expectAsset("app|foo.bbb", "foo.bb.bbb"); | 237 expectAsset("app|foo.bbb", "foo.bb.bbb"); |
| 238 buildShouldSucceed(); |
| 222 | 239 |
| 223 schedule(() { | 240 schedule(() { |
| 224 updateSources(["app|foo.a"]); | 241 updateSources(["app|foo.a"]); |
| 225 }); | 242 }); |
| 226 | 243 |
| 227 expectAsset("app|foo.aaa", "foo.aa.aaa"); | 244 expectAsset("app|foo.aaa", "foo.aa.aaa"); |
| 228 expectAsset("app|foo.bbb", "foo.bb.bbb"); | 245 expectAsset("app|foo.bbb", "foo.bb.bbb"); |
| 246 buildShouldSucceed(); |
| 229 | 247 |
| 230 schedule(() { | 248 schedule(() { |
| 231 expect(aa.numRuns, equals(2)); | 249 expect(aa.numRuns, equals(2)); |
| 232 expect(bb.numRuns, equals(1)); | 250 expect(bb.numRuns, equals(1)); |
| 233 }); | 251 }); |
| 234 }); | 252 }); |
| 235 | 253 |
| 236 test("doesn't get an output from a transform whose primary input is removed", | 254 test("doesn't get an output from a transform whose primary input is removed", |
| 237 () { | 255 () { |
| 238 initGraph(["app|foo.txt"], {"app": [ | 256 initGraph(["app|foo.txt"], {"app": [ |
| 239 [new RewriteTransformer("txt", "out")] | 257 [new RewriteTransformer("txt", "out")] |
| 240 ]}); | 258 ]}); |
| 241 | 259 |
| 242 updateSources(["app|foo.txt"]); | 260 updateSources(["app|foo.txt"]); |
| 243 expectAsset("app|foo.out", "foo.out"); | 261 expectAsset("app|foo.out", "foo.out"); |
| 262 buildShouldSucceed(); |
| 244 | 263 |
| 245 schedule(() { | 264 schedule(() { |
| 246 removeSources(["app|foo.txt"]); | 265 removeSources(["app|foo.txt"]); |
| 247 }); | 266 }); |
| 248 | 267 |
| 249 expectNoAsset("app|foo.out"); | 268 expectNoAsset("app|foo.out"); |
| 269 buildShouldSucceed(); |
| 250 }); | 270 }); |
| 251 | 271 |
| 252 test("reapplies a transform when a non-primary input changes", () { | 272 test("reapplies a transform when a non-primary input changes", () { |
| 253 initGraph({ | 273 initGraph({ |
| 254 "app|a.txt": "a.inc", | 274 "app|a.txt": "a.inc", |
| 255 "app|a.inc": "a" | 275 "app|a.inc": "a" |
| 256 }, {"app": [[new ManyToOneTransformer("txt")]]}); | 276 }, {"app": [[new ManyToOneTransformer("txt")]]}); |
| 257 | 277 |
| 258 updateSources(["app|a.txt", "app|a.inc"]); | 278 updateSources(["app|a.txt", "app|a.inc"]); |
| 259 expectAsset("app|a.out", "a"); | 279 expectAsset("app|a.out", "a"); |
| 280 buildShouldSucceed(); |
| 260 | 281 |
| 261 schedule(() { | 282 schedule(() { |
| 262 modifyAsset("app|a.inc", "after"); | 283 modifyAsset("app|a.inc", "after"); |
| 263 updateSources(["app|a.inc"]); | 284 updateSources(["app|a.inc"]); |
| 264 }); | 285 }); |
| 265 | 286 |
| 266 expectAsset("app|a.out", "after"); | 287 expectAsset("app|a.out", "after"); |
| 288 buildShouldSucceed(); |
| 267 }); | 289 }); |
| 268 | 290 |
| 269 test("restarts processing if a change occurs during processing", () { | 291 test("restarts processing if a change occurs during processing", () { |
| 270 var transformer = new RewriteTransformer("txt", "out"); | 292 var transformer = new RewriteTransformer("txt", "out"); |
| 271 initGraph(["app|foo.txt"], {"app": [[transformer]]}); | 293 initGraph(["app|foo.txt"], {"app": [[transformer]]}); |
| 272 | 294 |
| 273 transformer.wait(); | 295 transformer.wait(); |
| 274 | 296 |
| 275 schedule(() { | 297 schedule(() { |
| 276 updateSources(["app|foo.txt"]); | 298 updateSources(["app|foo.txt"]); |
| 277 | 299 |
| 278 // Wait for the transform to start. | 300 // Wait for the transform to start. |
| 279 return transformer.started; | 301 return transformer.started; |
| 280 }); | 302 }); |
| 281 | 303 |
| 282 schedule(() { | 304 schedule(() { |
| 283 // Now update the graph during it. | 305 // Now update the graph during it. |
| 284 updateSources(["app|foo.txt"]); | 306 updateSources(["app|foo.txt"]); |
| 285 }); | 307 }); |
| 286 | 308 |
| 287 schedule(() { | 309 schedule(() { |
| 288 transformer.complete(); | 310 transformer.complete(); |
| 289 }); | 311 }); |
| 290 | 312 |
| 291 expectAsset("app|foo.out", "foo.out"); | 313 expectAsset("app|foo.out", "foo.out"); |
| 314 buildShouldSucceed(); |
| 292 | 315 |
| 293 schedule(() { | 316 schedule(() { |
| 294 expect(transformer.numRuns, equals(2)); | 317 expect(transformer.numRuns, equals(2)); |
| 295 }); | 318 }); |
| 296 }); | 319 }); |
| 297 | 320 |
| 298 test("handles an output moving from one transformer to another", () { | 321 test("handles an output moving from one transformer to another", () { |
| 299 // In the first run, "shared.out" is created by the "a.a" transformer. | 322 // In the first run, "shared.out" is created by the "a.a" transformer. |
| 300 initGraph({ | 323 initGraph({ |
| 301 "app|a.a": "a.out,shared.out", | 324 "app|a.a": "a.out,shared.out", |
| 302 "app|b.b": "b.out" | 325 "app|b.b": "b.out" |
| 303 }, {"app": [ | 326 }, {"app": [ |
| 304 [new OneToManyTransformer("a"), new OneToManyTransformer("b")] | 327 [new OneToManyTransformer("a"), new OneToManyTransformer("b")] |
| 305 ]}); | 328 ]}); |
| 306 | 329 |
| 307 updateSources(["app|a.a", "app|b.b"]); | 330 updateSources(["app|a.a", "app|b.b"]); |
| 308 | 331 |
| 309 expectAsset("app|a.out", "spread a"); | 332 expectAsset("app|a.out", "spread a"); |
| 310 expectAsset("app|b.out", "spread b"); | 333 expectAsset("app|b.out", "spread b"); |
| 311 expectAsset("app|shared.out", "spread a"); | 334 expectAsset("app|shared.out", "spread a"); |
| 335 buildShouldSucceed(); |
| 312 | 336 |
| 313 // Now switch their contents so that "shared.out" will be output by "b.b"'s | 337 // Now switch their contents so that "shared.out" will be output by "b.b"'s |
| 314 // transformer. | 338 // transformer. |
| 315 schedule(() { | 339 schedule(() { |
| 316 modifyAsset("app|a.a", "a.out"); | 340 modifyAsset("app|a.a", "a.out"); |
| 317 modifyAsset("app|b.b", "b.out,shared.out"); | 341 modifyAsset("app|b.b", "b.out,shared.out"); |
| 318 updateSources(["app|a.a", "app|b.b"]); | 342 updateSources(["app|a.a", "app|b.b"]); |
| 319 }); | 343 }); |
| 320 | 344 |
| 321 expectAsset("app|a.out", "spread a"); | 345 expectAsset("app|a.out", "spread a"); |
| 322 expectAsset("app|b.out", "spread b"); | 346 expectAsset("app|b.out", "spread b"); |
| 323 expectAsset("app|shared.out", "spread b"); | 347 expectAsset("app|shared.out", "spread b"); |
| 348 buildShouldSucceed(); |
| 324 }); | 349 }); |
| 325 | 350 |
| 326 test("restarts before finishing later phases when a change occurs", () { | 351 test("restarts before finishing later phases when a change occurs", () { |
| 327 var txtToInt = new RewriteTransformer("txt", "int"); | 352 var txtToInt = new RewriteTransformer("txt", "int"); |
| 328 var intToOut = new RewriteTransformer("int", "out"); | 353 var intToOut = new RewriteTransformer("int", "out"); |
| 329 initGraph(["app|foo.txt", "app|bar.txt"], | 354 initGraph(["app|foo.txt", "app|bar.txt"], |
| 330 {"app": [[txtToInt], [intToOut]]}); | 355 {"app": [[txtToInt], [intToOut]]}); |
| 331 | 356 |
| 332 txtToInt.wait(); | 357 txtToInt.wait(); |
| 333 | 358 |
| 334 schedule(() { | 359 schedule(() { |
| 335 updateSources(["app|foo.txt"]); | 360 updateSources(["app|foo.txt"]); |
| 336 | 361 |
| 337 // Wait for the first transform to start. | 362 // Wait for the first transform to start. |
| 338 return txtToInt.started; | 363 return txtToInt.started; |
| 339 }); | 364 }); |
| 340 | 365 |
| 341 schedule(() { | 366 schedule(() { |
| 342 // Now update the graph during it. | 367 // Now update the graph during it. |
| 343 updateSources(["app|bar.txt"]); | 368 updateSources(["app|bar.txt"]); |
| 344 }); | 369 }); |
| 345 | 370 |
| 346 schedule(() { | 371 schedule(() { |
| 347 txtToInt.complete(); | 372 txtToInt.complete(); |
| 348 }); | 373 }); |
| 349 | 374 |
| 350 expectAsset("app|foo.out", "foo.int.out"); | 375 expectAsset("app|foo.out", "foo.int.out"); |
| 351 expectAsset("app|bar.out", "bar.int.out"); | 376 expectAsset("app|bar.out", "bar.int.out"); |
| 377 buildShouldSucceed(); |
| 352 | 378 |
| 353 schedule(() { | 379 schedule(() { |
| 354 // Should only have run each transform once for each primary. | 380 // Should only have run each transform once for each primary. |
| 355 expect(txtToInt.numRuns, equals(2)); | 381 expect(txtToInt.numRuns, equals(2)); |
| 356 expect(intToOut.numRuns, equals(2)); | 382 expect(intToOut.numRuns, equals(2)); |
| 357 }); | 383 }); |
| 358 }); | 384 }); |
| 359 | 385 |
| 360 test("applies transforms to the correct packages", () { | 386 test("applies transforms to the correct packages", () { |
| 361 var rewrite1 = new RewriteTransformer("txt", "out1"); | 387 var rewrite1 = new RewriteTransformer("txt", "out1"); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 schedule(() => updateSources(["pkg2|foo.txt"])); | 427 schedule(() => updateSources(["pkg2|foo.txt"])); |
| 402 expectAsset("pkg1|foo.out", "foo.out"); | 428 expectAsset("pkg1|foo.out", "foo.out"); |
| 403 buildShouldNotBeDone(); | 429 buildShouldNotBeDone(); |
| 404 | 430 |
| 405 // Now that the provider is unpaused, pkg2's transforms finish and the | 431 // Now that the provider is unpaused, pkg2's transforms finish and the |
| 406 // overall build succeeds. | 432 // overall build succeeds. |
| 407 resumeProvider(); | 433 resumeProvider(); |
| 408 buildShouldSucceed(); | 434 buildShouldSucceed(); |
| 409 }); | 435 }); |
| 410 } | 436 } |
| OLD | NEW |