jjrscott
(John Scott)
September 23, 2024, 3:46pm
1
I'm trying to use swift run --quiet
to get just the output from the executable. I thought that --quiet
would work given the description "Decrease verbosity to only include error output." but, no matter what I do, I keep getting build output on stderr:
[1/1] Write swift-version-62C46B7DD7C58376.txt
Build complete! (0.09s)
Is there a way to disable these messages?
1 Like
hassila
(Joakim Hassila)
September 23, 2024, 4:44pm
2
I believe this was fixed but may have regressed - see e.g.
swiftlang:main
← clayellis:quiet
opened 08:39PM - 21 Dec 22 UTC
This PR adds a quiet flag (`-q`, `--quiet`) to `swift` commands which suppresses… all but error output.
### Motivation:
Closes #4395. Executable targets often depend on the output of other executable targets. When an executable target is run with `swift`, there is currently no way to suppress the build output, which makes it more difficult to pass the output of one executable as the input of another. The new quiet flag suppresses all output except errors.
### Modifications:
- Added a `@Flag` to `LoggingOptions`
- Interpret that flag as a `Diagnostic.Severity` in `LoggingOptions.logLevel`.
- Added tests for both the short and long flag.
### Result:
When a user passes the quiet flag, only errors will be logged.
opened 05:22PM - 06 Aug 21 UTC
closed 11:41PM - 21 Dec 22 UTC
enhancement
| | |
|------------------|-----------------|…
|Previous ID | SR-15037 |
|Radar | rdar://problem/81620352 |
|Original Reporter | @BenchR267 |
|Type | New Feature |
<details>
<summary>Additional Detail from JIRA</summary>
| | |
|------------------|-----------------|
|Votes | 1 |
|Component/s | Package Manager |
|Labels | New Feature |
|Assignee | None |
|Priority | Medium |
md5: c5f31e82419529323d967dcf872f390c
</details>
**Issue Description:**
\`swift run\` is often used for running Swift scripts. When running those scripts from other scripts, the output is in an expected format and should not contain any output from SwiftPM itself.
Currently, all output from SwiftPM seems to be printed on stderr so it's an option to nuke that in those situations (\`2\>\>/dev/null\`). But that doesn't work if the script itself is using stderr too.
I propose to add a new option to \`swift run\` which suppresses all output about building the script and only prints the output of the executable itself, \`--quiet\`.
Open for discussion is how build failures are surfaced to the user and I don't have a strong opinion on that. It could suppress that too making the command fail silently and only provide the exit status as indicator for failure or it could print those out instead since the executable will never run anyway.
and also
swiftlang:main
← clayellis:quiet-build-test
opened 07:13AM - 25 Dec 23 UTC
Only output when tests and builds fail if the `--quiet` flag is present.
### … Motivation:
Resolves the latest conversation on #4395 concerning how the `--quiet` flag doesn't do what it advertises when used with `swift test` and `swift build`.
### Modifications:
- When not testing in parallel, and `--quiet` is present, collect output until tests finish and print output to stdout conditionally.
- Pass `LoggingOptions` into `ParallelTestRunner`.
- Determine if any of the parallel tests failed and, if so, output all test results (regardless of passing status) if `--quiet` is present.
- Adds three new test fixtures (`TestQuietPass`, `TestQuietPassFail`, `TestQuietFail`) for testing the quiet flag
- Adds tests for the `--quiet` flag when all tests pass, when some tests pass/fail, when all tests fail.
- Redirect build output to a thread-safe buffered output stream that will be flushed to stdout if a build fails when `--quiet` is present.
- Adds tests for the `--quiet` flag when a build passes and when one fails.
### Result:
If tests pass successfully and the `--quiet` flag is present, nothing will be output. Output as normal when tests fail. The only notable change to output in the failure case is that when running tests in parallel (`--parallel`), the progress animation is not updated.
If a build succeeds and the `--quiet` flag is present, nothing will be output. If a build fails with the flag, the build output will appear as normal on `stdout`.
(you may want to file a new issue or provide a PR if possible to fix it...)
2 Likes
jjrscott
(John Scott)
September 23, 2024, 9:44pm
3
Thank you hassila , I'm stuck on Xcode 15.4 for the next month but I'll check after I upgrade and submit an issue if needed.
At least it's good to know --quiet means what I think it means.