@@ -51,12 +51,11 @@ void main() {
51
51
52
52
final AssetTransformer transformer = AssetTransformer (
53
53
processManager: processManager,
54
- logger: logger,
55
54
fileSystem: fileSystem,
56
55
dartBinaryPath: artifacts.getArtifactPath (Artifact .engineDartBinary),
57
56
);
58
57
59
- final bool transformationSuccessful = await transformer.transformAsset (
58
+ final AssetTransformationFailure ? transformationFailure = await transformer.transformAsset (
60
59
asset: asset,
61
60
outputPath: outputPath,
62
61
workingDirectory: fileSystem.currentDirectory.path,
@@ -72,13 +71,12 @@ void main() {
72
71
],
73
72
);
74
73
75
- expect (transformationSuccessful, isTrue , reason: logger.errorText);
74
+ expect (transformationFailure, isNull , reason: logger.errorText);
76
75
expect (processManager, hasNoRemainingExpectations);
77
76
});
78
77
79
78
testWithoutContext ('logs useful error information when transformation process returns a nonzero exit code' , () async {
80
79
final FileSystem fileSystem = MemoryFileSystem .test ();
81
- final BufferLogger logger = BufferLogger .test ();
82
80
final Artifacts artifacts = Artifacts .test ();
83
81
84
82
final File asset = fileSystem.file ('asset.txt' )..createSync ();
@@ -110,12 +108,11 @@ void main() {
110
108
111
109
final AssetTransformer transformer = AssetTransformer (
112
110
processManager: processManager,
113
- logger: logger,
114
111
fileSystem: fileSystem,
115
112
dartBinaryPath: dartBinaryPath,
116
113
);
117
114
118
- final bool transformationSuccessful = await transformer.transformAsset (
115
+ final AssetTransformationFailure ? failure = await transformer.transformAsset (
119
116
asset: asset,
120
117
outputPath: outputPath,
121
118
workingDirectory: fileSystem.currentDirectory.path,
@@ -127,10 +124,10 @@ void main() {
127
124
],
128
125
);
129
126
130
- expect (transformationSuccessful, false , reason: logger.errorText);
131
127
expect (asset, exists);
132
128
expect (processManager, hasNoRemainingExpectations);
133
- expect (logger.errorText, contains (
129
+ expect (failure, isNotNull);
130
+ expect (failure! .message,
134
131
'''
135
132
User-defined transformation of asset "asset.txt" failed.
136
133
Transformer process terminated with non-zero exit code: 1
@@ -139,13 +136,11 @@ Full command: $dartBinaryPath run my_transformer --input=/.tmp_rand0/asset.txt-t
139
136
stdout:
140
137
Beginning transformation
141
138
stderr:
142
- Something went wrong
143
- ''' ));
139
+ Something went wrong''' );
144
140
});
145
141
146
142
testWithoutContext ('prints error message when the transformer does not produce an output file' , () async {
147
143
final FileSystem fileSystem = MemoryFileSystem .test ();
148
- final BufferLogger logger = BufferLogger .test ();
149
144
final Artifacts artifacts = Artifacts .test ();
150
145
151
146
final File asset = fileSystem.file ('asset.txt' )..createSync ();
@@ -171,12 +166,11 @@ Something went wrong
171
166
172
167
final AssetTransformer transformer = AssetTransformer (
173
168
processManager: processManager,
174
- logger: logger,
175
169
fileSystem: fileSystem,
176
170
dartBinaryPath: dartBinaryPath,
177
171
);
178
172
179
- final bool transformationSuccessful = await transformer.transformAsset (
173
+ final AssetTransformationFailure ? failure = await transformer.transformAsset (
180
174
asset: asset,
181
175
outputPath: outputPath,
182
176
workingDirectory: fileSystem.currentDirectory.path,
@@ -189,7 +183,8 @@ Something went wrong
189
183
);
190
184
191
185
expect (processManager, hasNoRemainingExpectations);
192
- expect (logger.errorText,
186
+ expect (failure, isNotNull);
187
+ expect (failure! .message,
193
188
'''
194
189
User-defined transformation of asset "asset.txt" failed.
195
190
Asset transformer my_transformer did not produce an output file.
@@ -199,15 +194,12 @@ Full command: $dartBinaryPath run my_transformer --input=/.tmp_rand0/asset.txt-t
199
194
stdout:
200
195
201
196
stderr:
202
- Transformation failed, but I forgot to exit with a non-zero code.
203
- '''
197
+ Transformation failed, but I forgot to exit with a non-zero code.'''
204
198
);
205
- expect (transformationSuccessful, false );
206
199
});
207
200
208
201
testWithoutContext ('correctly chains transformations when there are multiple of them' , () async {
209
202
final FileSystem fileSystem = MemoryFileSystem .test ();
210
- final BufferLogger logger = BufferLogger .test ();
211
203
final Artifacts artifacts = Artifacts .test ();
212
204
213
205
final File asset = fileSystem.file ('asset.txt' )
@@ -267,12 +259,11 @@ Transformation failed, but I forgot to exit with a non-zero code.
267
259
268
260
final AssetTransformer transformer = AssetTransformer (
269
261
processManager: processManager,
270
- logger: logger,
271
262
fileSystem: fileSystem,
272
263
dartBinaryPath: dartBinaryPath,
273
264
);
274
265
275
- await transformer.transformAsset (
266
+ final AssetTransformationFailure ? failure = await transformer.transformAsset (
276
267
asset: asset,
277
268
outputPath: outputPath,
278
269
workingDirectory: fileSystem.currentDirectory.path,
@@ -289,12 +280,12 @@ Transformation failed, but I forgot to exit with a non-zero code.
289
280
);
290
281
291
282
expect (processManager, hasNoRemainingExpectations);
283
+ expect (failure, isNull);
292
284
expect (fileSystem.file (outputPath).readAsStringSync (), '012' );
293
285
});
294
286
295
287
testWithoutContext ('prints an error when a transformer in a chain (thats not the first) does not produce an output' , () async {
296
288
final FileSystem fileSystem = MemoryFileSystem ();
297
- final BufferLogger logger = BufferLogger .test ();
298
289
final Artifacts artifacts = Artifacts .test ();
299
290
300
291
final File asset = fileSystem.file ('asset.txt' )
@@ -341,12 +332,11 @@ Transformation failed, but I forgot to exit with a non-zero code.
341
332
342
333
final AssetTransformer transformer = AssetTransformer (
343
334
processManager: processManager,
344
- logger: logger,
345
335
fileSystem: fileSystem,
346
336
dartBinaryPath: dartBinaryPath,
347
337
);
348
338
349
- final bool transformationSuccessful = await transformer.transformAsset (
339
+ final AssetTransformationFailure ? failure = await transformer.transformAsset (
350
340
asset: asset,
351
341
outputPath: outputPath,
352
342
workingDirectory: fileSystem.currentDirectory.path,
@@ -362,10 +352,8 @@ Transformation failed, but I forgot to exit with a non-zero code.
362
352
],
363
353
);
364
354
365
- expect (transformationSuccessful, isFalse);
366
- expect (processManager, hasNoRemainingExpectations);
367
- expect (fileSystem.file (outputPath), isNot (exists));
368
- expect (logger.errorText,
355
+ expect (failure, isNotNull);
356
+ expect (failure! .message,
369
357
'''
370
358
User-defined transformation of asset "asset.txt" failed.
371
359
Asset transformer my_distance_from_ascii_a_transformer did not produce an output file.
@@ -375,9 +363,10 @@ Full command: Artifact.engineDartBinary run my_distance_from_ascii_a_transformer
375
363
stdout:
376
364
377
365
stderr:
378
- Transformation failed, but I forgot to exit with a non-zero code.
379
- '''
366
+ Transformation failed, but I forgot to exit with a non-zero code.'''
380
367
);
368
+ expect (processManager, hasNoRemainingExpectations);
369
+ expect (fileSystem.file (outputPath), isNot (exists));
381
370
expect (fileSystem.systemTempDirectory.listSync (), isEmpty);
382
371
});
383
372
}
0 commit comments