Add --check support to EOF and Trailing Whitespace fixers

This change adds an advisory mode via `--check` that only warns of
formatting issues with files, but does not address them.

This support is desirable because--while I don't mind the automagic
changes when done in a mechanical way--some individuals who I
described the current behavior of these fixers to were a bit uneasy
about the magic that went along with them. Adding `--check` so
others can opt out (similar to `black --check`) is a compromise on
this front.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
This commit is contained in:
Enji Cooper 2019-12-18 17:25:07 -08:00
parent 5df1a4bf6f
commit a17514d55e
4 changed files with 65 additions and 20 deletions

View file

@ -40,3 +40,15 @@ def test_integration(input_s, expected_retval, output, tmpdir):
assert file_output == output
assert ret == expected_retval
@pytest.mark.parametrize(('input_s', 'expected_retval', 'output'), TESTS)
def test_integration_check(input_s, expected_retval, output, tmpdir):
path = tmpdir.join('file.txt')
path.write_binary(input_s)
ret = main(['--check', path.strpath])
file_output = path.read_binary()
assert file_output == input_s
assert ret == expected_retval