| 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.asset_graph.source_test; | 5 library barback.test.asset_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:barback/src/asset_graph.dart'; | 10 import 'package:barback/src/asset_graph.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // Sources must be explicitly made visible to barback by calling | 37 // Sources must be explicitly made visible to barback by calling |
| 38 // updateSources() on them. It isn't enough for the provider to be able | 38 // updateSources() on them. It isn't enough for the provider to be able |
| 39 // to provide it. | 39 // to provide it. |
| 40 // | 40 // |
| 41 // This lets you distinguish between sources that you want to be primaries | 41 // This lets you distinguish between sources that you want to be primaries |
| 42 // and the larger set of inputs that those primaries are allowed to pull in. | 42 // and the larger set of inputs that those primaries are allowed to pull in. |
| 43 expectNoAsset("app|foo.txt"); | 43 expectNoAsset("app|foo.txt"); |
| 44 }); | 44 }); |
| 45 | 45 |
| 46 test("gets a source asset if not transformed", () { | 46 test("gets a source asset if not transformed", () { |
| 47 initGraph(["app|foo.txt"], [ | 47 initGraph(["app|foo.txt"], {"app": [ |
| 48 [new RewriteTransformer("nottxt", "whatever")] | 48 [new RewriteTransformer("nottxt", "whatever")] |
| 49 ]); | 49 ]}); |
| 50 | 50 |
| 51 updateSources(["app|foo.txt"]); | 51 updateSources(["app|foo.txt"]); |
| 52 expectAsset("app|foo.txt"); | 52 expectAsset("app|foo.txt"); |
| 53 }); | 53 }); |
| 54 | 54 |
| 55 test("doesn't get a removed source", () { | 55 test("doesn't get a removed source", () { |
| 56 initGraph(["app|foo.txt"]); | 56 initGraph(["app|foo.txt"]); |
| 57 | 57 |
| 58 updateSources(["app|foo.txt"]); | 58 updateSources(["app|foo.txt"]); |
| 59 expectAsset("app|foo.txt"); | 59 expectAsset("app|foo.txt"); |
| 60 | 60 |
| 61 schedule(() { | 61 schedule(() { |
| 62 removeSources(["app|foo.txt"]); | 62 removeSources(["app|foo.txt"]); |
| 63 }); | 63 }); |
| 64 | 64 |
| 65 expectNoAsset("app|foo.txt"); | 65 expectNoAsset("app|foo.txt"); |
| 66 }); | 66 }); |
| 67 | 67 |
| 68 test("collapses redundant updates", () { | 68 test("collapses redundant updates", () { |
| 69 var transformer = new RewriteTransformer("blub", "blab"); | 69 var transformer = new RewriteTransformer("blub", "blab"); |
| 70 initGraph(["app|foo.blub"], [[transformer]]); | 70 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 71 | 71 |
| 72 schedule(() { | 72 schedule(() { |
| 73 // Make a bunch of synchronous update calls. | 73 // Make a bunch of synchronous update calls. |
| 74 updateSources(["app|foo.blub"]); | 74 updateSources(["app|foo.blub"]); |
| 75 updateSources(["app|foo.blub"]); | 75 updateSources(["app|foo.blub"]); |
| 76 updateSources(["app|foo.blub"]); | 76 updateSources(["app|foo.blub"]); |
| 77 updateSources(["app|foo.blub"]); | 77 updateSources(["app|foo.blub"]); |
| 78 }); | 78 }); |
| 79 | 79 |
| 80 expectAsset("app|foo.blab", "foo.blab"); | 80 expectAsset("app|foo.blab", "foo.blab"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 101 schedule(() { | 101 schedule(() { |
| 102 removeSources(["app|foo.txt"]); | 102 removeSources(["app|foo.txt"]); |
| 103 updateSources(["app|foo.txt"]); | 103 updateSources(["app|foo.txt"]); |
| 104 }); | 104 }); |
| 105 | 105 |
| 106 expectAsset("app|foo.txt"); | 106 expectAsset("app|foo.txt"); |
| 107 }); | 107 }); |
| 108 | 108 |
| 109 test("restarts a build if a source is updated while sources are loading", () { | 109 test("restarts a build if a source is updated while sources are loading", () { |
| 110 var transformer = new RewriteTransformer("txt", "out"); | 110 var transformer = new RewriteTransformer("txt", "out"); |
| 111 initGraph(["app|foo.txt", "app|other.bar"], [[transformer]]); | 111 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]}); |
| 112 | 112 |
| 113 // Run the whole graph so all nodes are clean. | 113 // Run the whole graph so all nodes are clean. |
| 114 updateSources(["app|foo.txt", "app|other.bar"]); | 114 updateSources(["app|foo.txt", "app|other.bar"]); |
| 115 expectAsset("app|foo.out", "foo.out"); | 115 expectAsset("app|foo.out", "foo.out"); |
| 116 expectAsset("app|other.bar"); | 116 expectAsset("app|other.bar"); |
| 117 | 117 |
| 118 buildShouldSucceed(); | 118 buildShouldSucceed(); |
| 119 | 119 |
| 120 // Make the provider slow to load a source. | 120 // Make the provider slow to load a source. |
| 121 pauseProvider(); | 121 pauseProvider(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 resumeProvider(); | 133 resumeProvider(); |
| 134 | 134 |
| 135 buildShouldSucceed(); | 135 buildShouldSucceed(); |
| 136 waitForBuild(); | 136 waitForBuild(); |
| 137 | 137 |
| 138 schedule(() { | 138 schedule(() { |
| 139 expect(transformer.numRuns, equals(2)); | 139 expect(transformer.numRuns, equals(2)); |
| 140 }); | 140 }); |
| 141 }); | 141 }); |
| 142 } | 142 } |
| OLD | NEW |