2014-11-21 03:14:58 +00:00
|
|
|
use std::io::{mod, fs, File};
|
|
|
|
use cargo::util::process;
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2014-10-23 05:05:30 +00:00
|
|
|
use support::{project, execs, cargo_dir};
|
2014-09-27 04:14:46 +00:00
|
|
|
use support::{UPDATING, DOWNLOADING, COMPILING, PACKAGING, VERIFYING};
|
2014-10-23 20:04:08 +00:00
|
|
|
use support::paths::{mod, PathExt};
|
2014-10-23 05:05:30 +00:00
|
|
|
use support::registry as r;
|
2014-09-09 05:26:14 +00:00
|
|
|
|
|
|
|
use hamcrest::assert_that;
|
|
|
|
|
|
|
|
fn setup() {
|
2014-10-23 05:05:30 +00:00
|
|
|
r::init();
|
2014-09-27 04:14:46 +00:00
|
|
|
}
|
|
|
|
|
2014-09-09 05:26:14 +00:00
|
|
|
test!(simple {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
2014-10-23 05:05:30 +00:00
|
|
|
bar = ">= 0.0.0"
|
2014-09-09 05:26:14 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
2014-10-23 05:05:30 +00:00
|
|
|
|
2014-09-09 05:26:14 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `{reg}`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} bar v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
2014-09-09 05:26:14 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
",
|
|
|
|
updating = UPDATING,
|
|
|
|
downloading = DOWNLOADING,
|
|
|
|
compiling = COMPILING,
|
|
|
|
dir = p.url(),
|
2014-10-23 05:05:30 +00:00
|
|
|
reg = r::registry()).as_slice()));
|
2014-09-09 14:23:09 +00:00
|
|
|
|
|
|
|
// Don't download a second time
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `{reg}`
|
2014-11-11 20:24:50 +00:00
|
|
|
[..] bar v0.0.1 (registry file://[..])
|
2014-09-09 14:23:09 +00:00
|
|
|
[..] foo v0.0.1 ({dir})
|
|
|
|
",
|
|
|
|
updating = UPDATING,
|
|
|
|
dir = p.url(),
|
2014-10-23 05:05:30 +00:00
|
|
|
reg = r::registry()).as_slice()));
|
2014-09-09 05:26:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(deps {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("baz", "0.0.1", &[]);
|
2014-11-21 02:17:31 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[("baz", "*", "normal")]);
|
2014-10-23 05:05:30 +00:00
|
|
|
|
2014-09-09 05:26:14 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `{reg}`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{compiling} baz v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
2014-09-09 05:26:14 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
",
|
|
|
|
updating = UPDATING,
|
|
|
|
downloading = DOWNLOADING,
|
|
|
|
compiling = COMPILING,
|
|
|
|
dir = p.url(),
|
2014-10-23 05:05:30 +00:00
|
|
|
reg = r::registry()).as_slice()));
|
2014-09-09 05:26:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(nonexistent {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
nonexistent = ">= 0.0.0"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
2014-10-17 15:17:17 +00:00
|
|
|
no package named `nonexistent` found (required by `foo`)
|
2014-11-11 20:24:50 +00:00
|
|
|
location searched: registry file://[..]
|
2014-10-17 15:17:17 +00:00
|
|
|
version required: >= 0.0.0
|
2014-09-09 05:26:14 +00:00
|
|
|
"));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(bad_cksum {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bad-cksum = ">= 0.0.0"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bad-cksum", "0.0.1", &[]);
|
2014-10-23 05:05:30 +00:00
|
|
|
File::create(&r::mock_archive_dst("bad-cksum", "0.0.1")).unwrap();
|
|
|
|
|
2014-09-09 05:26:14 +00:00
|
|
|
assert_that(p.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
Unable to get packages from source
|
|
|
|
|
|
|
|
Caused by:
|
2014-11-11 20:24:50 +00:00
|
|
|
Failed to download package `bad-cksum v0.0.1 (registry file://[..])` from [..]
|
2014-09-09 05:26:14 +00:00
|
|
|
|
|
|
|
Caused by:
|
2014-11-11 20:24:50 +00:00
|
|
|
Failed to verify the checksum of `bad-cksum v0.0.1 (registry file://[..])`
|
2014-09-09 05:26:14 +00:00
|
|
|
"));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(update_registry {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
notyet = ">= 0.0.0"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
2014-10-17 15:17:17 +00:00
|
|
|
no package named `notyet` found (required by `foo`)
|
2014-11-11 20:24:50 +00:00
|
|
|
location searched: registry file://[..]
|
2014-10-17 15:17:17 +00:00
|
|
|
version required: >= 0.0.0
|
2014-09-09 05:26:14 +00:00
|
|
|
"));
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("notyet", "0.0.1", &[]);
|
2014-09-09 05:26:14 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `{reg}`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} notyet v0.0.1 (registry file://[..])
|
|
|
|
{compiling} notyet v0.0.1 (registry file://[..])
|
2014-09-09 05:26:14 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
",
|
|
|
|
updating = UPDATING,
|
|
|
|
downloading = DOWNLOADING,
|
|
|
|
compiling = COMPILING,
|
|
|
|
dir = p.url(),
|
2014-10-23 05:05:30 +00:00
|
|
|
reg = r::registry()).as_slice()));
|
2014-09-09 05:26:14 +00:00
|
|
|
})
|
2014-09-27 04:14:46 +00:00
|
|
|
|
|
|
|
test!(package_with_path_deps {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-11-18 12:23:53 +00:00
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-09-27 04:14:46 +00:00
|
|
|
|
|
|
|
[dependencies.notyet]
|
|
|
|
version = "0.0.1"
|
|
|
|
path = "notyet"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("notyet/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "notyet"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("notyet/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("package").arg("-v"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
failed to verify package tarball
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
no package named `notyet` found (required by `foo`)
|
2014-11-11 20:24:50 +00:00
|
|
|
location searched: registry file://[..]
|
2014-09-27 04:14:46 +00:00
|
|
|
version required: ^0.0.1
|
|
|
|
"));
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("notyet", "0.0.1", &[]);
|
2014-09-27 04:14:46 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("package"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{packaging} foo v0.0.1 ({dir})
|
|
|
|
{verifying} foo v0.0.1 ({dir})
|
|
|
|
{updating} registry `[..]`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} notyet v0.0.1 (registry file://[..])
|
|
|
|
{compiling} notyet v0.0.1 (registry file://[..])
|
2014-11-05 02:56:08 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir}[..])
|
2014-09-27 04:14:46 +00:00
|
|
|
",
|
|
|
|
packaging = PACKAGING,
|
|
|
|
verifying = VERIFYING,
|
|
|
|
updating = UPDATING,
|
|
|
|
downloading = DOWNLOADING,
|
|
|
|
compiling = COMPILING,
|
|
|
|
dir = p.url(),
|
|
|
|
)));
|
|
|
|
})
|
2014-10-23 17:38:44 +00:00
|
|
|
|
|
|
|
test!(lockfile_locks {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
2014-10-23 17:38:44 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} bar v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
2014-10-23 17:38:44 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
|
|
|
|
p.root().move_into_the_past().unwrap();
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.2", &[]);
|
2014-10-23 17:38:44 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-10-23 20:04:08 +00:00
|
|
|
execs().with_status(0).with_stdout(""));
|
2014-10-23 17:38:44 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(lockfile_locks_transitively {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("baz", "0.0.1", &[]);
|
2014-11-21 02:17:31 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[("baz", "*", "normal")]);
|
2014-10-23 17:38:44 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{compiling} baz v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
2014-10-23 17:38:44 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
|
|
|
|
p.root().move_into_the_past().unwrap();
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("baz", "0.0.2", &[]);
|
2014-11-21 02:17:31 +00:00
|
|
|
r::mock_pkg("bar", "0.0.2", &[("baz", "*", "normal")]);
|
2014-10-23 17:38:44 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-10-23 20:04:08 +00:00
|
|
|
execs().with_status(0).with_stdout(""));
|
2014-10-23 17:38:44 +00:00
|
|
|
})
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
test!(yanks_are_not_used {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("baz", "0.0.1", &[]);
|
|
|
|
r::mock_pkg_yank("baz", "0.0.2", &[], true);
|
2014-11-21 02:17:31 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[("baz", "*", "normal")]);
|
|
|
|
r::mock_pkg_yank("bar", "0.0.2", &[("baz", "*", "normal")], true);
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{compiling} baz v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
2014-10-23 19:21:08 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(relying_on_a_yank_is_bad {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("baz", "0.0.1", &[]);
|
|
|
|
r::mock_pkg_yank("baz", "0.0.2", &[], true);
|
2014-11-21 02:17:31 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[("baz", "=0.0.2", "normal")]);
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
no package named `baz` found (required by `bar`)
|
2014-11-11 20:24:50 +00:00
|
|
|
location searched: registry file://[..]
|
2014-10-23 19:21:08 +00:00
|
|
|
version required: = 0.0.2
|
|
|
|
"));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(yanks_in_lockfiles_are_ok {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
fs::rmdir_recursive(&r::registry_path().join("3")).unwrap();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg_yank("bar", "0.0.1", &[], true);
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-10-23 20:04:08 +00:00
|
|
|
execs().with_status(0).with_stdout(""));
|
2014-10-23 19:21:08 +00:00
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("update"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
no package named `bar` found (required by `foo`)
|
2014-11-11 20:24:50 +00:00
|
|
|
location searched: registry file://[..]
|
2014-10-23 19:21:08 +00:00
|
|
|
version required: *
|
|
|
|
"));
|
|
|
|
})
|
2014-10-23 20:04:08 +00:00
|
|
|
|
|
|
|
test!(update_with_lockfile_if_packages_missing {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
2014-10-23 20:04:08 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0));
|
|
|
|
p.root().move_into_the_past().unwrap();
|
|
|
|
|
|
|
|
fs::rmdir_recursive(&paths::home().join(".cargo/registry")).unwrap();
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} bar v0.0.1 (registry file://[..])
|
2014-10-23 20:04:08 +00:00
|
|
|
", updating = UPDATING, downloading = DOWNLOADING).as_slice()));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(update_lockfile {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
2014-10-23 20:04:08 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
2014-11-22 10:04:40 +00:00
|
|
|
r::mock_pkg("bar", "0.0.2", &[]);
|
2014-10-23 20:04:08 +00:00
|
|
|
fs::rmdir_recursive(&paths::home().join(".cargo/registry")).unwrap();
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("update")
|
|
|
|
.arg("-p").arg("bar"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
|
|
|
", updating = UPDATING).as_slice()));
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
2014-11-11 20:24:50 +00:00
|
|
|
{downloading} [..] v0.0.2 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.2 (registry file://[..])
|
2014-10-23 20:04:08 +00:00
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
})
|
2014-11-21 02:17:31 +00:00
|
|
|
|
|
|
|
test!(dev_dependency_not_used {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
r::mock_pkg("baz", "0.0.1", &[]);
|
|
|
|
r::mock_pkg("bar", "0.0.1", &[("baz", "*", "dev")]);
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
|
|
|
{downloading} [..] v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
})
|
2014-11-21 03:14:58 +00:00
|
|
|
|
|
|
|
test!(login_with_no_cargo_dir {
|
|
|
|
let home = paths::home().join("new-home");
|
|
|
|
fs::mkdir(&home, io::USER_DIR).unwrap();
|
|
|
|
assert_that(process(cargo_dir().join("cargo")).unwrap()
|
|
|
|
.arg("login").arg("foo").arg("-v")
|
|
|
|
.cwd(paths::root())
|
|
|
|
.env("HOME", Some(home)),
|
|
|
|
execs().with_status(0));
|
|
|
|
})
|
2014-11-25 06:18:54 +00:00
|
|
|
|
|
|
|
test!(bad_license_file {
|
|
|
|
let p = project("all")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license-file = "foo"
|
|
|
|
description = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {}
|
|
|
|
"#);
|
|
|
|
assert_that(p.cargo_process("publish"),
|
|
|
|
execs().with_status(101)
|
|
|
|
.with_stderr("\
|
|
|
|
the license file `foo` does not exist"));
|
|
|
|
})
|
2014-11-27 23:49:16 +00:00
|
|
|
|
|
|
|
test!(updating_a_dep {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.a]
|
|
|
|
path = "a"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#)
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
r::mock_pkg("bar", "0.0.1", &[]);
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
|
|
|
{downloading} bar v0.0.1 (registry file://[..])
|
|
|
|
{compiling} bar v0.0.1 (registry file://[..])
|
|
|
|
{compiling} a v0.0.1 ({dir})
|
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
|
|
|
|
File::create(&p.root().join("a/Cargo.toml")).write_str(r#"
|
|
|
|
[project]
|
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#).unwrap();
|
|
|
|
r::mock_pkg("bar", "0.1.0", &[]);
|
|
|
|
|
|
|
|
println!("second");
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
|
|
|
execs().with_status(0).with_stdout(format!("\
|
|
|
|
{updating} registry `[..]`
|
|
|
|
{downloading} bar v0.1.0 (registry file://[..])
|
|
|
|
{compiling} bar v0.1.0 (registry file://[..])
|
|
|
|
{compiling} a v0.0.1 ({dir})
|
|
|
|
{compiling} foo v0.0.1 ({dir})
|
|
|
|
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
|
|
|
|
dir = p.url()).as_slice()));
|
|
|
|
})
|