Skip to content

Commit 1508238

Browse files
authored
[flutter_tool] Include impellerc output in ShaderCompilerException (#108348)
1 parent 41940c9 commit 1508238

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,16 @@ class ShaderCompiler {
181181
final Process impellercProcess = await _processManager.start(cmd);
182182
final int code = await impellercProcess.exitCode;
183183
if (code != 0) {
184-
_logger.printTrace(await utf8.decodeStream(impellercProcess.stdout));
185-
_logger.printError(await utf8.decodeStream(impellercProcess.stderr));
184+
final String stdout = await utf8.decodeStream(impellercProcess.stdout);
185+
final String stderr = await utf8.decodeStream(impellercProcess.stderr);
186+
_logger.printTrace(stdout);
187+
_logger.printError(stderr);
186188
if (fatal) {
187189
throw ShaderCompilerException._(
188190
'Shader compilation of "${input.path}" to "$outputPath" '
189-
'failed with exit code $code.',
191+
'failed with exit code $code.\n'
192+
'impellerc stdout:\n$stdout\n'
193+
'impellerc stderr:\n$stderr',
190194
);
191195
}
192196
return false;

packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ void main() {
199199
'--input-type=frag',
200200
'--include=$fragDir',
201201
],
202+
stdout: 'impellerc stdout',
203+
stderr: 'impellerc stderr',
202204
exitCode: 1,
203205
),
204206
]);
@@ -209,14 +211,18 @@ void main() {
209211
artifacts: artifacts,
210212
);
211213

212-
await expectLater(
213-
() => shaderCompiler.compileShader(
214+
try {
215+
await shaderCompiler.compileShader(
214216
input: fileSystem.file(notFragPath),
215217
outputPath: outputPath,
216218
target: ShaderTarget.sksl,
217-
),
218-
throwsA(isA<ShaderCompilerException>()),
219-
);
219+
);
220+
fail('unreachable');
221+
} on ShaderCompilerException catch (e) {
222+
expect(e.toString(), contains('impellerc stdout:\nimpellerc stdout'));
223+
expect(e.toString(), contains('impellerc stderr:\nimpellerc stderr'));
224+
}
225+
220226
expect(fileSystem.file(outputPath).existsSync(), false);
221227
});
222228

0 commit comments

Comments
 (0)