| 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 '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 // This tests the behavior of barback under many operations happening in quick | 11 // This tests the behavior of barback under many operations happening in quick |
| 13 // succession. Since Barback is so asynchronous, it's easy for it to have subtle | 12 // succession. Since Barback is so asynchronous, it's easy for it to have subtle |
| 14 // dependencies on the commonly-used and -tested usage patterns. These tests | 13 // dependencies on the commonly-used and -tested usage patterns. These tests |
| 15 // exist to stress-test less-common usage patterns in order to root out | 14 // exist to stress-test less-common usage patterns in order to root out |
| 16 // additional bugs. | 15 // additional bugs. |
| 17 | 16 |
| 18 main() { | 17 main() { |
| 19 initConfig(); | 18 initConfig(); |
| 20 | 19 |
| 21 test("updates sources many times", () { | 20 test("updates sources many times", () { |
| 22 initGraph(["app|foo.txt"], { | 21 initGraph([ |
| 23 "app": [[new RewriteTransformer("txt", "out")]] | 22 "app|foo.txt" |
| 23 ], { |
| 24 "app": [ |
| 25 [new RewriteTransformer("txt", "out")] |
| 26 ] |
| 24 }); | 27 }); |
| 25 | 28 |
| 26 for (var i = 0; i < 1000; i++) { | 29 for (var i = 0; i < 1000; i++) { |
| 27 updateSources(["app|foo.txt"]); | 30 updateSources(["app|foo.txt"]); |
| 28 } | 31 } |
| 29 | 32 |
| 30 expectAsset("app|foo.out", "foo.out"); | 33 expectAsset("app|foo.out", "foo.out"); |
| 31 buildShouldSucceed(); | 34 buildShouldSucceed(); |
| 32 }); | 35 }); |
| 33 | 36 |
| 34 test("updates and then removes sources many times", () { | 37 test("updates and then removes sources many times", () { |
| 35 initGraph(["app|foo.txt"], { | 38 initGraph([ |
| 36 "app": [[new RewriteTransformer("txt", "out")]] | 39 "app|foo.txt" |
| 40 ], { |
| 41 "app": [ |
| 42 [new RewriteTransformer("txt", "out")] |
| 43 ] |
| 37 }); | 44 }); |
| 38 | 45 |
| 39 for (var i = 0; i < 1000; i++) { | 46 for (var i = 0; i < 1000; i++) { |
| 40 updateSources(["app|foo.txt"]); | 47 updateSources(["app|foo.txt"]); |
| 41 removeSources(["app|foo.txt"]); | 48 removeSources(["app|foo.txt"]); |
| 42 } | 49 } |
| 43 | 50 |
| 44 expectNoAsset("app|foo.out"); | 51 expectNoAsset("app|foo.out"); |
| 45 expectNoAsset("app|foo.txt"); | 52 expectNoAsset("app|foo.txt"); |
| 46 buildShouldSucceed(); | 53 buildShouldSucceed(); |
| 47 }); | 54 }); |
| 48 | 55 |
| 49 test("updates transformers many times", () { | 56 test("updates transformers many times", () { |
| 50 var rewrite = new RewriteTransformer("txt", "out"); | 57 var rewrite = new RewriteTransformer("txt", "out"); |
| 51 initGraph(["app|foo.txt"], {"app": [[rewrite]]}); | 58 initGraph([ |
| 59 "app|foo.txt" |
| 60 ], { |
| 61 "app": [ |
| 62 [rewrite] |
| 63 ] |
| 64 }); |
| 52 updateSources(["app|foo.txt"]); | 65 updateSources(["app|foo.txt"]); |
| 53 | 66 |
| 54 for (var i = 0; i < 1000; i++) { | 67 for (var i = 0; i < 1000; i++) { |
| 55 updateTransformers("app", [[rewrite]]); | 68 updateTransformers("app", [ |
| 69 [rewrite] |
| 70 ]); |
| 56 } | 71 } |
| 57 | 72 |
| 58 expectAsset("app|foo.out", "foo.out"); | 73 expectAsset("app|foo.out", "foo.out"); |
| 59 buildShouldSucceed(); | 74 buildShouldSucceed(); |
| 60 }); | 75 }); |
| 61 | 76 |
| 62 test("updates and removes transformers many times", () { | 77 test("updates and removes transformers many times", () { |
| 63 var rewrite = new RewriteTransformer("txt", "out"); | 78 var rewrite = new RewriteTransformer("txt", "out"); |
| 64 initGraph(["app|foo.txt"], {"app": [[rewrite]]}); | 79 initGraph([ |
| 80 "app|foo.txt" |
| 81 ], { |
| 82 "app": [ |
| 83 [rewrite] |
| 84 ] |
| 85 }); |
| 65 updateSources(["app|foo.txt"]); | 86 updateSources(["app|foo.txt"]); |
| 66 | 87 |
| 67 for (var i = 0; i < 1000; i++) { | 88 for (var i = 0; i < 1000; i++) { |
| 68 updateTransformers("app", [[rewrite]]); | 89 updateTransformers("app", [ |
| 90 [rewrite] |
| 91 ]); |
| 69 updateTransformers("app", [[]]); | 92 updateTransformers("app", [[]]); |
| 70 } | 93 } |
| 71 | 94 |
| 72 expectAsset("app|foo.txt", "foo"); | 95 expectAsset("app|foo.txt", "foo"); |
| 73 expectNoAsset("app|foo.out"); | 96 expectNoAsset("app|foo.out"); |
| 74 buildShouldSucceed(); | 97 buildShouldSucceed(); |
| 75 }); | 98 }); |
| 76 } | 99 } |
| OLD | NEW |