Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.declaring_transformer_test; | 5 library barback.test.package_graph.declaring_transformer_test; |
| 6 | 6 |
| 7 import 'package:barback/barback.dart'; | 7 import 'package:barback/barback.dart'; |
| 8 import 'package:barback/src/utils.dart'; | 8 import 'package:barback/src/utils.dart'; |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 54 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 55 | 55 |
| 56 transformer.pauseApply(); | 56 transformer.pauseApply(); |
| 57 updateSources(["app|foo.blub"]); | 57 updateSources(["app|foo.blub"]); |
| 58 expectAsset("app|foo.blub", "foo"); | 58 expectAsset("app|foo.blub", "foo"); |
| 59 | 59 |
| 60 transformer.resumeApply(); | 60 transformer.resumeApply(); |
| 61 buildShouldSucceed(); | 61 buildShouldSucceed(); |
| 62 }); | 62 }); |
| 63 | 63 |
| 64 // TODO(nweiz): Enable this test when issue 18226 is fixed. | 64 test("fails to get a consumed asset before apply is finished", () { |
| 65 // test("fails to get a consumed asset before apply is finished", () { | 65 var transformer = new DeclaringRewriteTransformer("blub", "blab") |
| 66 // var transformer = new DeclaringRewriteTransformer("blub", "blab") | 66 ..consumePrimary = true; |
| 67 // ..consumePrimary = true; | 67 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 68 // initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 68 |
| 69 // | 69 transformer.pauseApply(); |
| 70 // transformer.pauseApply(); | 70 updateSources(["app|foo.blub"]); |
| 71 // updateSources(["app|foo.blub"]); | 71 expectNoAsset("app|foo.blub"); |
| 72 // expectNoAsset("app|foo.blub"); | 72 |
| 73 // | 73 transformer.resumeApply(); |
| 74 // transformer.resumeApply(); | 74 buildShouldSucceed(); |
| 75 // buildShouldSucceed(); | 75 }); |
| 76 // }); | 76 |
| 77 test("blocks on getting a declared asset that wasn't generated last run", () { | |
| 78 var transformer = new DeclaringCheckContentAndRenameTransformer( | |
| 79 "txt", "yes", "out", "done"); | |
| 80 initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); | |
| 81 | |
| 82 updateSources(["app|foo.txt"]); | |
| 83 expectNoAsset("app|foo.out"); | |
| 84 buildShouldSucceed(); | |
| 85 | |
| 86 // The transform should remember that foo.out was declared, so it should | |
| 87 // expect that it might still be generated even though it wasn't last time. | |
| 88 transformer.pauseApply(); | |
| 89 modifyAsset("app|foo.txt", "yes"); | |
| 90 updateSources(["app|foo.txt"]); | |
| 91 expectAssetDoesNotComplete("app|foo.out"); | |
| 92 | |
| 93 transformer.resumeApply(); | |
| 94 expectAsset("app|foo.out", "done"); | |
| 95 buildShouldSucceed(); | |
| 96 }); | |
| 97 | |
| 98 test("doesn't block on on getting an undeclared asset that wasn't generated " | |
| 99 "last run", () { | |
| 100 var transformer = new DeclaringCheckContentAndRenameTransformer( | |
| 101 "txt", "yes", "out", "done"); | |
| 102 initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]}); | |
| 103 | |
| 104 updateSources(["app|foo.txt"]); | |
| 105 expectNoAsset("app|foo.out"); | |
| 106 buildShouldSucceed(); | |
| 107 | |
| 108 transformer.pauseApply(); | |
| 109 modifyAsset("app|foo.txt", "yes"); | |
| 110 updateSources(["app|foo.txt"]); | |
| 111 expectNoAsset("app|undeclared.out"); | |
| 112 | |
| 113 transformer.resumeApply(); | |
| 114 buildShouldSucceed(); | |
| 115 }); | |
| 77 | 116 |
|
Bob Nystrom
2014/04/25 22:02:33
There's a bunch of code (all the .dirtiest() calls
nweiz
2014/04/28 21:02:00
Done.
| |
| 78 test("waits until apply is finished to get an overwritten asset", () { | 117 test("waits until apply is finished to get an overwritten asset", () { |
| 79 var transformer = new DeclaringRewriteTransformer("blub", "blub"); | 118 var transformer = new DeclaringRewriteTransformer("blub", "blub"); |
| 80 initGraph(["app|foo.blub"], {"app": [[transformer]]}); | 119 initGraph(["app|foo.blub"], {"app": [[transformer]]}); |
| 81 | 120 |
| 82 transformer.pauseApply(); | 121 transformer.pauseApply(); |
| 83 updateSources(["app|foo.blub"]); | 122 updateSources(["app|foo.blub"]); |
| 84 expectAssetDoesNotComplete("app|foo.blub"); | 123 expectAssetDoesNotComplete("app|foo.blub"); |
| 85 | 124 |
| 86 transformer.resumeApply(); | 125 transformer.resumeApply(); |
| 87 expectAsset("app|foo.blub", "foo.blub"); | 126 expectAsset("app|foo.blub", "foo.blub"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 // Once we make a request, [declaring] should force the lazy transformer and | 175 // Once we make a request, [declaring] should force the lazy transformer and |
| 137 // then run itself. | 176 // then run itself. |
| 138 expectAsset("app|out.three", "app|out.two.three"); | 177 expectAsset("app|out.three", "app|out.two.three"); |
| 139 buildShouldSucceed(); | 178 buildShouldSucceed(); |
| 140 | 179 |
| 141 // Now [declaring] should have run twice. This ensures that it didn't use | 180 // Now [declaring] should have run twice. This ensures that it didn't use |
| 142 // its original output for some reason. | 181 // its original output for some reason. |
| 143 expect(declaring.numRuns, completion(equals(2))); | 182 expect(declaring.numRuns, completion(equals(2))); |
| 144 }); | 183 }); |
| 145 | 184 |
| 146 group("with an error in declareOutputs", () { | 185 // TODO(nweiz): Re-enable these when barback is capable of dealing with a |
| 147 test("still runs apply", () { | 186 // changing [TransformNode.deferred] value. |
|
Bob Nystrom
2014/04/25 22:02:33
Tracking bug?
nweiz
2014/04/28 21:02:00
I already have a patch for this, I don't think it'
| |
| 148 initGraph(["app|foo.txt"], {"app": [[ | 187 // group("with an error in declareOutputs", () { |
| 149 new DeclaringBadTransformer("app|out.txt", | 188 // test("still runs apply", () { |
| 150 declareError: true, applyError: false) | 189 // initGraph(["app|foo.txt"], {"app": [[ |
| 151 ]]}); | 190 // new DeclaringBadTransformer("app|out.txt", |
| 152 | 191 // declareError: true, applyError: false) |
| 153 updateSources(["app|foo.txt"]); | 192 // ]]}); |
| 154 expectAsset("app|out.txt", "bad out"); | 193 // |
| 155 expectAsset("app|foo.txt", "foo"); | 194 // updateSources(["app|foo.txt"]); |
| 156 buildShouldFail([isTransformerException(BadTransformer.ERROR)]); | 195 // expectAsset("app|out.txt", "bad out"); |
| 157 }); | 196 // expectAsset("app|foo.txt", "foo"); |
| 158 | 197 // buildShouldFail([isTransformerException(BadTransformer.ERROR)]); |
| 159 test("waits for apply to complete before passing through the input even if " | 198 // }); |
| 160 "consumePrimary was called", () { | 199 // |
| 161 var transformer = new DeclaringBadTransformer("app|out.txt", | 200 // test("waits for apply to complete before passing through the input even i f " |
| 162 declareError: true, applyError: false)..consumePrimary = true; | 201 // "consumePrimary was called", () { |
| 163 initGraph(["app|foo.txt"], {"app": [[transformer]]}); | 202 // var transformer = new DeclaringBadTransformer("app|out.txt", |
| 164 | 203 // declareError: true, applyError: false)..consumePrimary = true; |
| 165 transformer.pauseApply(); | 204 // initGraph(["app|foo.txt"], {"app": [[transformer]]}); |
| 166 updateSources(["app|foo.txt"]); | 205 // |
| 167 expectAssetDoesNotComplete("app|out.txt"); | 206 // transformer.pauseApply(); |
| 168 expectAssetDoesNotComplete("app|foo.txt"); | 207 // updateSources(["app|foo.txt"]); |
| 169 | 208 // expectAssetDoesNotComplete("app|out.txt"); |
| 170 transformer.resumeApply(); | 209 // expectAssetDoesNotComplete("app|foo.txt"); |
| 171 expectAsset("app|out.txt", "bad out"); | 210 // |
| 172 expectNoAsset("app|foo.txt"); | 211 // transformer.resumeApply(); |
| 173 buildShouldFail([isTransformerException(BadTransformer.ERROR)]); | 212 // expectAsset("app|out.txt", "bad out"); |
| 174 }); | 213 // expectNoAsset("app|foo.txt"); |
| 175 }); | 214 // buildShouldFail([isTransformerException(BadTransformer.ERROR)]); |
| 215 // }); | |
| 216 // }); | |
| 176 | 217 |
| 177 test("with an error in apply still passes through the input", () { | 218 test("with an error in apply still passes through the input", () { |
| 178 initGraph(["app|foo.txt"], {"app": [[ | 219 initGraph(["app|foo.txt"], {"app": [[ |
| 179 new DeclaringBadTransformer("app|out.txt", | 220 new DeclaringBadTransformer("app|out.txt", |
| 180 declareError: false, applyError: true) | 221 declareError: false, applyError: true) |
| 181 ]]}); | 222 ]]}); |
| 182 | 223 |
| 183 updateSources(["app|foo.txt"]); | 224 updateSources(["app|foo.txt"]); |
| 184 expectNoAsset("app|out.txt"); | 225 expectNoAsset("app|out.txt"); |
| 185 expectAsset("app|foo.txt", "foo"); | 226 expectAsset("app|foo.txt", "foo"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 test("can declare outputs it doesn't emit", () { | 258 test("can declare outputs it doesn't emit", () { |
| 218 initGraph(["app|foo.txt"], {"app": [ | 259 initGraph(["app|foo.txt"], {"app": [ |
| 219 [new DeclareAssetsTransformer(["app|out.txt"], [])] | 260 [new DeclareAssetsTransformer(["app|out.txt"], [])] |
| 220 ]}); | 261 ]}); |
| 221 | 262 |
| 222 updateSources(["app|foo.txt"]); | 263 updateSources(["app|foo.txt"]); |
| 223 expectNoAsset("app|out.txt"); | 264 expectNoAsset("app|out.txt"); |
| 224 buildShouldSucceed(); | 265 buildShouldSucceed(); |
| 225 }); | 266 }); |
| 226 } | 267 } |
| OLD | NEW |