[flutter_tools] Set basic error matcher for Linux builds (#71003)
This commit is contained in:
@@ -16,6 +16,12 @@ import '../globals.dart' as globals;
|
||||
import '../plugins.dart';
|
||||
import '../project.dart';
|
||||
|
||||
// Matches the following error and warning patterns:
|
||||
// - <file path>:<line>:<column>: error: <error...>
|
||||
// - <file path>:<line>:<column>: warning: <warning...>
|
||||
// - clang: error: <link error...>
|
||||
final RegExp errorMatcher = RegExp(r'(?:.*:\d+:\d+|clang):\s?(?:error|warning):\s.*', caseSensitive: false);
|
||||
|
||||
/// Builds the Linux project through the Makefile.
|
||||
Future<void> buildLinux(
|
||||
LinuxProject linuxProject,
|
||||
@@ -130,6 +136,7 @@ Future<void> _runBuild(Directory buildDir) async {
|
||||
'VERBOSE_SCRIPT_LOGGING': 'true'
|
||||
},
|
||||
trace: true,
|
||||
stdoutErrorMatcher: errorMatcher,
|
||||
);
|
||||
} on ArgumentError {
|
||||
throwToolExit("ninja not found. Run 'flutter doctor' for more information.");
|
||||
|
||||
@@ -209,6 +209,55 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Linux build extracts errors from stdout', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
// This contains a mix of routine build output and various types of errors
|
||||
// (Dart error, compile error, link error), edited down for compactness.
|
||||
const String stdout = r'''
|
||||
ninja: Entering directory `build/linux/release'
|
||||
[1/6] Generating /foo/linux/flutter/ephemeral/libflutter_linux_gtk.so, /foo/linux/flutter/ephemeral/flutter_linux/flutter_linux.h, _phony
|
||||
lib/main.dart:4:3: Error: Method not found: 'foo'.
|
||||
[2/6] Building CXX object CMakeFiles/foo.dir/main.cc.o
|
||||
/foo/linux/main.cc:6:2: error: expected ';' after class
|
||||
/foo/linux/main.cc:9:7: warning: unused variable 'unused_variable' [-Wunused-variable]
|
||||
/foo/linux/main.cc:10:3: error: unknown type name 'UnknownType'
|
||||
/foo/linux/main.cc:12:7: error: 'bar' is a private member of 'Foo'
|
||||
[3/6] Building CXX object CMakeFiles/foo_bar.dir/flutter/generated_plugin_registrant.cc.o
|
||||
[4/6] Building CXX object CMakeFiles/foo_bar.dir/my_application.cc.o
|
||||
[5/6] Linking CXX executable intermediates_do_not_run/foo_bar
|
||||
main.cc:(.text+0x13): undefined reference to `Foo::bar()'
|
||||
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||
ninja: build stopped: subcommand failed.
|
||||
''';
|
||||
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
cmakeCommand('release'),
|
||||
ninjaCommand('release',
|
||||
stdout: stdout,
|
||||
),
|
||||
]);
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'linux', '--no-pub']
|
||||
);
|
||||
// Just the warnings and errors should be surfaced.
|
||||
expect(testLogger.errorText, r'''
|
||||
lib/main.dart:4:3: Error: Method not found: 'foo'.
|
||||
/foo/linux/main.cc:6:2: error: expected ';' after class
|
||||
/foo/linux/main.cc:9:7: warning: unused variable 'unused_variable' [-Wunused-variable]
|
||||
/foo/linux/main.cc:10:3: error: unknown type name 'UnknownType'
|
||||
/foo/linux/main.cc:12:7: error: 'bar' is a private member of 'Foo'
|
||||
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||
''');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Platform: () => linuxPlatform,
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Linux verbose build sets VERBOSE_SCRIPT_LOGGING', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
Reference in New Issue
Block a user