Skip to content

Commit 129ce53

Browse files
committed
Test for cargo check with macro and both lib and bin.
Closes #3419
1 parent 7e2c81d commit 129ce53

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/check.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extern crate hamcrest;
33

44
use cargotest::is_nightly;
55
use cargotest::support::{execs, project};
6+
use cargotest::support::registry::Package;
67
use hamcrest::assert_that;
78

89
#[test]
@@ -238,3 +239,57 @@ fn issue_3418() {
238239
execs().with_status(0)
239240
.with_stderr_does_not_contain("--crate-type lib"));
240241
}
242+
243+
// Some weirdness that seems to be caused by a crate being built as well as
244+
// checked, but in this case with a proc macro too.
245+
#[test]
246+
fn issue_3419() {
247+
if !is_nightly() {
248+
return;
249+
}
250+
251+
let foo = project("foo")
252+
.file("Cargo.toml", r#"
253+
[package]
254+
name = "foo"
255+
version = "0.0.1"
256+
authors = []
257+
258+
[dependencies]
259+
rustc-serialize = "*"
260+
"#)
261+
.file("src/lib.rs", r#"
262+
extern crate rustc_serialize;
263+
264+
use rustc_serialize::Decodable;
265+
266+
pub fn take<T: Decodable>() {}
267+
"#)
268+
.file("src/main.rs", r#"
269+
extern crate rustc_serialize;
270+
271+
extern crate foo;
272+
273+
#[derive(RustcDecodable)]
274+
pub struct Foo;
275+
276+
fn main() {
277+
foo::take::<Foo>();
278+
}
279+
"#);
280+
281+
Package::new("rustc-serialize", "1.0.0")
282+
.file("src/lib.rs",
283+
r#"pub trait Decodable: Sized {
284+
fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>;
285+
}
286+
pub trait Decoder {
287+
type Error;
288+
fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F)
289+
-> Result<T, Self::Error>
290+
where F: FnOnce(&mut Self) -> Result<T, Self::Error>;
291+
} "#).publish();
292+
293+
assert_that(foo.cargo_process("check"),
294+
execs().with_status(0));
295+
}

0 commit comments

Comments
 (0)