Skip to content

categorize sandbox creation failure #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- New variant `CommandError::SandboxContainerCreate`

## [0.18.0] - 2024-10-13

- **BREAKING** Extend `CommandError::ExecutionFailed` and `PrepareError` to optionally include stderr
Expand Down
4 changes: 2 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct BuildBuilder<'a> {
patches: Vec<CratePatch>,
}

impl<'a> BuildBuilder<'a> {
impl BuildBuilder<'_> {
/// Add a git-based patch to this build.
/// Patches get added to the crate's Cargo.toml in the `patch.crates-io` table.
/// # Example
Expand Down Expand Up @@ -170,7 +170,7 @@ impl BuildDirectory {
toolchain: &'a Toolchain,
krate: &'a Crate,
sandbox: SandboxBuilder,
) -> BuildBuilder {
) -> BuildBuilder<'a> {
BuildBuilder {
build_dir: self,
toolchain,
Expand Down
8 changes: 6 additions & 2 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ pub enum CommandError {
#[error("sandbox image missing from the local system: {0}")]
SandboxImageMissing(#[source] Box<CommandError>),

/// Failed to create the sandbox container
#[error("sandbox container could not be created: {0}")]
SandboxContainerCreate(#[source] Box<CommandError>),

/// Running rustwide inside a Docker container requires the workspace directory to be mounted
/// from the host system. This error happens if that's not true, for example if the workspace
/// lives in a directory inside the container.
Expand Down Expand Up @@ -165,7 +169,7 @@ pub trait Runnable {
}
}

impl<'a> Runnable for &'a str {
impl Runnable for &str {
fn name(&self) -> Binary {
Binary::Global(self.into())
}
Expand All @@ -177,7 +181,7 @@ impl Runnable for String {
}
}

impl<'a, B: Runnable> Runnable for &'a B {
impl<B: Runnable> Runnable for &B {
fn name(&self) -> Binary {
Runnable::name(*self)
}
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ impl SandboxBuilder {

let out = Command::new(workspace, "docker")
.args(&args)
.run_capture()?;
.run_capture()
.map_err(|err| CommandError::SandboxContainerCreate(Box::new(err)))?;
Ok(Container {
id: out.stdout_lines()[0].clone(),
workspace,
Expand Down
2 changes: 1 addition & 1 deletion src/native/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod tests {
#[test]
fn test_kill_process() {
// Try to kill a sleep command
let mut cmd = Command::new("timeout").args(&["2"]).spawn().unwrap();
let mut cmd = Command::new("timeout").args(["2"]).spawn().unwrap();
kill_process(cmd.id()).unwrap();

// Ensure it returns the code passed to `TerminateProcess`
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod windows_tests {
let first_component = p.components().next().unwrap();

if let Component::Prefix(prefix) = &first_component {
let stripped = strip_verbatim_from_prefix(&prefix);
let stripped = strip_verbatim_from_prefix(prefix);
assert_eq!(stripped.as_ref().map(|p| p.to_str().unwrap()), output);
} else {
assert!(output.is_none());
Expand Down
Loading