Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose Cargo exit status if non-zero #13
Comments
ebkalderon
added
type: bug
diff: medium
pri: important
labels
Feb 11, 2016
ebkalderon
added this to the 1.0 milestone
Feb 11, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
White-Oak
Feb 11, 2016
Contributor
btw, I suppose cargo call should return Result, not Option. Right now option return in case of error is very confusing.
|
btw, I suppose cargo call should return Result, not Option. Right now option return in case of error is very confusing. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ebkalderon
Feb 11, 2016
Member
@White-Oak I chose Option because it looked a little less verbose to me. If I were to choose Result, I would have to make the return value be something like Result<(), &'static str>, which isn't particularly pretty. Edit: It appears this actually may be standard practice(?)
If a successful Cargo execution isn't meant to return anything, it's much easier to use Some(error) and None. However, it's a subjective issue of aesthetics, really, and if the use of Option is too confusing for people, I'll gladly switch it to Result.
|
@White-Oak I chose If a successful Cargo execution isn't meant to return anything, it's much easier to use |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ebkalderon
Feb 12, 2016
Member
@White-Oak After thinking about it some more, I've come to agree with your stance on using Result over Option. However, this should probably be a separate pull request from #15, which implements the basic functionality. One thing at a time...
Edit: I'd recommend reducing the verbosity of Result a bit with a typedef:
pub type CargoStatus = Result<(), &'static str>;That makes things like this look much, much cleaner, similar to Option. It's less confusing and more Rusty.
pub fn call(args: Vec<&str>) -> CargoStatus {
// ...
if output.task.success() {
Ok(())
} else {
Err("Running cargo task failed")
}
}|
@White-Oak After thinking about it some more, I've come to agree with your stance on using Edit: I'd recommend reducing the verbosity of pub type CargoStatus = Result<(), &'static str>;That makes things like this look much, much cleaner, similar to pub fn call(args: Vec<&str>) -> CargoStatus {
// ...
if output.task.success() {
Ok(())
} else {
Err("Running cargo task failed")
}
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Looks like with commit 3b416e0, this issue is now resolved. |
ebkalderon commentedFeb 11, 2016
Right now, the Amethyst CLI client always returns zero when calling Cargo commands, regardless of whether Cargo itself returned errors. This is why the
tests.shfile doesn't work as expected, returning "All tests pass!" even when that's obviously not true (see the comments on pull request #12 for an example).This isn't too problematic since Amethyst and its toolchain are in the 0.X.Y release stage, but nonetheless this must be fixed before 1.0 rolls around.