Skip to content

Commit

Permalink
nicer error message
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Oct 2, 2024
1 parent d03db31 commit cc2ecf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
4 changes: 3 additions & 1 deletion phd-tests/runner/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn set_crucible_git_rev() -> anyhow::Result<()> {
anyhow::anyhow!("Failed to find Crucible package in cargo metadata")
})?;

let mut errmsg = String::new();
let crucible_sha = crucible_pkg
.source
.as_ref()
Expand All @@ -61,7 +62,8 @@ fn set_crucible_git_rev() -> anyhow::Result<()> {
"cargo:warning={err}, so the `--crucible-downstairs-commit auto` \
flag will be disabled in this PHD build",
);
"CANT_GET_YE_CRUCIBLE_SHA"
errmsg = format!("CANT_GET_YE_CRUCIBLE_SHA{err}");
&errmsg
});

println!("cargo:rustc-env=PHD_CRUCIBLE_GIT_REV={crucible_sha}");
Expand Down
28 changes: 16 additions & 12 deletions phd-tests/runner/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +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 = match env!("PHD_CRUCIBLE_GIT_REV") {
"CANT_GET_YE_CRUCIBLE_SHA" => anyhow::bail!(
"Crucible upstairs dependency was patched with a \
local path when PHD was compiled, so the \
`--crucible-downstairs-commit auto` option has been \
disabled."
),
commit => commit.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. You can provide a local Crucible \
binary using `--crucible-downstairs-command`.",
)
}

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),
Expand Down

0 comments on commit cc2ecf0

Please sign in to comment.