Migrate ArgumentParserExampleTests to Swift Testing - #949
Conversation
12277ae to
760ba35
Compare
|
|
||
| func testCountLines() throws { | ||
| @Test func countLines() throws { | ||
| guard #available(macOS 12, *) else { return } |
There was a problem hiding this comment.
question: Out of curiosity, why do test test only run on macOS? Should the test, and related binary, be updated to run on all platforms os is the intents to verify Swift Argument Parser with the @available(...) API?
There was a problem hiding this comment.
For all these Qs, I think the gating factor was what I could get working at the time of setting up these executable tests. So the question is more about whether we can get these executable tests to run on Linux/Windows, there isn't a principled reason not to.
|
|
||
| func testCountLinesHelp() throws { | ||
| @Test func countLinesHelp() throws { | ||
| guard #available(macOS 12, *) else { return } |
There was a problem hiding this comment.
question: Out of curiosity, why do test test only run on macOS? Should the test, and related binary, be updated to run on all platforms os is the intents to verify Swift Argument Parser with the @available(...) API?
| func testMathBashCompletionScript() throws { | ||
| let script = try AssertExecuteCommand( | ||
| @Test( | ||
| .requiresProcessExecution |
There was a problem hiding this comment.
question: This trait disabled the test on some platforms, for example Windows. Is this expected?
| func testMathZshCompletionScript() throws { | ||
| let script = try AssertExecuteCommand( | ||
| @Test( | ||
| .requiresProcessExecution |
There was a problem hiding this comment.
question: This trait disabled the test on some platforms, for example Windows. Is this expected?
54cf308 to
555b885
Compare
ccc2547 to
0394d42
Compare
Migrate the four `ArgumentParserExampleTests` suites from XCTest to
Swift Testing:
- `RollDiceExampleTests`
- `CountLinesExampleTests`
- `RepeatExampleTests`
- `MathExampleTests`
Add Swift Testing counterparts for the process-executing test helpers
in `ArgumentParserTestHelpers`, which were previously only available as
methods on `extension XCTest`:
- `requireExecuteCommand` (String and [String] overloads) — uses
`#require` for unrecoverable preconditions (missing executable,
process failing to launch) and `#expect` for the exit-code and
stdout/stderr comparisons.
- `expectSnapshot` — reads/writes snapshots next to the caller's file
using `#function` as the default snapshot name, preserving the
existing `Snapshots/testMath*CompletionScript().{bash,zsh,fish}`
files.
Preserved the exact `testMath{Bash,Zsh,Fish}CompletionScript` method
names so `#function`-based snapshot lookup continues to resolve the
existing baselines without renaming files.
Relates to #710
0394d42 to
cb646b9
Compare
Migrate the four
ArgumentParserExampleTestssuites from XCTest toSwift Testing:
RollDiceExampleTestsCountLinesExampleTestsRepeatExampleTestsMathExampleTestsAdd Swift Testing counterparts for the process-executing test helpers
in
ArgumentParserTestHelpers, which were previously only available asmethods on
extension XCTest:requireExecuteCommand(String and [String] overloads) — uses#requirefor unrecoverable preconditions (missing executable,process failing to launch) and
#expectfor the exit-code andstdout/stderr comparisons.
expectSnapshot— reads/writes snapshots next to the caller's fileusing
#functionas the default snapshot name, preserving theexisting
Snapshots/testMath*CompletionScript().{bash,zsh,fish}files.
Preserved the exact
testMath{Bash,Zsh,Fish}CompletionScriptmethodnames so
#function-based snapshot lookup continues to resolve theexisting baselines without renaming files.
Relates to #710
Checklist
Stack created with GitHub Stacks CLI • Give Feedback 💬