Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
flag tests
  • Loading branch information
jmagman committed Jan 17, 2024
commit e937de9845f7c8b2a95f7d0a6f110b4a0dd64abe
44 changes: 42 additions & 2 deletions script/tool/test/format_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ void main() {
]));
});

test('skips dart if --no-dart flag is provided', () async {
const List<String> files = <String>[
'lib/a.dart',
];
createFakePlugin('a_plugin', packagesDir, extraFiles: files);

await runCapturingPrint(runner, <String>['format', '--no-dart']);
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('formats .java files', () async {
const List<String> files = <String>[
'android/src/main/java/io/flutter/plugins/a_plugin/a.java',
Expand Down Expand Up @@ -250,7 +260,7 @@ void main() {
]));
});

test('honors --java flag', () async {
test('honors --java-path flag', () async {
const List<String> files = <String>[
'android/src/main/java/io/flutter/plugins/a_plugin/a.java',
'android/src/main/java/io/flutter/plugins/a_plugin/b.java',
Expand Down Expand Up @@ -280,6 +290,16 @@ void main() {
]));
});

test('skips Java if --no-java flag is provided', () async {
const List<String> files = <String>[
'android/src/main/java/io/flutter/plugins/a_plugin/a.java',
];
createFakePlugin('a_plugin', packagesDir, extraFiles: files);

await runCapturingPrint(runner, <String>['format', '--no-java']);
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('formats c-ish files', () async {
const List<String> files = <String>[
'ios/Classes/Foo.h',
Expand Down Expand Up @@ -377,7 +397,7 @@ void main() {
]));
});

test('honors --clang-format flag', () async {
test('honors --clang-format-path flag', () async {
const List<String> files = <String>[
'windows/foo_plugin.cpp',
];
Expand Down Expand Up @@ -434,6 +454,16 @@ void main() {
]));
});

test('skips clang-format if --no-clang-format flag is provided', () async {
const List<String> files = <String>[
'linux/foo_plugin.cc',
];
createFakePlugin('a_plugin', packagesDir, extraFiles: files);

await runCapturingPrint(runner, <String>['format', '--no-clang-format']);
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

group('kotlin-format', () {
test('formats .kt files', () async {
const List<String> files = <String>[
Expand Down Expand Up @@ -488,6 +518,16 @@ void main() {
contains('Failed to format Kotlin files: exit code 1.'),
]));
});

test('skips Kotlin if --no-kotlin flag is provided', () async {
const List<String> files = <String>[
'android/src/main/kotlin/io/flutter/plugins/a_plugin/a.kt',
];
createFakePlugin('a_plugin', packagesDir, extraFiles: files);

await runCapturingPrint(runner, <String>['format', '--no-kotlin']);
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});
});

group('swift-format', () {
Expand Down