Skip to content

Commit

Permalink
rustdoc: Set a nonzero exit status on failure
Browse files Browse the repository at this point in the history
Now that rustdoc is spawning a child task, the program won't exit with a default
error code if the main task fails (because it never fails). This commit forces
the main task to wait for a child task in order to correctly propagate failure.

Closes #16341
  • Loading branch information
alexcrichton committed Aug 8, 2014
1 parent 8888d7c commit d9038fc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustdoc/lib.rs
Expand Up @@ -120,9 +120,16 @@ pub fn main() {
// So, in summary, it is unknown why this is necessary, what it is
// preventing, or what the actual bug is. In the meantime, this allows
// --test to work on windows, which seems good, right? Fun times.
let (tx, rx) = channel();
spawn(proc() {
std::os::set_exit_status(main_args(std::os::args().as_slice()));
tx.send(());
});

// If the task failed, set an error'd exit status
if rx.recv_opt().is_err() {
std::os::set_exit_status(std::rt::DEFAULT_ERROR_CODE);
}
}

pub fn opts() -> Vec<getopts::OptGroup> {
Expand Down

5 comments on commit d9038fc

@bors
Copy link
Contributor

@bors bors commented on d9038fc Aug 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at alexcrichton@d9038fc

@bors
Copy link
Contributor

@bors bors commented on d9038fc Aug 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/issue-16341 = d9038fc into auto

@bors
Copy link
Contributor

@bors bors commented on d9038fc Aug 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/issue-16341 = d9038fc merged ok, testing candidate = beda30e

@bors
Copy link
Contributor

@bors bors commented on d9038fc Aug 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = beda30e

Please sign in to comment.