| 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.transform.pass_through_test; | 5 library barback.test.package_graph.transform.pass_through_test; |
| 6 | 6 |
| 7 import 'package:barback/src/utils.dart'; | |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
| 9 | 8 |
| 10 import '../../utils.dart'; | 9 import '../../utils.dart'; |
| 11 | 10 |
| 12 main() { | 11 main() { |
| 13 initConfig(); | 12 initConfig(); |
| 14 test("can access other packages' source assets", () { | 13 test("can access other packages' source assets", () { |
| 15 initGraph({ | 14 initGraph({ |
| 16 "pkg1|a.txt": "pkg2|a.inc", | 15 "pkg1|a.txt": "pkg2|a.inc", |
| 17 "pkg2|a.inc": "a" | 16 "pkg2|a.inc": "a" |
| 18 }, {"pkg1": [[new ManyToOneTransformer("txt")]]}); | 17 }, { |
| 18 "pkg1": [ |
| 19 [new ManyToOneTransformer("txt")] |
| 20 ] |
| 21 }); |
| 19 | 22 |
| 20 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 23 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 21 expectAsset("pkg1|a.out", "a"); | 24 expectAsset("pkg1|a.out", "a"); |
| 22 buildShouldSucceed(); | 25 buildShouldSucceed(); |
| 23 }); | 26 }); |
| 24 | 27 |
| 25 test("can access other packages' transformed assets", () { | 28 test("can access other packages' transformed assets", () { |
| 26 initGraph({ | 29 initGraph({ |
| 27 "pkg1|a.txt": "pkg2|a.inc", | 30 "pkg1|a.txt": "pkg2|a.inc", |
| 28 "pkg2|a.txt": "a" | 31 "pkg2|a.txt": "a" |
| 29 }, { | 32 }, { |
| 30 "pkg1": [[new ManyToOneTransformer("txt")]], | 33 "pkg1": [ |
| 31 "pkg2": [[new RewriteTransformer("txt", "inc")]] | 34 [new ManyToOneTransformer("txt")] |
| 35 ], |
| 36 "pkg2": [ |
| 37 [new RewriteTransformer("txt", "inc")] |
| 38 ] |
| 32 }); | 39 }); |
| 33 | 40 |
| 34 updateSources(["pkg1|a.txt", "pkg2|a.txt"]); | 41 updateSources(["pkg1|a.txt", "pkg2|a.txt"]); |
| 35 expectAsset("pkg1|a.out", "a.inc"); | 42 expectAsset("pkg1|a.out", "a.inc"); |
| 36 buildShouldSucceed(); | 43 buildShouldSucceed(); |
| 37 }); | 44 }); |
| 38 | 45 |
| 39 test("re-runs a transform when an input from another package changes", () { | 46 test("re-runs a transform when an input from another package changes", () { |
| 40 initGraph({ | 47 initGraph({ |
| 41 "pkg1|a.txt": "pkg2|a.inc", | 48 "pkg1|a.txt": "pkg2|a.inc", |
| 42 "pkg2|a.inc": "a" | 49 "pkg2|a.inc": "a" |
| 43 }, { | 50 }, { |
| 44 "pkg1": [[new ManyToOneTransformer("txt")]] | 51 "pkg1": [ |
| 52 [new ManyToOneTransformer("txt")] |
| 53 ] |
| 45 }); | 54 }); |
| 46 | 55 |
| 47 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 56 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 48 expectAsset("pkg1|a.out", "a"); | 57 expectAsset("pkg1|a.out", "a"); |
| 49 buildShouldSucceed(); | 58 buildShouldSucceed(); |
| 50 | 59 |
| 51 modifyAsset("pkg2|a.inc", "new a"); | 60 modifyAsset("pkg2|a.inc", "new a"); |
| 52 updateSources(["pkg2|a.inc"]); | 61 updateSources(["pkg2|a.inc"]); |
| 53 expectAsset("pkg1|a.out", "new a"); | 62 expectAsset("pkg1|a.out", "new a"); |
| 54 buildShouldSucceed(); | 63 buildShouldSucceed(); |
| 55 }); | 64 }); |
| 56 | 65 |
| 57 test("re-runs a transform when a transformed input from another package " | 66 test( |
| 67 "re-runs a transform when a transformed input from another package " |
| 58 "changes", () { | 68 "changes", () { |
| 59 initGraph({ | 69 initGraph({ |
| 60 "pkg1|a.txt": "pkg2|a.inc", | 70 "pkg1|a.txt": "pkg2|a.inc", |
| 61 "pkg2|a.txt": "a" | 71 "pkg2|a.txt": "a" |
| 62 }, { | 72 }, { |
| 63 "pkg1": [[new ManyToOneTransformer("txt")]], | 73 "pkg1": [ |
| 64 "pkg2": [[new RewriteTransformer("txt", "inc")]] | 74 [new ManyToOneTransformer("txt")] |
| 75 ], |
| 76 "pkg2": [ |
| 77 [new RewriteTransformer("txt", "inc")] |
| 78 ] |
| 65 }); | 79 }); |
| 66 | 80 |
| 67 updateSources(["pkg1|a.txt", "pkg2|a.txt"]); | 81 updateSources(["pkg1|a.txt", "pkg2|a.txt"]); |
| 68 expectAsset("pkg1|a.out", "a.inc"); | 82 expectAsset("pkg1|a.out", "a.inc"); |
| 69 buildShouldSucceed(); | 83 buildShouldSucceed(); |
| 70 | 84 |
| 71 modifyAsset("pkg2|a.txt", "new a"); | 85 modifyAsset("pkg2|a.txt", "new a"); |
| 72 updateSources(["pkg2|a.txt"]); | 86 updateSources(["pkg2|a.txt"]); |
| 73 expectAsset("pkg1|a.out", "new a.inc"); | 87 expectAsset("pkg1|a.out", "new a.inc"); |
| 74 buildShouldSucceed(); | 88 buildShouldSucceed(); |
| 75 }); | 89 }); |
| 76 | 90 |
| 77 test("doesn't complete the build until all packages' transforms are " | 91 test( |
| 92 "doesn't complete the build until all packages' transforms are " |
| 78 "finished running", () { | 93 "finished running", () { |
| 79 var transformer = new ManyToOneTransformer("txt"); | 94 var transformer = new ManyToOneTransformer("txt"); |
| 80 initGraph({ | 95 initGraph({ |
| 81 "pkg1|a.txt": "pkg2|a.inc", | 96 "pkg1|a.txt": "pkg2|a.inc", |
| 82 "pkg2|a.inc": "a" | 97 "pkg2|a.inc": "a" |
| 83 }, { | 98 }, { |
| 84 "pkg1": [[transformer]] | 99 "pkg1": [ |
| 100 [transformer] |
| 101 ] |
| 85 }); | 102 }); |
| 86 | 103 |
| 87 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 104 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 88 expectAsset("pkg1|a.out", "a"); | 105 expectAsset("pkg1|a.out", "a"); |
| 89 buildShouldSucceed(); | 106 buildShouldSucceed(); |
| 90 | 107 |
| 91 transformer.pauseApply(); | 108 transformer.pauseApply(); |
| 92 modifyAsset("pkg2|a.inc", "new a"); | 109 modifyAsset("pkg2|a.inc", "new a"); |
| 93 updateSources(["pkg2|a.inc"]); | 110 updateSources(["pkg2|a.inc"]); |
| 94 buildShouldNotBeDone(); | 111 buildShouldNotBeDone(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 119 expectAsset("pkg1|b", "spread out"); | 136 expectAsset("pkg1|b", "spread out"); |
| 120 buildShouldSucceed(); | 137 buildShouldSucceed(); |
| 121 | 138 |
| 122 modifyAsset("pkg2|a.inc", "b,c.md"); | 139 modifyAsset("pkg2|a.inc", "b,c.md"); |
| 123 updateSources(["pkg2|a.inc"]); | 140 updateSources(["pkg2|a.inc"]); |
| 124 expectAsset("pkg1|b", "spread out"); | 141 expectAsset("pkg1|b", "spread out"); |
| 125 expectAsset("pkg1|c.done", "spread out.done"); | 142 expectAsset("pkg1|c.done", "spread out.done"); |
| 126 buildShouldSucceed(); | 143 buildShouldSucceed(); |
| 127 }); | 144 }); |
| 128 | 145 |
| 129 test("doesn't run a transform that's removed because of a change in " | 146 test( |
| 147 "doesn't run a transform that's removed because of a change in " |
| 130 "another package", () { | 148 "another package", () { |
| 131 initGraph({ | 149 initGraph({ |
| 132 "pkg1|a.txt": "pkg2|a.inc", | 150 "pkg1|a.txt": "pkg2|a.inc", |
| 133 "pkg2|a.inc": "b,c.md" | 151 "pkg2|a.inc": "b,c.md" |
| 134 }, { | 152 }, { |
| 135 "pkg1": [ | 153 "pkg1": [ |
| 136 [new ManyToOneTransformer("txt")], | 154 [new ManyToOneTransformer("txt")], |
| 137 [new OneToManyTransformer("out")], | 155 [new OneToManyTransformer("out")], |
| 138 [new RewriteTransformer("md", "done")] | 156 [new RewriteTransformer("md", "done")] |
| 139 ], | 157 ], |
| 140 }); | 158 }); |
| 141 | 159 |
| 142 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 160 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 143 expectAsset("pkg1|b", "spread out"); | 161 expectAsset("pkg1|b", "spread out"); |
| 144 expectAsset("pkg1|c.done", "spread out.done"); | 162 expectAsset("pkg1|c.done", "spread out.done"); |
| 145 buildShouldSucceed(); | 163 buildShouldSucceed(); |
| 146 | 164 |
| 147 modifyAsset("pkg2|a.inc", "b"); | 165 modifyAsset("pkg2|a.inc", "b"); |
| 148 updateSources(["pkg2|a.inc"]); | 166 updateSources(["pkg2|a.inc"]); |
| 149 expectAsset("pkg1|b", "spread out"); | 167 expectAsset("pkg1|b", "spread out"); |
| 150 expectNoAsset("pkg1|c.done"); | 168 expectNoAsset("pkg1|c.done"); |
| 151 buildShouldSucceed(); | 169 buildShouldSucceed(); |
| 152 }); | 170 }); |
| 153 | 171 |
| 154 test("sees a transformer that's newly applied to a cross-package " | 172 test( |
| 173 "sees a transformer that's newly applied to a cross-package " |
| 155 "dependency", () { | 174 "dependency", () { |
| 156 initGraph({ | 175 initGraph({ |
| 157 "pkg1|a.txt": "pkg2|a.inc", | 176 "pkg1|a.txt": "pkg2|a.inc", |
| 158 "pkg2|a.inc": "a" | 177 "pkg2|a.inc": "a" |
| 159 }, { | 178 }, { |
| 160 "pkg1": [[new ManyToOneTransformer("txt")]], | 179 "pkg1": [ |
| 161 "pkg2": [[new CheckContentTransformer("b", " transformed")]] | 180 [new ManyToOneTransformer("txt")] |
| 181 ], |
| 182 "pkg2": [ |
| 183 [new CheckContentTransformer("b", " transformed")] |
| 184 ] |
| 162 }); | 185 }); |
| 163 | 186 |
| 164 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 187 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 165 expectAsset("pkg1|a.out", "a"); | 188 expectAsset("pkg1|a.out", "a"); |
| 166 buildShouldSucceed(); | 189 buildShouldSucceed(); |
| 167 | 190 |
| 168 modifyAsset("pkg2|a.inc", "b"); | 191 modifyAsset("pkg2|a.inc", "b"); |
| 169 updateSources(["pkg2|a.inc"]); | 192 updateSources(["pkg2|a.inc"]); |
| 170 expectAsset("pkg1|a.out", "b transformed"); | 193 expectAsset("pkg1|a.out", "b transformed"); |
| 171 buildShouldSucceed(); | 194 buildShouldSucceed(); |
| 172 }); | 195 }); |
| 173 | 196 |
| 174 test("doesn't see a transformer that's newly not applied to a " | 197 test( |
| 198 "doesn't see a transformer that's newly not applied to a " |
| 175 "cross-package dependency", () { | 199 "cross-package dependency", () { |
| 176 initGraph({ | 200 initGraph({ |
| 177 "pkg1|a.txt": "pkg2|a.inc", | 201 "pkg1|a.txt": "pkg2|a.inc", |
| 178 "pkg2|a.inc": "a" | 202 "pkg2|a.inc": "a" |
| 179 }, { | 203 }, { |
| 180 "pkg1": [[new ManyToOneTransformer("txt")]], | 204 "pkg1": [ |
| 181 "pkg2": [[new CheckContentTransformer("a", " transformed")]] | 205 [new ManyToOneTransformer("txt")] |
| 206 ], |
| 207 "pkg2": [ |
| 208 [new CheckContentTransformer("a", " transformed")] |
| 209 ] |
| 182 }); | 210 }); |
| 183 | 211 |
| 184 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); | 212 updateSources(["pkg1|a.txt", "pkg2|a.inc"]); |
| 185 expectAsset("pkg1|a.out", "a transformed"); | 213 expectAsset("pkg1|a.out", "a transformed"); |
| 186 buildShouldSucceed(); | 214 buildShouldSucceed(); |
| 187 | 215 |
| 188 modifyAsset("pkg2|a.inc", "b"); | 216 modifyAsset("pkg2|a.inc", "b"); |
| 189 updateSources(["pkg2|a.inc"]); | 217 updateSources(["pkg2|a.inc"]); |
| 190 expectAsset("pkg1|a.out", "b"); | 218 expectAsset("pkg1|a.out", "b"); |
| 191 buildShouldSucceed(); | 219 buildShouldSucceed(); |
| 192 }); | 220 }); |
| 193 } | 221 } |
| OLD | NEW |