Repository navigation
Omit help text on runtime errors in xcprojformatter - #31
Open
zachshallbetter wants to merge 2 commits into
Open
zachshallbetter wants to merge 2 commits into
zachshallbetter wants to merge 2 commits into
Conversation
zachshallbetter
marked this pull request as ready for review
November 24, 2026 07:04
zachshallbetter
requested review from
deccylol,
jakepetroules,
jonathanjhess,
owenv and
rconnell9
as code owners
November 24, 2026 07:04
deccylol
reviewed
Nov 24, 2026
| } catch { | ||
| let error = error as NSError | ||
| let message = error.localizedDescriptionCombinedWithRecoverySuggestionIfPresent + "\n\n----------------------------\n\n" | ||
| try? FileHandle.standardError.write(contentsOf: message.utf8.asData) |
Collaborator
There was a problem hiding this comment.
We could wrap this in a printError() as the code is duplicated on the new 37/38 line as well.
deccylol
reviewed
Nov 24, 2026
| } | ||
|
|
||
| private func runFormatter(_ arguments: [String], stdin: Data? = nil) throws -> ProcessResult { | ||
| let process = Process() |
Collaborator
There was a problem hiding this comment.
Want to take a dependency on swift-subprocess? @jakepetroules
There are a handful of other PRs also exercising this "find build products and run the executable behavior." (#30, #2) Ideally, if possible, all 3 of these new tests don't copy the same code everywhere just to get something specific from stdio or exit statuses.
Author
Author
|
Could someone approve the CI run for |
Author
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.
Type of change
xcprojformatter(CLI) changeSummary
Separates argument-parsing errors from runtime/decode/I/O errors in
xcprojformatterso that decode, malformed-input, and unreadable-file failures print only the error diagnostic tostderrwithout appending the separator and full--helpusage text.Also replaces
try!writes tostderrwithtry?so brokenstderrpipes don't trap, and returns exit status1instead of-1(255) on errors. Kept independent of #2 and #30.Related issue
Fixes #27
Related (not bundled): #2, #30
Changes
Sources/Tool/main.swift:Arguments(commandLine:)error handling (which still prints--helptostderr) fromreadInputData,prettyPrint, andwriteOutputerrors (which now print only the diagnostic).try!when writing tostderrwithtry?and changed error exit status from-1to1.Sources/Tests/FormatterErrorOutputTests.swift: Added focused tests (guarded formacOS || Linux || Windows) covering decode failure (Missing required value for key “name” at “/targets[0]”), malformed JSON, unreadable input, and invalid CLI arguments.Testing
swift test) — 35 tests in 7 suites passed (TestPerformanceskipped in debug configuration), plusswift build -c releasesucceeded.FormatterErrorOutputTests: 4 tests).FormatterErrorOutputTestsagainst the builtxcprojformatterbinary.Checklist