Skip to content
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

Add logic to check for --keep-going support #160

Merged
merged 1 commit into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 19 additions & 9 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,38 @@ fn cargo_target_dir(project: &Project) -> impl Iterator<Item = (&'static str, Pa
))
}

pub fn build_dependencies(project: &Project) -> Result<()> {
pub fn build_dependencies(project: &mut Project) -> Result<()> {
let workspace_cargo_lock = path!(project.workspace / "Cargo.lock");
if workspace_cargo_lock.exists() {
let _ = fs::copy(workspace_cargo_lock, path!(project.dir / "Cargo.lock"));
} else {
let _ = cargo(project).arg("generate-lockfile").status();
}

let status = cargo(project)
let mut command = cargo(project);
command
.arg(if project.has_pass { "build" } else { "check" })
.args(target())
.arg("--bin")
.arg(&project.name)
.args(features(project))
.status()
.map_err(Error::Cargo)?;
.args(features(project));

if status.success() {
Ok(())
} else {
Err(Error::CargoFail)
let status = command.status().map_err(Error::Cargo)?;
if !status.success() {
return Err(Error::CargoFail);
}

// Check if this Cargo contains https://github.com/rust-lang/cargo/pull/10383
project.keep_going = command
.arg("-Zunstable-options")
.arg("--keep-going")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.map(|status| status.success())
.unwrap_or(false);

Ok(())
}

pub fn build_test(project: &Project, name: &Name) -> Result<Output> {
Expand Down
8 changes: 5 additions & 3 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct Project {
pub workspace: Directory,
pub path_dependencies: Vec<PathDependency>,
manifest: Manifest,
pub keep_going: bool,
}

#[derive(Debug)]
Expand All @@ -45,9 +46,9 @@ impl Runner {
filter(&mut tests);

let (project, _lock) = (|| {
let project = self.prepare(&tests)?;
let mut project = self.prepare(&tests)?;
let lock = Lock::acquire(path!(project.dir / ".lock"));
self.write(&project)?;
self.write(&mut project)?;
Ok((project, lock))
})()
.unwrap_or_else(|err| {
Expand Down Expand Up @@ -149,10 +150,11 @@ impl Runner {
workspace,
path_dependencies,
manifest,
keep_going: false,
})
}

fn write(&self, project: &Project) -> Result<()> {
fn write(&self, project: &mut Project) -> Result<()> {
let manifest_toml = toml::to_string(&project.manifest)?;

let config = self.make_config();
Expand Down