mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 10:30:28 +08:00
print status code only once and check tests
This commit is contained in:
parent
4b16b9e1a1
commit
709a1d3ff8
15
src/proc.rs
15
src/proc.rs
|
@ -1588,6 +1588,13 @@ fn proc_wants_summary_in_job(j: &Job, p: &Process) -> bool {
|
|||
true
|
||||
}
|
||||
|
||||
/// check if any of the processes in the job normally exited with non zero status code
|
||||
fn job_any_process_exited_normally_and_non_with_zero_status(j: &Job) -> bool {
|
||||
j.processes()
|
||||
.iter()
|
||||
.any(|p| p.status.normal_exited() && p.status.status_value() != 0)
|
||||
}
|
||||
|
||||
/// Return whether to emit a fish_job_summary call for a job as a whole. We may also emit this for
|
||||
/// its individual processes.
|
||||
fn job_wants_summary(j: &Job) -> bool {
|
||||
|
@ -1655,18 +1662,17 @@ fn summary_command(j: &Job, p: Option<&Process>) -> WString {
|
|||
// We are summarizing a process which exited with a signal.
|
||||
// Arguments are the signal name and description.
|
||||
buffer.push(' ');
|
||||
if p.status.normal_exited(){
|
||||
if p.status.normal_exited() {
|
||||
buffer += L!("STATUS");
|
||||
buffer.push(' ');
|
||||
buffer.push_str(&format!("{}", p.status.status_value()));
|
||||
} else{
|
||||
} else {
|
||||
let sig = Signal::new(p.status.signal_code());
|
||||
buffer += &escape(sig.name())[..];
|
||||
buffer.push(' ');
|
||||
buffer += &escape(sig.desc())[..];
|
||||
}
|
||||
|
||||
|
||||
// If we have multiple processes, we also append the pid and argv.
|
||||
if j.processes().len() > 1 {
|
||||
buffer += &sprintf!(" %d", p.pid())[..];
|
||||
|
@ -1699,7 +1705,8 @@ fn summarize_jobs(parser: &Parser, jobs: &[JobRef]) -> bool {
|
|||
}
|
||||
|
||||
// Overall status for the job.
|
||||
if job_wants_summary(j) {
|
||||
if job_wants_summary(j) && !job_any_process_exited_normally_and_non_with_zero_status(j)
|
||||
{
|
||||
call_job_summary(parser, &summary_command(j, None));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
sys.path.append("/home/cedric/projects/fish-shell/build_tools/")
|
||||
from pexpect_helper import SpawnedProc
|
||||
|
||||
sp = SpawnedProc()
|
||||
|
@ -52,6 +54,9 @@ expect_re("[0-9]+:0:sleep 20 &:SIGTERM:Polite quit request", timeout=20)
|
|||
sendline("")
|
||||
expect_prompt()
|
||||
|
||||
sendline("python -c 'import time;import sys;time.sleep(1);sys.exit(1)'")
|
||||
expect_re("Job.* has Non Zero status code 1", timeout=1)
|
||||
|
||||
# fish_job_summary is called when foreground job is signalled.
|
||||
# cmd_line contains the entire pipeline. proc_id and proc_name are set in a pipeline.
|
||||
sendline("true | sleep 6")
|
||||
|
|
7
tests/test_exit.py
Normal file
7
tests/test_exit.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import time
|
||||
import sys
|
||||
time.sleep(1)
|
||||
# exits with non zero status code
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user