-
Notifications
You must be signed in to change notification settings - Fork 40
Add non-global ways to set debug and pipefail modes #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tao-guo
merged 2 commits into
rust-shell-script:master
from
delan:non-global-debug-pipefail
Aug 3, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ fn test_vars_in_str3() { | |
} | ||
|
||
#[test] | ||
// FIXME: doctests have no effect here, and we need to split these into one test per error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the notes, yeah I it is a known issue and I was just manually testing them previously. |
||
/// ```compile_fail | ||
/// run_cmd!(echo "${msg0}").unwrap(); | ||
/// assert_eq!(run_fun!(echo "${ msg }").unwrap(), "${ msg }"); | ||
|
@@ -144,15 +145,16 @@ fn test_pipe() { | |
assert!(run_cmd!(false | wc).is_err()); | ||
assert!(run_cmd!(echo xx | false | wc | wc | wc).is_err()); | ||
|
||
set_pipefail(false); | ||
let _pipefail = ScopedPipefail::set(false); | ||
assert!(run_cmd!(du -ah . | sort -hr | head -n 10).is_ok()); | ||
set_pipefail(true); | ||
let _pipefail = ScopedPipefail::set(true); | ||
|
||
let wc_cmd = "wc"; | ||
assert!(run_cmd!(ls | $wc_cmd).is_ok()); | ||
} | ||
|
||
// test `ignore` command and pipefail mode | ||
// FIXME: make set_pipefail() thread safe, then move this to a separate test_ignore_and_pipefail() | ||
#[test] | ||
fn test_ignore_and_pipefail() { | ||
struct TestCase { | ||
/// Run the test case, returning whether the result `.is_ok()`. | ||
code: fn() -> bool, | ||
|
@@ -260,20 +262,21 @@ fn test_pipe() { | |
"{} when pipefail is on", | ||
case.code_str | ||
); | ||
set_pipefail(false); | ||
let _pipefail = ScopedPipefail::set(false); | ||
ok &= check_eq!( | ||
(case.code)(), | ||
case.expected_ok_pipefail_off, | ||
"{} when pipefail is off", | ||
case.code_str | ||
); | ||
set_pipefail(true); | ||
let _pipefail = ScopedPipefail::set(true); | ||
} | ||
|
||
assert!(ok); | ||
} | ||
|
||
#[test] | ||
// FIXME: doctests have no effect here, and we need to split these into one test per error | ||
/// ```compile_fail | ||
/// run_cmd!(ls > >&1).unwrap(); | ||
/// run_cmd!(ls >>&1).unwrap(); | ||
|
@@ -345,6 +348,7 @@ fn test_current_dir() { | |
} | ||
|
||
#[test] | ||
// FIXME: doctests have no effect here, and we need to split these into one test per error | ||
/// ```compile_fail | ||
/// run_cmd!(ls / /x &>>> /tmp/f).unwrap(); | ||
/// run_cmd!(ls / /x &> > /tmp/f).unwrap(); | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed docs!