2015-03-16 13:27:58 +00:00
|
|
|
use std::path::MAIN_SEPARATOR as SEP;
|
2014-07-13 18:47:37 +00:00
|
|
|
|
2015-02-27 01:04:25 +00:00
|
|
|
use support::{project, execs, path2url};
|
2014-07-13 18:47:37 +00:00
|
|
|
use support::{COMPILING, RUNNING};
|
|
|
|
use hamcrest::{assert_that, existing_file};
|
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
}
|
|
|
|
|
|
|
|
test!(simple {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2014-08-06 16:21:10 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}foo[..]`
|
2014-07-13 18:47:37 +00:00
|
|
|
hello
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
2014-08-06 16:21:10 +00:00
|
|
|
dir = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-07-17 01:44:30 +00:00
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-07-13 18:47:37 +00:00
|
|
|
|
2014-10-21 18:48:16 +00:00
|
|
|
test!(simple_quiet {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("-q"),
|
|
|
|
execs().with_status(0).with_stdout("\
|
|
|
|
hello
|
|
|
|
")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test!(simple_quiet_and_verbose {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("-q").arg("-v"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
cannot set both --verbose and --quiet
|
|
|
|
")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2014-07-13 18:47:37 +00:00
|
|
|
test!(simple_with_args {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {
|
2015-03-26 18:17:44 +00:00
|
|
|
assert_eq!(std::env::args().nth(1).unwrap(), "hello");
|
|
|
|
assert_eq!(std::env::args().nth(2).unwrap(), "world");
|
2014-07-13 18:47:37 +00:00
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run").arg("hello").arg("world"),
|
2014-07-13 18:47:37 +00:00
|
|
|
execs().with_status(0));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-07-13 18:47:37 +00:00
|
|
|
|
|
|
|
test!(exit_code {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
2015-06-13 00:37:19 +00:00
|
|
|
fn main() { std::process::exit(2); }
|
2014-07-13 18:47:37 +00:00
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run"),
|
2014-07-13 18:47:37 +00:00
|
|
|
execs().with_status(2));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-07-13 18:47:37 +00:00
|
|
|
|
2015-10-13 00:30:44 +00:00
|
|
|
test!(exit_code_verbose {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { std::process::exit(2); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("-v"),
|
|
|
|
execs().with_status(2)
|
|
|
|
.with_stderr(&format!("\
|
|
|
|
Process didn't exit successfully: `target[..]foo` (exit code: 2)
|
|
|
|
",
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
2014-07-13 18:47:37 +00:00
|
|
|
test!(no_main_file {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run"),
|
2014-07-13 18:47:37 +00:00
|
|
|
execs().with_status(101)
|
2014-08-22 16:53:56 +00:00
|
|
|
.with_stderr("a bin target must be available \
|
|
|
|
for `cargo run`\n"));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-08-22 16:53:56 +00:00
|
|
|
|
|
|
|
test!(too_many_bins {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/bin/a.rs", "")
|
|
|
|
.file("src/bin/b.rs", "");
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run"),
|
2014-08-22 16:53:56 +00:00
|
|
|
execs().with_status(101)
|
|
|
|
.with_stderr("`cargo run` requires that a project only \
|
2015-03-21 03:00:03 +00:00
|
|
|
have one executable; use the `--bin` option \
|
2014-10-27 21:49:20 +00:00
|
|
|
to specify which one to run\n"));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-10-27 21:49:20 +00:00
|
|
|
|
|
|
|
test!(specify_name {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/bin/a.rs", r#"
|
|
|
|
extern crate foo;
|
|
|
|
fn main() { println!("hello a.rs"); }
|
|
|
|
"#)
|
|
|
|
.file("src/bin/b.rs", r#"
|
|
|
|
extern crate foo;
|
|
|
|
fn main() { println!("hello b.rs"); }
|
|
|
|
"#);
|
|
|
|
|
2015-03-21 03:00:03 +00:00
|
|
|
assert_that(p.cargo_process("run").arg("--bin").arg("a").arg("-v"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2014-10-27 21:49:20 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2015-03-21 03:00:03 +00:00
|
|
|
{running} `rustc src[..]lib.rs [..]`
|
|
|
|
{running} `rustc src[..]a.rs [..]`
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}a[..]`
|
2014-10-27 21:49:20 +00:00
|
|
|
hello a.rs
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-10-27 21:49:20 +00:00
|
|
|
|
2015-03-21 03:00:03 +00:00
|
|
|
assert_that(p.cargo("run").arg("--bin").arg("b").arg("-v"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2015-03-21 03:00:03 +00:00
|
|
|
{compiling} foo v0.0.1 ([..])
|
|
|
|
{running} `rustc src[..]b.rs [..]`
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}b[..]`
|
2014-10-27 21:49:20 +00:00
|
|
|
hello b.rs
|
|
|
|
",
|
2015-03-21 03:00:03 +00:00
|
|
|
running = RUNNING, compiling = COMPILING,
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-10-27 21:49:20 +00:00
|
|
|
|
|
|
|
test!(run_example {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/a.rs", r#"
|
|
|
|
fn main() { println!("example"); }
|
|
|
|
"#)
|
|
|
|
.file("src/bin/a.rs", r#"
|
|
|
|
fn main() { println!("bin"); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("--example").arg("a"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2014-10-27 21:49:20 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}examples{sep}a[..]`
|
2014-10-27 21:49:20 +00:00
|
|
|
example
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-10-27 21:49:20 +00:00
|
|
|
|
|
|
|
test!(either_name_or_example {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/a.rs", r#"
|
|
|
|
fn main() { println!("hello a.rs"); }
|
|
|
|
"#)
|
|
|
|
.file("examples/b.rs", r#"
|
|
|
|
fn main() { println!("hello b.rs"); }
|
|
|
|
"#);
|
|
|
|
|
2014-11-13 17:37:09 +00:00
|
|
|
assert_that(p.cargo_process("run").arg("--bin").arg("a").arg("--example").arg("b"),
|
2015-03-21 03:00:03 +00:00
|
|
|
execs().with_status(101)
|
|
|
|
.with_stderr("`cargo run` can run at most one \
|
|
|
|
executable, but multiple were \
|
|
|
|
specified"));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-10-27 21:49:20 +00:00
|
|
|
|
|
|
|
test!(one_bin_multiple_examples {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/bin/main.rs", r#"
|
|
|
|
fn main() { println!("hello main.rs"); }
|
|
|
|
"#)
|
|
|
|
.file("examples/a.rs", r#"
|
|
|
|
fn main() { println!("hello a.rs"); }
|
|
|
|
"#)
|
|
|
|
.file("examples/b.rs", r#"
|
|
|
|
fn main() { println!("hello b.rs"); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2014-10-27 21:49:20 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}main[..]`
|
2014-10-27 21:49:20 +00:00
|
|
|
hello main.rs
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-08-07 00:50:55 +00:00
|
|
|
|
2015-01-03 16:33:08 +00:00
|
|
|
test!(example_with_release_flag {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "*"
|
|
|
|
path = "bar"
|
|
|
|
"#)
|
|
|
|
.file("examples/a.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
|
|
|
|
fn main() {
|
2015-03-24 00:45:41 +00:00
|
|
|
if cfg!(debug_assertions) {
|
2015-01-03 16:33:08 +00:00
|
|
|
println!("slow1")
|
2015-03-24 00:45:41 +00:00
|
|
|
} else {
|
|
|
|
println!("fast1")
|
2015-01-03 16:33:08 +00:00
|
|
|
}
|
|
|
|
bar::baz();
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
pub fn baz() {
|
2015-03-24 00:45:41 +00:00
|
|
|
if cfg!(debug_assertions) {
|
2015-01-03 16:33:08 +00:00
|
|
|
println!("slow2")
|
2015-03-24 00:45:41 +00:00
|
|
|
} else {
|
|
|
|
println!("fast2")
|
2015-01-03 16:33:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("-v").arg("--release").arg("--example").arg("a"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2015-01-03 16:33:08 +00:00
|
|
|
{compiling} bar v0.0.1 ({url})
|
2015-01-14 03:10:16 +00:00
|
|
|
{running} `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
2015-01-03 16:33:08 +00:00
|
|
|
-C opt-level=3 \
|
|
|
|
-C metadata=[..] \
|
|
|
|
-C extra-filename=[..] \
|
|
|
|
--out-dir {dir}{sep}target{sep}release{sep}deps \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
|
|
|
-L dependency={dir}{sep}target{sep}release{sep}deps`
|
|
|
|
{compiling} foo v0.0.1 ({url})
|
2015-01-14 03:10:16 +00:00
|
|
|
{running} `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
2015-01-03 16:33:08 +00:00
|
|
|
-C opt-level=3 \
|
|
|
|
--out-dir {dir}{sep}target{sep}release{sep}examples \
|
|
|
|
--emit=dep-info,link \
|
|
|
|
-L dependency={dir}{sep}target{sep}release \
|
|
|
|
-L dependency={dir}{sep}target{sep}release{sep}deps \
|
|
|
|
--extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar-[..].rlib`
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}release{sep}examples{sep}a[..]`
|
2015-01-03 16:33:08 +00:00
|
|
|
fast1
|
|
|
|
fast2
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = p.root().display(),
|
|
|
|
url = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2015-01-03 16:33:08 +00:00
|
|
|
|
2015-02-27 01:04:25 +00:00
|
|
|
assert_that(p.cargo("run").arg("-v").arg("--example").arg("a"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2015-01-03 16:33:08 +00:00
|
|
|
{compiling} bar v0.0.1 ({url})
|
2015-01-14 03:10:16 +00:00
|
|
|
{running} `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
|
2015-01-03 16:33:08 +00:00
|
|
|
-g \
|
|
|
|
-C metadata=[..] \
|
|
|
|
-C extra-filename=[..] \
|
2015-03-03 21:46:02 +00:00
|
|
|
--out-dir {dir}{sep}target{sep}debug{sep}deps \
|
2015-01-03 16:33:08 +00:00
|
|
|
--emit=dep-info,link \
|
2015-03-03 21:46:02 +00:00
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps`
|
2015-01-03 16:33:08 +00:00
|
|
|
{compiling} foo v0.0.1 ({url})
|
2015-01-14 03:10:16 +00:00
|
|
|
{running} `rustc examples{sep}a.rs --crate-name a --crate-type bin \
|
2015-01-03 16:33:08 +00:00
|
|
|
-g \
|
2015-03-03 21:46:02 +00:00
|
|
|
--out-dir {dir}{sep}target{sep}debug{sep}examples \
|
2015-01-03 16:33:08 +00:00
|
|
|
--emit=dep-info,link \
|
2015-03-03 21:46:02 +00:00
|
|
|
-L dependency={dir}{sep}target{sep}debug \
|
|
|
|
-L dependency={dir}{sep}target{sep}debug{sep}deps \
|
|
|
|
--extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar-[..].rlib`
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}debug{sep}examples{sep}a[..]`
|
2015-01-03 16:33:08 +00:00
|
|
|
slow1
|
|
|
|
slow2
|
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = p.root().display(),
|
|
|
|
url = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2015-01-03 16:33:08 +00:00
|
|
|
});
|
|
|
|
|
2014-08-07 00:50:55 +00:00
|
|
|
test!(run_dylib_dep {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() { bar::bar(); }
|
|
|
|
"#)
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-08-07 00:50:55 +00:00
|
|
|
name = "bar"
|
|
|
|
crate-type = ["dylib"]
|
|
|
|
"#)
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}");
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run").arg("hello").arg("world"),
|
2014-08-07 00:50:55 +00:00
|
|
|
execs().with_status(0));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-08-22 16:53:56 +00:00
|
|
|
|
2014-08-25 14:51:13 +00:00
|
|
|
test!(release_works {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
2015-03-24 00:45:41 +00:00
|
|
|
fn main() { if cfg!(debug_assertions) { panic!() } }
|
2014-08-25 14:51:13 +00:00
|
|
|
"#);
|
|
|
|
|
2014-08-27 15:01:26 +00:00
|
|
|
assert_that(p.cargo_process("run").arg("--release"),
|
2015-03-26 18:17:44 +00:00
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2014-08-25 14:51:13 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
2015-03-23 23:56:29 +00:00
|
|
|
{running} `target{sep}release{sep}foo[..]`
|
2014-08-25 14:51:13 +00:00
|
|
|
",
|
|
|
|
compiling = COMPILING,
|
|
|
|
running = RUNNING,
|
|
|
|
dir = path2url(p.root()),
|
2015-03-26 18:17:44 +00:00
|
|
|
sep = SEP)));
|
2014-08-25 14:51:13 +00:00
|
|
|
assert_that(&p.release_bin("foo"), existing_file());
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2014-08-27 15:04:38 +00:00
|
|
|
|
2014-08-22 16:53:56 +00:00
|
|
|
test!(run_bin_different_name {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/bar.rs", r#"
|
|
|
|
fn main() { }
|
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("run"), execs().with_status(0));
|
2014-12-19 18:38:32 +00:00
|
|
|
});
|
2015-07-28 01:08:28 +00:00
|
|
|
|
|
|
|
test!(dashes_are_forwarded {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {
|
|
|
|
let s: Vec<String> = std::env::args().collect();
|
|
|
|
assert_eq!(s[1], "a");
|
|
|
|
assert_eq!(s[2], "--");
|
|
|
|
assert_eq!(s[3], "b");
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("run").arg("--").arg("a").arg("--").arg("b"),
|
|
|
|
execs().with_status(0));
|
|
|
|
});
|
2015-08-29 11:03:14 +00:00
|
|
|
|
|
|
|
test!(run_from_executable_folder {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
let cwd = p.root().join("target").join("debug");
|
|
|
|
p.cargo_process("build").exec_with_output().unwrap();
|
|
|
|
|
|
|
|
assert_that(p.cargo("run").cwd(cwd),
|
|
|
|
execs().with_status(0).with_stdout(&format!("\
|
2015-08-29 15:07:52 +00:00
|
|
|
{running} `.{sep}foo[..]`
|
2015-08-29 11:03:14 +00:00
|
|
|
hello
|
|
|
|
",
|
2015-08-29 15:07:52 +00:00
|
|
|
running = RUNNING,
|
|
|
|
sep = SEP
|
2015-08-29 11:03:14 +00:00
|
|
|
)));
|
|
|
|
});
|