Repository navigation
refactor: move what any external tool needs out of clang-format - #146
Merged
Merged
Conversation
Finding a program on PATH, asking it for its version, running it and describing why it could not run or failed hold nothing particular to clang-format. They move to src/tool and command/ToolText, which take the tool's name, so another tool can use them as they are. ClangFormat keeps the command lines of a format and a check, and FormatText the messages that name a file.
Both were left out of the linted modules, so the code that runs clang-format and other tools was never checked.
ExternalTool holds the name the messages give the tool, so the messages about a tool that was found take the tool alone. lookUpTool finds a tool, learns its version and names it on standard error, as the format command did itself, so another command can do the same.
runTool and standardOutputOf are tested on their own, including the second run that reads why a run failed. The header names Process::runProgram again as why the streams cannot be read apart, and the new command sources sit in order in the source list.
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
Moves what any external tool needs out of the clang-format code, so a second tool can use it without a copy. Nothing a user sees changes.
src/tool/ExternalToolholds the tool's name, program and version (ExternalTool), why it could not run or failed (ToolNotRun,ToolFailed), finding it onPATHby name (findTool), asking it for its version (describeTool), and running it (runTool,standardOutputOf).command/ToolTextholds the messages about a tool: the line naming the tool in use, the one saying it was not found, a version that could not be learned, and a run that failed under a given heading.command/ToolLookupfinds a tool, learns its version and names it on standard error (lookUpTool), which the format command did itself.format/ClangFormatkeeps the command lines of a format and a check, andcommand/FormatTextthe messages that name a file.src/formatandsrc/tooljoin the linted modules.src/formathad been left out, so the code moved here was not checked before; the one finding, a missing<cstddef>, is fixed in the moved code.Tests
The tests of finding a tool and reading its version move from
ClangFormatTesttoExternalToolTest, and those of the tool messages fromFormatTextTesttoToolTextTest, with the name of the tool now given and kept inExternalTool.ToolTextTesthas one more test, of a failed run under a heading, whichFormatTextTestcovered only through a format, andExternalToolTestthree more, ofrunToolandstandardOutputOf, whichClangFormatTestcovered only through a format and a check.