Skip to content

Commit d28b7a7

Browse files
Fix #98.
While one command is waiting on the jobs semaphore, another command can fail. Need to check exit on error condiition after acquiring semaphore.
1 parent 6fca752 commit d28b7a7

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/command.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ impl CommandService {
141141
return Ok(());
142142
}
143143

144-
if self.command_line_args.exit_on_error && self.context.command_metrics.error_occurred() {
145-
trace!("return from spawn_command due to exit_on_error");
146-
return Ok(());
147-
}
148-
149144
let context_clone = Arc::clone(&self.context);
150145

151146
let output_sender = self.output_writer.sender();
@@ -155,6 +150,11 @@ impl CommandService {
155150
.await
156151
.context("command_semaphore.acquire_owned error")?;
157152

153+
if self.command_line_args.exit_on_error && self.context.command_metrics.error_occurred() {
154+
trace!("return from spawn_command due to exit_on_error");
155+
return Ok(());
156+
}
157+
158158
tokio::spawn(async move {
159159
command.run(&context_clone, output_sender).await;
160160

tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ fn test_exit_status_on_failing_commands_exit_on_error() {
603603
.failure()
604604
.code(1)
605605
.stdout(
606-
(predicate::str::contains("command failed"))
606+
(predicate::str::contains("command failed").count(1))
607607
.and(predicate::str::contains("command failures:"))
608608
.and(predicate::str::contains("exit_status_errors=0").not()),
609609
)

0 commit comments

Comments
 (0)