Skip to content

Commit 3247c66

Browse files
authored
Merge pull request #482 from apoelstra/2018-10-lib-tests
cargo-miri: support running unit tests for libraries as well as test binaries
2 parents 8e0180d + 4faf8fa commit 3247c66

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

src/bin/cargo-miri.rs

+30-16
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,38 @@ fn main() {
9797
let kind = target.kind.get(0).expect(
9898
"badly formatted cargo metadata: target::kind is an empty array",
9999
);
100-
if test && kind == "test" {
101-
if let Err(code) = process(
102-
vec!["--test".to_string(), target.name].into_iter().chain(
103-
args,
104-
),
105-
)
106-
{
107-
std::process::exit(code);
100+
match (test, &kind[..]) {
101+
(true, "test") => {
102+
if let Err(code) = process(
103+
vec!["--test".to_string(), target.name].into_iter().chain(
104+
args,
105+
),
106+
)
107+
{
108+
std::process::exit(code);
109+
}
108110
}
109-
} else if !test && kind == "bin" {
110-
if let Err(code) = process(
111-
vec!["--bin".to_string(), target.name].into_iter().chain(
112-
args,
113-
),
114-
)
115-
{
116-
std::process::exit(code);
111+
(true, "lib") => {
112+
if let Err(code) = process(
113+
vec!["--".to_string(), "--test".to_string()].into_iter().chain(
114+
args,
115+
),
116+
)
117+
{
118+
std::process::exit(code);
119+
}
117120
}
121+
(false, "bin") => {
122+
if let Err(code) = process(
123+
vec!["--bin".to_string(), target.name].into_iter().chain(
124+
args,
125+
),
126+
)
127+
{
128+
std::process::exit(code);
129+
}
130+
}
131+
_ => {}
118132
}
119133
}
120134
} else {

0 commit comments

Comments
 (0)