File tree Expand file tree Collapse file tree 7 files changed +55
-0
lines changed Expand file tree Collapse file tree 7 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5
5
6
6
## Unreleased
7
7
8
+ ### Added
9
+
10
+ - New variant ` PrepareError::MissingDependencies ` , returned during the prepare
11
+ step when a dependency does not exist.
12
+
8
13
### Changed
9
14
10
15
- Path dependencies are no longer removed from ` Cargo.toml ` during the prepare
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ impl<'a> Prepare<'a> {
96
96
}
97
97
98
98
let mut yanked_deps = false ;
99
+ let mut missing_deps = false ;
99
100
let mut cmd = Command :: new ( self . workspace , self . toolchain . cargo ( ) ) . args ( & [
100
101
"generate-lockfile" ,
101
102
"--manifest-path" ,
@@ -111,13 +112,20 @@ impl<'a> Prepare<'a> {
111
112
. process_lines ( & mut |line, _| {
112
113
if line. contains ( "failed to select a version for the requirement" ) {
113
114
yanked_deps = true ;
115
+ } else if line. contains ( "failed to load source for dependency" )
116
+ || line. contains ( "no matching package named" )
117
+ {
118
+ missing_deps = true ;
114
119
}
115
120
} )
116
121
. run ( ) ;
117
122
match res {
118
123
Err ( _) if yanked_deps => {
119
124
return Err ( PrepareError :: YankedDependencies . into ( ) ) ;
120
125
}
126
+ Err ( _) if missing_deps => {
127
+ return Err ( PrepareError :: MissingDependencies . into ( ) ) ;
128
+ }
121
129
other => other?,
122
130
}
123
131
self . lockfile_captured = true ;
@@ -349,6 +357,9 @@ pub enum PrepareError {
349
357
/// Some of this crate's dependencies were yanked, preventing Crater from fetching them.
350
358
#[ fail( display = "the crate depends on yanked dependencies" ) ]
351
359
YankedDependencies ,
360
+ /// Some of the dependencies do not exist anymore.
361
+ #[ fail( display = "the crate depends on missing dependencies" ) ]
362
+ MissingDependencies ,
352
363
}
353
364
354
365
#[ cfg( test) ]
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " missing-deps"
3
+ version = " 0.1.0"
4
+ authors = [" Pietro Albini <pietro@pietroalbini.org>" ]
5
+ edition = " 2018"
6
+
7
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
+
9
+ [dependencies ]
10
+ not-a-git-repo = { git = " https://www.example.com/definitely-not-a-git-repo.git" }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! ( "Hello, world!" ) ;
3
+ }
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " missing-deps-registry"
3
+ version = " 0.1.0"
4
+ authors = [" Pietro Albini <pietro@pietroalbini.org>" ]
5
+ edition = " 2018"
6
+
7
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
+
9
+ [dependencies ]
10
+ # The `macro` crate name is reserved on crates.io.
11
+ macro = " *"
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! ( "Hello, world!" ) ;
3
+ }
Original file line number Diff line number Diff line change @@ -131,3 +131,15 @@ test_prepare_error!(
131
131
) ;
132
132
133
133
test_prepare_error ! ( test_yanked_deps, "yanked-deps" , YankedDependencies ) ;
134
+
135
+ test_prepare_error ! (
136
+ test_missing_deps_git,
137
+ "missing-deps-git" ,
138
+ MissingDependencies
139
+ ) ;
140
+
141
+ test_prepare_error ! (
142
+ test_missing_deps_registry,
143
+ "missing-deps-registry" ,
144
+ MissingDependencies
145
+ ) ;
You can’t perform that action at this time.
0 commit comments