From: Manish Goregaokar Date: Mon, 5 Feb 2018 21:42:42 +0000 (-0500) Subject: Add tests for epoch X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~3^2~10^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5d615a69b7b72c47d198d281c92cc25ca243a9b8;p=cargo.git Add tests for epoch --- diff --git a/tests/package.rs b/tests/package.rs index d90e76e95..4f10b9e53 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -887,3 +887,120 @@ fn package_two_kinds_of_deps() { assert_that(p.cargo("package").arg("--no-verify"), execs().with_status(0)); } + +#[test] +fn test_epoch() { + let p = project("foo") + .file("Cargo.toml", r#" + cargo-features = ["epoch"] + [package] + name = "foo" + version = "0.0.1" + authors = [] + epoch = "2018" + "#) + .file("src/lib.rs", r#" "#) + .build(); + + assert_that(p.cargo("build").arg("-v") + .masquerade_as_nightly_cargo(), + execs() + // -Zepoch is still in flux and we're not passing -Zunstable-options + // from Cargo so it will probably error. Only partially match the output + // until stuff stabilizes + .with_stderr_contains(format!("\ +[COMPILING] foo v0.0.1 ({url}) +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \ + --emit=dep-info,link -Zepoch=2018 -C debuginfo=2 \ + -C metadata=[..] \ + --out-dir [..] \ + -L dependency={dir}[/]target[/]debug[/]deps` +", dir = p.root().display(), url = p.url()))); +} + +#[test] +fn test_epoch_missing() { + // no epoch = 2015 + let p = project("foo") + .file("Cargo.toml", r#" + cargo-features = ["epoch"] + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/lib.rs", r#" "#) + .build(); + + assert_that(p.cargo("build").arg("-v") + .masquerade_as_nightly_cargo(), + execs() + // -Zepoch is still in flux and we're not passing -Zunstable-options + // from Cargo so it will probably error. Only partially match the output + // until stuff stabilizes + .with_stderr_contains(format!("\ +[COMPILING] foo v0.0.1 ({url}) +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \ + --emit=dep-info,link -Zepoch=2015 -C debuginfo=2 \ + -C metadata=[..] \ + --out-dir [..] \ + -L dependency={dir}[/]target[/]debug[/]deps` +", dir = p.root().display(), url = p.url()))); +} + +#[test] +fn test_epoch_malformed() { + let p = project("foo") + .file("Cargo.toml", r#" + cargo-features = ["epoch"] + [package] + name = "foo" + version = "0.0.1" + authors = [] + epoch = "chicken" + "#) + .file("src/lib.rs", r#" "#) + .build(); + + assert_that(p.cargo("build").arg("-v") + .masquerade_as_nightly_cargo(), + execs() + .with_status(101) + .with_stderr(format!("\ +error: failed to parse manifest at `[..]` + +Caused by: + the `epoch` key must be one of: `2015`, `2018` +"))); +} + + +#[test] +fn test_epoch_nightly() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + epoch = "2015" + "#) + .file("src/lib.rs", r#" "#) + .build(); + + assert_that(p.cargo("build").arg("-v") + .masquerade_as_nightly_cargo(), + execs() + .with_status(101) + .with_stderr(format!("\ +error: failed to parse manifest at `[..]` + +Caused by: + epoches are unstable + +Caused by: + feature `epoch` is required + +consider adding `cargo-features = [\"epoch\"]` to the manifest +"))); +} \ No newline at end of file