From f14e0d29bbb28b7facbdedc72547d6fdbdcbe32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 29 Sep 2024 10:47:58 +0200 Subject: [PATCH] cmd/shfmt: test that -i=0 does not skip ignore=true from EditorConfig The man page says: If any parser or printer flags are given to the tool, no EditorConfig formatting options will be used. A default like -i=0 can be used for this purpose. Since ignore=true is not a formatting option, and it's still useful when formatting options are given as flags, it should still work then. The docs said so, but we had no specific test for it. For #1095. --- cmd/shfmt/testdata/script/editorconfig.txtar | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/shfmt/testdata/script/editorconfig.txtar b/cmd/shfmt/testdata/script/editorconfig.txtar index 7a84c401..7c829a77 100644 --- a/cmd/shfmt/testdata/script/editorconfig.txtar +++ b/cmd/shfmt/testdata/script/editorconfig.txtar @@ -57,6 +57,13 @@ stdout 'regular\.sh' ! stdout 'ignored\.sh' ! stderr . +# EditorConfig ignore=true properties are obeyed even when any formatting flags +# are used, which cause formatting options from EditorConfig files to be skipped. +exec shfmt -i=0 -l ignored +stdout 'regular\.sh' +! stdout 'ignored\.sh' +! stderr . + # Formatting files directly does not obey ignore=true properties by default. # Test the various modes in which shfmt can run. ! exec shfmt -l input.sh ignored/1_lone_ignored.sh ignored/third_party/bad_syntax_ignored.sh