Skip to content

Commit

Permalink
feat(cli): Gracefully handle errors with make outputting status for u…
Browse files Browse the repository at this point in the history
…nwrapped jobs
  • Loading branch information
alerque committed Mar 26, 2024
1 parent 0bf89ae commit a58857a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
3 changes: 3 additions & 0 deletions assets/en-US/cli.ftl
Expand Up @@ -112,6 +112,9 @@ make-error-build =
make-error-target =
Make failed to execute a recipe.
make-error-unidentified-target =
Make asked to print output related to a target we didn't know was running: { $target }
make-error-unknown =
Make returned unknown error.
Expand Down
75 changes: 52 additions & 23 deletions src/make/mod.rs
Expand Up @@ -101,37 +101,66 @@ pub fn run(target: Vec<String>) -> Result<()> {
}
"STDOUT" => {
let target = fields[2].to_owned();
let target_status = target_statuses.get(&target).unwrap();
if is_gha || is_glc {
target_status.stdout(fields[3]);
} else if CONF.get_bool("verbose")? {
target_status.stderr(fields[3]);
} else {
backlog.push(String::from(fields[3]));
let target_status = target_statuses.get(&target);
match target_status {
Some(target_status) => {
if is_gha || is_glc {
target_status.stdout(fields[3]);
} else if CONF.get_bool("verbose")? {
target_status.stderr(fields[3]);
} else {
backlog.push(String::from(fields[3]));
}
},
None =>{
let text = LocalText::new("make-error-unknown-target").
arg("target", style(target).white()).fmt();
eprintln!("{}", style(text).red());
backlog.push(String::from(fields[3]));
}
}
}
"STDERR" => {
let target = fields[2].to_owned();
let target_status = target_statuses.get(&target).unwrap();
if is_gha || is_glc {
target_status.stderr(fields[3]);
} else if CONF.get_bool("verbose")? {
target_status.stdout(fields[3]);
} else {
backlog.push(String::from(fields[3]));
let target_status = target_statuses.get(&target);
match target_status {
Some(target_status) => {
if is_gha || is_glc {
target_status.stderr(fields[3]);
} else if CONF.get_bool("verbose")? {
target_status.stdout(fields[3]);
} else {
backlog.push(String::from(fields[3]));
}
},
None => {
let text = LocalText::new("make-error-unknown-target").
arg("target", style(target).white()).fmt();
eprintln!("{}", style(text).red());
backlog.push(String::from(fields[3]));
}
}
}
"POST" => {
let target = fields[3].to_owned();
let target_status = target_statuses.get(&target).unwrap();
match fields[2] {
"0" => {
target_status.pass();
}
val => {
target_status.fail();
ret = val.parse().unwrap_or(1);
}
let target_status = target_statuses.get(&target);
match target_status {
Some(target_status) => {
match fields[2] {
"0" => {
target_status.pass();
}
val => {
target_status.fail();
ret = val.parse().unwrap_or(1);
}
}
},
None => {
let text = LocalText::new("make-error-unknown-target").
arg("target", style(target).white()).fmt();
eprintln!("{}", style(text).red());
},
}
}
_ => {
Expand Down

0 comments on commit a58857a

Please sign in to comment.