Unverified Commit efc9e16e authored by Jay Mehta's avatar Jay Mehta Committed by GitHub

Fixed regex to show missing assets file error (#131160)

Added Regex to match error message from verbos build as suggested by @stuartmorgan [here](https://github.com/flutter/flutter/pull/98137#discussion_r810559589).
Modified Windows Build Test

Fixes #97065
parent 3cf206ba
......@@ -190,7 +190,16 @@ Future<void> _runBuild(
// MSBuild sends all output to stdout, including build errors. This surfaces
// known error patterns.
final RegExp errorMatcher = RegExp(r':\s*(?:warning|(?:fatal )?error).*?:');
final RegExp errorMatcher = RegExp(
<String>[
// Known error messages
r'(:\s*(?:warning|(?:fatal )?error).*?:)',
r'Error detected in pubspec\.yaml:',
// Known secondary error lines for pubspec.yaml
r'No file or variants found for asset:',
].join('|'),
);
int result;
try {
......
......@@ -962,6 +962,41 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
// Tests the case where stdout contains the error about pubspec.yaml
// And tests the case where stdout contains the error about missing assets
testUsingContext('Windows build extracts errors related to pubspec.yaml from stdout', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
const String stdout = r'''
Error detected in pubspec.yaml:
No file or variants found for asset: images/a_dot_burr.jpeg.
''';
processManager = FakeProcessManager.list(<FakeCommand>[
cmakeGenerationCommand(),
buildCommand('Release',
stdout: stdout,
),
]);
await createTestCommandRunner(command).run(
const <String>['windows', '--no-pub']
);
// Just the warnings and errors should be surfaced.
expect(testLogger.errorText, r'''
Error detected in pubspec.yaml:
No file or variants found for asset: images/a_dot_burr.jpeg.
''');
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Platform: () => windowsPlatform,
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
}
class FakeVisualStudio extends Fake implements VisualStudio {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment