Repository navigation
feat: check the format of the sources with scrap format --check - #145
Merged
Merged
Conversation
With --check, no file is changed. Each file formatting would change is reported with a warning, followed by a hint to run scrap format, and the command exits with 1 when there is any.
Document that scrap format --check exits with 1 for a file formatting would change, and test that a check names a clang-format it could not start as a format does.
A check of named paths no longer suggests formatting the whole project.
scrap format --check changes no file, so its failures no longer say that formatting failed.
A check that fails exits with 1 as well, and paths that leave no file to check exit with 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--checktoscrap format. With it, no file is changed: each file formatting would change is reported, and the command exits with 1 when there is any or a file cannot be checked, and with 0 otherwise.checkFile, which compares what clang-format writes with the file. A file clang-format fails on is reported as a format reports it, undererror: failed to check 'src/a.cpp', and the other files are still checked. A file that cannot be read back to compare is reported aserror: cannot read 'src/a.cpp' to compare it with what clang-format wrote.The README describes the option.
Tests
FormatTextTest, 2 more tests: the warning and the hint, and a check that failed or could not read the file back.CliE2ETest, 4 more tests. Three run a script that stands in for clang-format onPATH: a check that reports a file and changes none, then passes once the project is formatted; a file clang-format fails on followed by the next; and a clang-format that cannot be started. One runs the clang-format of thePATHthe tests run with, and skips when there is none: a check that finds the file, then passes once the project is formatted.Each of these fails at least one test when taken out: the warning, the exit code for a file that would change, the hint, going on after a failed file, stopping at a clang-format that cannot be started, the option itself, telling a file that would change from one that would not, and the heading of a failed check.