2015-05-01 21:19:43 +00:00
|
|
|
use std::path::MAIN_SEPARATOR as SEP;
|
2015-05-02 22:49:58 +00:00
|
|
|
use support::{execs, project};
|
2015-05-01 21:19:43 +00:00
|
|
|
use support::{COMPILING, RUNNING};
|
|
|
|
use hamcrest::{assert_that};
|
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
}
|
|
|
|
|
|
|
|
test!(build_lib_for_foo {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2015-05-01 21:19:43 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
2015-05-02 10:19:55 +00:00
|
|
|
assert_that(p.cargo_process("rustc").arg("--lib").arg("-v"),
|
2015-05-01 21:19:43 +00:00
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2015-05-02 22:49:58 +00:00
|
|
|
.with_stdout(format!("\
|
|
|
|
{compiling} foo v0.0.1 ({url})
|
|
|
|
{running} `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
|
|
|
--out-dir {dir}{sep}target{sep}debug \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
|
|
|
",
|
|
|
|
running = RUNNING, compiling = COMPILING, sep = SEP,
|
|
|
|
dir = p.root().display(), url = p.url())));
|
2015-05-01 23:01:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(build_lib_and_allow_unstable_options {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2015-05-01 23:01:30 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
2015-05-02 10:19:55 +00:00
|
|
|
assert_that(p.cargo_process("rustc").arg("--lib").arg("-v")
|
2015-05-01 23:01:30 +00:00
|
|
|
.arg("--").arg("-Z").arg("unstable-options"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2015-05-02 22:49:58 +00:00
|
|
|
.with_stdout(format!("\
|
|
|
|
{compiling} foo v0.0.1 ({url})
|
|
|
|
{running} `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
|
|
|
|
-Z unstable-options \
|
|
|
|
--out-dir {dir}{sep}target{sep}debug \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
|
|
|
",
|
|
|
|
running = RUNNING, compiling = COMPILING, sep = SEP,
|
|
|
|
dir = p.root().display(), url = p.url())))
|
2015-05-01 23:01:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(build_main_and_allow_unstable_options {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2015-05-01 23:01:30 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
2015-05-02 16:18:05 +00:00
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2015-05-02 16:18:05 +00:00
|
|
|
assert_that(p.cargo_process("rustc").arg("-v").arg("--bin").arg("foo")
|
2015-05-01 23:01:30 +00:00
|
|
|
.arg("--").arg("-Z").arg("unstable-options"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
2015-05-02 16:18:05 +00:00
|
|
|
.with_stdout(&format!("\
|
|
|
|
{compiling} {name} v{version} ({url})
|
|
|
|
{running} `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \
|
|
|
|
--out-dir {dir}{sep}target{sep}debug \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
|
|
|
{running} `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \
|
|
|
|
-Z unstable-options \
|
|
|
|
--out-dir {dir}{sep}target{sep}debug \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
|
|
|
--extern {name}={dir}{sep}target{sep}debug{sep}lib{name}.rlib`
|
|
|
|
",
|
|
|
|
running = RUNNING, compiling = COMPILING, sep = SEP,
|
|
|
|
dir = p.root().display(), url = p.url(),
|
|
|
|
name = "foo", version = "0.0.1")));
|
2015-05-01 21:19:43 +00:00
|
|
|
});
|
2015-05-02 14:30:16 +00:00
|
|
|
|
|
|
|
test!(fails_when_trying_to_build_main_and_lib_with_args {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2015-05-02 14:30:16 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#" "#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("rustc").arg("-v")
|
|
|
|
.arg("--").arg("-Z").arg("unstable-options"),
|
|
|
|
execs()
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr("extra arguments to `rustc` can only be invoked for one target"));
|
|
|
|
});
|