Skip to content

Commit efc9e16

Browse files
Fixed regex to show missing assets file error (#131160)
Added Regex to match error message from verbos build as suggested by @stuartmorgan [here](flutter/flutter#98137 (comment)). Modified Windows Build Test Fixes #97065
1 parent 3cf206b commit efc9e16

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

packages/flutter_tools/lib/src/windows/build_windows.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,16 @@ Future<void> _runBuild(
190190

191191
// MSBuild sends all output to stdout, including build errors. This surfaces
192192
// known error patterns.
193-
final RegExp errorMatcher = RegExp(r':\s*(?:warning|(?:fatal )?error).*?:');
193+
final RegExp errorMatcher = RegExp(
194+
<String>[
195+
// Known error messages
196+
r'(:\s*(?:warning|(?:fatal )?error).*?:)',
197+
r'Error detected in pubspec\.yaml:',
198+
199+
// Known secondary error lines for pubspec.yaml
200+
r'No file or variants found for asset:',
201+
].join('|'),
202+
);
194203

195204
int result;
196205
try {

packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,41 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
962962
ProcessManager: () => FakeProcessManager.any(),
963963
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
964964
});
965+
966+
// Tests the case where stdout contains the error about pubspec.yaml
967+
// And tests the case where stdout contains the error about missing assets
968+
testUsingContext('Windows build extracts errors related to pubspec.yaml from stdout', () async {
969+
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
970+
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
971+
..visualStudioOverride = fakeVisualStudio;
972+
setUpMockProjectFilesForBuild();
973+
974+
const String stdout = r'''
975+
Error detected in pubspec.yaml:
976+
No file or variants found for asset: images/a_dot_burr.jpeg.
977+
''';
978+
979+
processManager = FakeProcessManager.list(<FakeCommand>[
980+
cmakeGenerationCommand(),
981+
buildCommand('Release',
982+
stdout: stdout,
983+
),
984+
]);
985+
986+
await createTestCommandRunner(command).run(
987+
const <String>['windows', '--no-pub']
988+
);
989+
// Just the warnings and errors should be surfaced.
990+
expect(testLogger.errorText, r'''
991+
Error detected in pubspec.yaml:
992+
No file or variants found for asset: images/a_dot_burr.jpeg.
993+
''');
994+
}, overrides: <Type, Generator>{
995+
FileSystem: () => fileSystem,
996+
ProcessManager: () => processManager,
997+
Platform: () => windowsPlatform,
998+
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
999+
});
9651000
}
9661001

9671002
class FakeVisualStudio extends Fake implements VisualStudio {

0 commit comments

Comments
 (0)