File tree 3 files changed +11
-5
lines changed
3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,13 @@ impl From<json::DecoderError> for Error {
65
65
}
66
66
}
67
67
68
- pub fn metadata ( ) -> Result < Metadata , Error > {
69
- let output = Command :: new ( "cargo" ) . args ( & [ "metadata" , "--no-deps" ] ) . output ( ) ?;
68
+ pub fn metadata ( manifest_path : Option < String > ) -> Result < Metadata , Error > {
69
+ let mut cmd = Command :: new ( "cargo" ) ;
70
+ cmd. arg ( "metadata" ) . arg ( "--no-deps" ) ;
71
+ if let Some ( ref mani) = manifest_path {
72
+ cmd. arg ( mani) ;
73
+ }
74
+ let output = cmd. output ( ) ?;
70
75
let stdout = from_utf8 ( & output. stdout ) ?;
71
76
Ok ( json:: decode ( stdout) ?)
72
77
}
Original file line number Diff line number Diff line change @@ -129,7 +129,8 @@ pub fn main() {
129
129
} ;
130
130
131
131
if let Some ( "clippy" ) = std:: env:: args ( ) . nth ( 1 ) . as_ref ( ) . map ( AsRef :: as_ref) {
132
- let mut metadata = cargo:: metadata ( ) . expect ( "could not obtain cargo metadata" ) ;
132
+ let manifest_path = std:: env:: args ( ) . skip ( 2 ) . find ( |val| val. starts_with ( "--manifest-path=" ) ) ;
133
+ let mut metadata = cargo:: metadata ( manifest_path) . expect ( "could not obtain cargo metadata" ) ;
133
134
assert_eq ! ( metadata. version, 1 ) ;
134
135
for target in metadata. packages . remove ( 0 ) . targets {
135
136
let args = std:: env:: args ( ) . skip ( 2 ) ;
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ use clippy_lints::utils::cargo;
3
3
4
4
#[ test]
5
5
fn check_that_clippy_lints_has_the_same_version_as_clippy ( ) {
6
- let clippy_meta = cargo:: metadata ( ) . expect ( "could not obtain cargo metadata" ) ;
6
+ let clippy_meta = cargo:: metadata ( None ) . expect ( "could not obtain cargo metadata" ) ;
7
7
std:: env:: set_current_dir ( std:: env:: current_dir ( ) . unwrap ( ) . join ( "clippy_lints" ) ) . unwrap ( ) ;
8
- let clippy_lints_meta = cargo:: metadata ( ) . expect ( "could not obtain cargo metadata" ) ;
8
+ let clippy_lints_meta = cargo:: metadata ( None ) . expect ( "could not obtain cargo metadata" ) ;
9
9
assert_eq ! ( clippy_lints_meta. packages[ 0 ] . version, clippy_meta. packages[ 0 ] . version) ;
10
10
for package in & clippy_meta. packages [ 0 ] . dependencies {
11
11
if package. name == "clippy_lints" {
You can’t perform that action at this time.
0 commit comments