OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library barback.test.package_graph.transform_test; | |
6 | |
7 import 'package:barback/src/utils.dart'; | |
8 import 'package:scheduled_test/scheduled_test.dart'; | |
9 | |
10 import '../utils.dart'; | |
11 | |
12 // 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 | |
14 // 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 | |
16 // additional bugs. | |
17 | |
18 main() { | |
19 initConfig(); | |
20 | |
21 test("updates sources many times", () { | |
22 initGraph(["app|foo.txt"], { | |
23 "app": [[new RewriteTransformer("txt", "out")]] | |
24 }); | |
25 | |
26 for (var i = 0; i < 1000; i++) { | |
27 updateSources(["app|foo.txt"]); | |
28 } | |
29 | |
30 expectAsset("app|foo.out", "foo.out"); | |
31 buildShouldSucceed(); | |
32 }); | |
33 | |
34 test("updates and then removes sources many times", () { | |
35 initGraph(["app|foo.txt"], { | |
36 "app": [[new RewriteTransformer("txt", "out")]] | |
37 }); | |
38 | |
39 for (var i = 0; i < 1000; i++) { | |
40 updateSources(["app|foo.txt"]); | |
41 removeSources(["app|foo.txt"]); | |
42 } | |
43 | |
44 expectNoAsset("app|foo.out"); | |
45 expectNoAsset("app|foo.txt"); | |
46 buildShouldSucceed(); | |
47 }); | |
48 | |
49 test("updates transformers many times", () { | |
50 var rewrite = new RewriteTransformer("txt", "out"); | |
51 initGraph(["app|foo.txt"], {"app": [[rewrite]]}); | |
52 updateSources(["app|foo.txt"]); | |
53 | |
54 for (var i = 0; i < 1000; i++) { | |
55 updateTransformers("app", [[rewrite]]); | |
56 } | |
57 | |
58 expectAsset("app|foo.out", "foo.out"); | |
59 buildShouldSucceed(); | |
60 }); | |
61 | |
62 test("updates and removes transformers many times", () { | |
63 var rewrite = new RewriteTransformer("txt", "out"); | |
64 initGraph(["app|foo.txt"], {"app": [[rewrite]]}); | |
65 updateSources(["app|foo.txt"]); | |
66 | |
67 for (var i = 0; i < 1000; i++) { | |
68 updateTransformers("app", [[rewrite]]); | |
69 updateTransformers("app", [[]]); | |
70 } | |
71 | |
72 expectAsset("app|foo.txt", "foo"); | |
73 expectNoAsset("app|foo.out"); | |
74 buildShouldSucceed(); | |
75 }); | |
76 } | |
OLD | NEW |