diff --git a/phd-tests/runner/build.rs b/phd-tests/runner/build.rs index 46b0bab40..3b0e94f19 100644 --- a/phd-tests/runner/build.rs +++ b/phd-tests/runner/build.rs @@ -12,13 +12,12 @@ fn main() -> anyhow::Result<()> { } fn set_crucible_git_rev() -> anyhow::Result<()> { + const CRUCIBLE_REPO: &str = "https://github.com/oxidecomputer/crucible"; fn extract_crucible_dep_sha( src: &cargo_metadata::Source, ) -> anyhow::Result<&str> { - const CRUCIBLE_REPO: &str = "https://github.com/oxidecomputer/crucible"; - let src = src.repr.strip_prefix("git+").ok_or_else(|| { - anyhow::anyhow!("Crucible package's source should be from git") + anyhow::anyhow!("Crucible is not a Git dependency") })?; if !src.starts_with(CRUCIBLE_REPO) { @@ -26,11 +25,11 @@ fn set_crucible_git_rev() -> anyhow::Result<()> { } let rev = src.split("?rev=").nth(1).ok_or_else(|| { - anyhow::anyhow!("Crucible package's source should have a revision") + anyhow::anyhow!("Crucible package's source did not have a revision") })?; let mut parts = rev.split('#'); let sha = parts.next().ok_or_else(|| { - anyhow::anyhow!("Crucible package's source should have a revision") + anyhow::anyhow!("Crucible package's source did not have a revision") })?; assert_eq!(Some(sha), parts.next()); Ok(sha) @@ -48,16 +47,24 @@ fn set_crucible_git_rev() -> anyhow::Result<()> { anyhow::anyhow!("Failed to find Crucible package in cargo metadata") })?; - let crucible_src = crucible_pkg.source.as_ref().ok_or_else(|| { - anyhow::anyhow!("Crucible package should not be a workspace member, and therefore should have source metadata") - })?; - - let crucible_sha = - extract_crucible_dep_sha(crucible_src).with_context(|| { - format!( - "Failed to extract Crucible source SHA from {crucible_src:?}" + let mut errmsg = String::new(); + let crucible_sha = crucible_pkg + .source + .as_ref() + .ok_or_else(|| { + anyhow::anyhow!( + "Crucible dependency is patched with a local checkout" ) - })?; + }) + .and_then(extract_crucible_dep_sha) + .unwrap_or_else(|err| { + println!( + "cargo:warning={err}, so the `--crucible-downstairs-commit auto` \ + flag will be disabled in this PHD build", + ); + errmsg = format!("CANT_GET_YE_CRUCIBLE_SHA{err}"); + &errmsg + }); println!("cargo:rustc-env=PHD_CRUCIBLE_GIT_REV={crucible_sha}"); diff --git a/phd-tests/runner/src/config.rs b/phd-tests/runner/src/config.rs index a68cac581..1e152d08f 100644 --- a/phd-tests/runner/src/config.rs +++ b/phd-tests/runner/src/config.rs @@ -265,9 +265,22 @@ impl RunOptions { // The Git revision of Crucible we depend on is determined when building // `phd-runner` by the build script, so that the `phd-runner` binary can // be run even after moving it out of the Propolis cargo workspace. - let commit = env!("PHD_CRUCIBLE_GIT_REV").parse().context( - "PHD_CRUCIBLE_GIT_REV must be set to a valid Git revision by the build script", - )?; + let commit = env!("PHD_CRUCIBLE_GIT_REV"); + if let Some(reason) = + commit.strip_prefix("CANT_GET_YE_CRUCIBLE_SHA") + { + anyhow::bail!( + "Because {reason}, phd-runner's build script could not determine \ + the Crucible Git SHA, so the `--crucible-downstairs-commit auto` \ + option has been disabled.\n\tYou can provide a local Crucible \ + binary using `--crucible-downstairs-cmd`.", + ) + } + + let commit = commit.parse().context( + "PHD_CRUCIBLE_GIT_REV must be set to a valid Git \ + revision by the build script", + )?; Ok(Some(CrucibleDownstairsSource::BuildomatGitRev(commit))) } None => Ok(None),