Skip to content

Commit 5328ecc

Browse files
committed
detect broken lock file
1 parent 370cfec commit 5328ecc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/prepare.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
146146
let mut yanked_deps = false;
147147
let mut missing_deps = false;
148148
let mut broken_deps = false;
149+
let mut broken_lockfile = false;
149150

150151
let mut process = |line: &str, _: &mut ProcessLinesActions| {
151152
if line.contains("failed to select a version for the requirement") {
@@ -158,6 +159,8 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
158159
|| line.contains("error: invalid table header")
159160
{
160161
broken_deps = true;
162+
} else if line.contains("error: failed to parse lock file at") {
163+
broken_lockfile = true;
161164
}
162165
};
163166

@@ -172,6 +175,9 @@ fn run_command(cmd: Command) -> anyhow::Result<()> {
172175
Err(CommandError::ExecutionFailed { status: _, stderr }) if broken_deps => {
173176
Err(PrepareError::BrokenDependencies(stderr).into())
174177
}
178+
Err(CommandError::ExecutionFailed { status: _, stderr }) if broken_lockfile => {
179+
Err(PrepareError::InvalidCargoLock(stderr).into())
180+
}
175181
Err(err) => Err(err.into()),
176182
}
177183
}
@@ -390,6 +396,9 @@ pub enum PrepareError {
390396
/// Some of the dependencies do not exist anymore.
391397
#[error("the crate depends on missing dependencies: \n\n{0}")]
392398
MissingDependencies(String),
399+
/// cargo rejected (generating) the lockfile
400+
#[error("the crate has a broken lockfile: \n\n{0}")]
401+
InvalidCargoLock(String),
393402
}
394403

395404
#[cfg(test)]

tests/buildtest/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ test_prepare_error_stderr!(
275275
"error: invalid table header"
276276
);
277277

278-
test_prepare_unknown_err!(
278+
test_prepare_error_stderr!(
279279
test_invalid_lockfile_syntax,
280280
"invalid-lockfile-syntax",
281281
InvalidCargoLock,

0 commit comments

Comments
 (0)