@@ -8,6 +8,16 @@ import 'invalidation_tester.dart';
8
8
9
9
/// Invalidation tests in which the inputs are individually read arbitrary
10
10
/// assets.
11
+ ///
12
+ /// In the test names:
13
+ ///
14
+ /// - `a1 <-- a2` means a1 is the primary input of a2, but _not_ an input:
15
+ /// the builder does not read a1
16
+ /// - `a1 <== a2` means a1 is the primary input of a2 _and_ is an input:
17
+ /// the builder _does_ read a1
18
+ /// - `[a1]` means a1 is an optional output
19
+ /// - `a1+(z1+z2) <-- a2` means z1 and z2 are non-primary inputs of a2
20
+
11
21
void main () {
12
22
late InvalidationTester tester;
13
23
@@ -88,4 +98,95 @@ void main() {
88
98
);
89
99
});
90
100
});
101
+
102
+ // The same as the previous group, but a.2 is now an optional output.
103
+ group ('a.1 <== [a.2], b.3+(a.2) <== b.4' , () {
104
+ setUp (() {
105
+ tester.sources (['a.1' , 'b.3' ]);
106
+ tester.builder (from: '.1' , to: '.2' , isOptional: true )
107
+ ..reads ('.1' )
108
+ ..writes ('.2' );
109
+ tester.builder (from: '.3' , to: '.4' )
110
+ ..reads ('.3' )
111
+ ..readsOther ('a.2' )
112
+ ..writes ('.4' );
113
+ });
114
+
115
+ test ('b.4 is built' , () async {
116
+ expect (await tester.build (), Result (written: ['a.2' , 'b.4' ]));
117
+ });
118
+
119
+ test ('change a.1, a.2+b.4 are rebuilt' , () async {
120
+ await tester.build ();
121
+ expect (
122
+ await tester.build (change: 'a.1' ),
123
+ Result (written: ['a.2' , 'b.4' ]),
124
+ );
125
+ });
126
+
127
+ test ('delete a.1, a.2 is deleted and b.4 is rebuilt' , () async {
128
+ await tester.build ();
129
+ expect (
130
+ await tester.build (delete: 'a.1' ),
131
+ Result (deleted: ['a.2' ], written: ['b.4' ]),
132
+ );
133
+ });
134
+
135
+ test ('create a.1, a.2+b.4 are rebuilt' , () async {
136
+ tester.sources (['b.3' ]);
137
+ await tester.build ();
138
+ expect (
139
+ await tester.build (create: 'a.1' ),
140
+ Result (written: ['a.2' , 'b.4' ]),
141
+ );
142
+ });
143
+ });
144
+
145
+ // As previous group but with b.4 now optional and introducing c.6 that
146
+ // depends on it.
147
+ group ('a.1 <== [a.2], b.3+(a.2) <== [b.4], c.5+(b.4) <== c.6' , () {
148
+ setUp (() {
149
+ tester.sources (['a.1' , 'b.3' , 'c.5' ]);
150
+ tester.builder (from: '.1' , to: '.2' , isOptional: true )
151
+ ..reads ('.1' )
152
+ ..writes ('.2' );
153
+ tester.builder (from: '.3' , to: '.4' , isOptional: true )
154
+ ..reads ('.3' )
155
+ ..readsOther ('a.2' )
156
+ ..writes ('.4' );
157
+ tester.builder (from: '.5' , to: '.6' )
158
+ ..reads ('.5' )
159
+ ..readsOther ('b.4' )
160
+ ..writes ('.6' );
161
+ });
162
+
163
+ test ('c.6 is built' , () async {
164
+ expect (await tester.build (), Result (written: ['a.2' , 'b.4' , 'c.6' ]));
165
+ });
166
+
167
+ test ('change a.1, a.2+b.4+c.6 are rebuilt' , () async {
168
+ await tester.build ();
169
+ expect (
170
+ await tester.build (change: 'a.1' ),
171
+ Result (written: ['a.2' , 'b.4' , 'c.6' ]),
172
+ );
173
+ });
174
+
175
+ test ('delete a.1, a.2 is deleted and b.4+c.6 are rebuilt' , () async {
176
+ await tester.build ();
177
+ expect (
178
+ await tester.build (delete: 'a.1' ),
179
+ Result (deleted: ['a.2' ], written: ['b.4' , 'c.6' ]),
180
+ );
181
+ });
182
+
183
+ test ('create a.1, a.2+b.4+c.6 are rebuilt' , () async {
184
+ tester.sources (['b.3' , 'c.5' ]);
185
+ await tester.build ();
186
+ expect (
187
+ await tester.build (create: 'a.1' ),
188
+ Result (written: ['a.2' , 'b.4' , 'c.6' ]),
189
+ );
190
+ });
191
+ });
91
192
}
0 commit comments