Chromium Code Reviews

Side by Side Diff: pkg/barback/test/package_graph/source_test.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
(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.source_test;
6
7 import 'package:scheduled_test/scheduled_test.dart';
8
9 import '../utils.dart';
10
11 main() {
12 initConfig();
13 test("gets a source asset", () {
14 initGraph(["app|foo.txt"]);
15 updateSources(["app|foo.txt"]);
16 expectAsset("app|foo.txt");
17 buildShouldSucceed();
18 });
19
20 test("doesn't get an unknown source", () {
21 initGraph();
22 expectNoAsset("app|unknown.txt");
23 });
24
25 test("doesn't get an unprovided source", () {
26 initGraph();
27 updateSources(["app|unknown.txt"]);
28 expectNoAsset("app|unknown.txt");
29 });
30
31 test("doesn't get an asset that isn't an updated source", () {
32 initGraph(["app|foo.txt"]);
33
34 // Sources must be explicitly made visible to barback by calling
35 // updateSources() on them. It isn't enough for the provider to be able
36 // to provide it.
37 //
38 // This lets you distinguish between sources that you want to be primaries
39 // and the larger set of inputs that those primaries are allowed to pull in.
40 expectNoAsset("app|foo.txt");
41 });
42
43 test("gets a source asset if not transformed", () {
44 initGraph(["app|foo.txt"], {"app": [
45 [new RewriteTransformer("nottxt", "whatever")]
46 ]});
47
48 updateSources(["app|foo.txt"]);
49 expectAsset("app|foo.txt");
50 buildShouldSucceed();
51 });
52
53 test("doesn't get a removed source", () {
54 initGraph(["app|foo.txt"]);
55
56 updateSources(["app|foo.txt"]);
57 expectAsset("app|foo.txt");
58 buildShouldSucceed();
59
60 removeSources(["app|foo.txt"]);
61 expectNoAsset("app|foo.txt");
62 buildShouldSucceed();
63 });
64
65 test("collapses redundant updates", () {
66 var transformer = new RewriteTransformer("blub", "blab");
67 initGraph(["app|foo.blub"], {"app": [[transformer]]});
68
69 schedule(() {
70 // Make a bunch of synchronous update calls.
71 updateSourcesSync(["app|foo.blub"]);
72 updateSourcesSync(["app|foo.blub"]);
73 updateSourcesSync(["app|foo.blub"]);
74 updateSourcesSync(["app|foo.blub"]);
75 });
76
77 expectAsset("app|foo.blab", "foo.blab");
78 buildShouldSucceed();
79
80 expect(transformer.numRuns, completion(equals(1)));
81 });
82
83 test("a removal cancels out an update", () {
84 initGraph(["app|foo.txt"]);
85
86 schedule(() {
87 updateSourcesSync(["app|foo.txt"]);
88 removeSourcesSync(["app|foo.txt"]);
89 });
90
91 expectNoAsset("app|foo.txt");
92 buildShouldSucceed();
93 });
94
95 test("an update cancels out a removal", () {
96 initGraph(["app|foo.txt"]);
97
98 schedule(() {
99 removeSourcesSync(["app|foo.txt"]);
100 updateSourcesSync(["app|foo.txt"]);
101 });
102
103 expectAsset("app|foo.txt");
104 buildShouldSucceed();
105 });
106
107 test("reloads an asset that's updated while loading", () {
108 initGraph({"app|foo.txt": "foo"});
109
110 pauseProvider();
111 // The mock provider synchronously loads the value of the assets, so this
112 // will kick off two loads with different values. The second one should
113 // win.
114 updateSources(["app|foo.txt"]);
115 modifyAsset("app|foo.txt", "bar");
116 updateSources(["app|foo.txt"]);
117
118 resumeProvider();
119 expectAsset("app|foo.txt", "bar");
120 buildShouldSucceed();
121 });
122
123 test("restarts a build if a source is updated while sources are loading", () {
124 var transformer = new RewriteTransformer("txt", "out");
125 initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]});
126
127 // Run the whole graph so all nodes are clean.
128 updateSources(["app|foo.txt", "app|other.bar"]);
129 expectAsset("app|foo.out", "foo.out");
130 expectAsset("app|other.bar");
131
132 buildShouldSucceed();
133
134 // Make the provider slow to load a source.
135 pauseProvider();
136
137 // Update an asset that doesn't trigger any transformers.
138 updateSources(["app|other.bar"]);
139
140 // Now update an asset that does trigger a transformer.
141 updateSources(["app|foo.txt"]);
142
143 resumeProvider();
144
145 buildShouldSucceed();
146
147 expect(transformer.numRuns, completion(equals(2)));
148 });
149 }
OLDNEW
« no previous file with comments | « pkg/barback/test/package_graph/repetition_test.dart ('k') | pkg/barback/test/package_graph/transform/aggregate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine