mirror of
https://github.com/flutter/packages.git
synced 2025-06-02 00:49:11 +08:00
[flutter_plugin_tools] If clang-format
does not run, fall back to other executables in PATH (#6853)
* If clang-format does not run, fall back to other executables in PATH * Review edits
This commit is contained in:
@ -332,6 +332,44 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
test('falls back to working clang-format in the path', () async {
|
||||
const List<String> files = <String>[
|
||||
'linux/foo_plugin.cc',
|
||||
'macos/Classes/Foo.h',
|
||||
];
|
||||
final RepositoryPackage plugin = createFakePlugin(
|
||||
'a_plugin',
|
||||
packagesDir,
|
||||
extraFiles: files,
|
||||
);
|
||||
|
||||
processRunner.mockProcessesForExecutable['clang-format'] = <io.Process>[
|
||||
MockProcess(exitCode: 1)
|
||||
];
|
||||
processRunner.mockProcessesForExecutable['which'] = <io.Process>[
|
||||
MockProcess(
|
||||
stdout: '/usr/local/bin/clang-format\n/path/to/working-clang-format')
|
||||
];
|
||||
processRunner.mockProcessesForExecutable['/usr/local/bin/clang-format'] =
|
||||
<io.Process>[MockProcess(exitCode: 1)];
|
||||
await runCapturingPrint(runner, <String>['format']);
|
||||
|
||||
expect(
|
||||
processRunner.recordedCalls,
|
||||
containsAll(<ProcessCall>[
|
||||
const ProcessCall(
|
||||
'/path/to/working-clang-format', <String>['--version'], null),
|
||||
ProcessCall(
|
||||
'/path/to/working-clang-format',
|
||||
<String>[
|
||||
'-i',
|
||||
'--style=file',
|
||||
...getPackagesDirRelativePaths(plugin, files)
|
||||
],
|
||||
packagesDir.path),
|
||||
]));
|
||||
});
|
||||
|
||||
test('honors --clang-format flag', () async {
|
||||
const List<String> files = <String>[
|
||||
'windows/foo_plugin.cpp',
|
||||
|
Reference in New Issue
Block a user