2018-02-08 00:13:17 +00:00
|
|
|
use std;
|
2017-02-15 14:16:41 +00:00
|
|
|
use std::fs::File;
|
2015-02-27 01:04:25 +00:00
|
|
|
use std::io::prelude::*;
|
2016-07-05 19:32:04 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2014-09-09 02:38:16 +00:00
|
|
|
|
2018-02-08 00:13:17 +00:00
|
|
|
use git2;
|
2018-01-18 19:33:26 +00:00
|
|
|
use cargotest::{cargo_process, process, ChannelChanger};
|
2018-03-14 15:17:44 +00:00
|
|
|
use cargotest::support::{cargo_exe, execs, git, paths, project, registry, path2url};
|
2017-05-22 15:56:27 +00:00
|
|
|
use cargotest::support::registry::Package;
|
2015-01-14 05:40:22 +00:00
|
|
|
use flate2::read::GzDecoder;
|
2018-03-14 15:17:44 +00:00
|
|
|
use hamcrest::{assert_that, contains, existing_file};
|
2016-05-26 00:06:25 +00:00
|
|
|
use tar::Archive;
|
2014-07-18 15:40:45 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn simple() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2014-07-18 15:40:45 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-09-09 02:38:16 +00:00
|
|
|
exclude = ["*.txt"]
|
2014-11-18 12:23:53 +00:00
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-07-18 15:40:45 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
2014-09-09 02:38:16 +00:00
|
|
|
"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/bar.txt", "") // should be ignored when packaging
|
|
|
|
.build();
|
2014-07-18 15:40:45 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no documentation[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2014-07-18 15:40:45 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
&p.root().join("target/package/foo-0.0.1.crate"),
|
|
|
|
existing_file(),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-l"),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2014-11-13 06:28:30 +00:00
|
|
|
Cargo.toml
|
2016-11-06 12:33:49 +00:00
|
|
|
src[/]main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
assert_that(p.cargo("package"), execs().with_status(0).with_stdout(""));
|
2014-09-09 02:38:16 +00:00
|
|
|
|
2014-12-21 23:19:44 +00:00
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
2017-12-29 14:37:22 +00:00
|
|
|
let mut rdr = GzDecoder::new(f);
|
2015-02-27 01:04:25 +00:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
2016-01-20 17:07:47 +00:00
|
|
|
let mut ar = Archive::new(&contents[..]);
|
|
|
|
for f in ar.entries().unwrap() {
|
2014-12-21 23:19:44 +00:00
|
|
|
let f = f.unwrap();
|
2015-08-03 17:04:22 +00:00
|
|
|
let fname = f.header().path_bytes();
|
|
|
|
let fname = &*fname;
|
2018-03-14 15:17:44 +00:00
|
|
|
assert!(
|
|
|
|
fname == b"foo-0.0.1/Cargo.toml" || fname == b"foo-0.0.1/Cargo.toml.orig"
|
|
|
|
|| fname == b"foo-0.0.1/src/main.rs",
|
|
|
|
"unexpected filename: {:?}",
|
|
|
|
f.header().path()
|
|
|
|
)
|
2014-09-09 02:38:16 +00:00
|
|
|
}
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-18 12:23:53 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn metadata_warning() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
warning: manifest has no description, license, license-file, documentation, \
|
2016-09-01 00:04:29 +00:00
|
|
|
homepage or repository.
|
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2014-11-18 12:23:53 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2014-11-18 12:23:53 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-09-01 00:04:29 +00:00
|
|
|
warning: manifest has no description, documentation, homepage or repository.
|
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2014-11-18 12:23:53 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2014-11-18 12:23:53 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
2014-12-15 04:43:38 +00:00
|
|
|
repository = "bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-11-18 12:23:53 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2014-11-18 12:23:53 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-18 12:23:53 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn package_verbose() {
|
2014-11-21 20:31:00 +00:00
|
|
|
let root = paths::root().join("all");
|
|
|
|
let p = git::repo(&root)
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-11-21 20:31:00 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-11-21 20:31:00 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
2014-11-21 20:31:00 +00:00
|
|
|
[project]
|
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
.build();
|
2016-05-26 00:06:25 +00:00
|
|
|
let mut cargo = cargo_process();
|
2015-12-17 17:53:14 +00:00
|
|
|
cargo.cwd(p.root());
|
2014-11-21 20:31:00 +00:00
|
|
|
assert_that(cargo.clone().arg("build"), execs().with_status(0));
|
2016-03-01 16:24:43 +00:00
|
|
|
|
|
|
|
println!("package main repo");
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
cargo.clone().arg("package").arg("-v").arg("--no-verify"),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no description[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([..])
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-03-01 16:24:43 +00:00
|
|
|
|
|
|
|
println!("package sub-repo");
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
cargo
|
|
|
|
.arg("package")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("--no-verify")
|
|
|
|
.cwd(p.root().join("a")),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no description[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] a v0.0.1 ([..])
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-21 06:48:18 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn package_verification() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-11-21 06:48:18 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-11-21 06:48:18 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no description[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2014-11-21 06:48:18 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-06 07:54:16 +00:00
|
|
|
|
2016-08-31 23:13:26 +00:00
|
|
|
#[test]
|
|
|
|
fn path_dependency_no_version() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2016-08-31 23:13:26 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2016-08-31 23:13:26 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2016-08-31 23:13:26 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
2016-08-31 23:13:26 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
"\
|
2016-09-01 00:04:29 +00:00
|
|
|
[WARNING] manifest has no documentation, homepage or repository.
|
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-08-31 23:13:26 +00:00
|
|
|
[ERROR] all path dependencies must have a version specified when packaging.
|
|
|
|
dependency `bar` does not specify a version.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-08-31 23:13:26 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn exclude() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-01-06 07:54:16 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-07-07 18:52:03 +00:00
|
|
|
exclude = [
|
|
|
|
"*.txt",
|
|
|
|
# file in root
|
|
|
|
"file_root_1", # NO_CHANGE (ignored)
|
|
|
|
"/file_root_2", # CHANGING (packaged -> ignored)
|
|
|
|
"file_root_3/", # NO_CHANGE (packaged)
|
|
|
|
"file_root_4/*", # NO_CHANGE (packaged)
|
|
|
|
"file_root_5/**", # NO_CHANGE (packaged)
|
|
|
|
# file in sub-dir
|
|
|
|
"file_deep_1", # CHANGING (packaged -> ignored)
|
|
|
|
"/file_deep_2", # NO_CHANGE (packaged)
|
|
|
|
"file_deep_3/", # NO_CHANGE (packaged)
|
|
|
|
"file_deep_4/*", # NO_CHANGE (packaged)
|
|
|
|
"file_deep_5/**", # NO_CHANGE (packaged)
|
|
|
|
# dir in root
|
|
|
|
"dir_root_1", # CHANGING (packaged -> ignored)
|
|
|
|
"/dir_root_2", # CHANGING (packaged -> ignored)
|
|
|
|
"dir_root_3/", # CHANGING (packaged -> ignored)
|
|
|
|
"dir_root_4/*", # NO_CHANGE (ignored)
|
|
|
|
"dir_root_5/**", # NO_CHANGE (ignored)
|
|
|
|
# dir in sub-dir
|
|
|
|
"dir_deep_1", # CHANGING (packaged -> ignored)
|
|
|
|
"/dir_deep_2", # NO_CHANGE
|
|
|
|
"dir_deep_3/", # CHANGING (packaged -> ignored)
|
|
|
|
"dir_deep_4/*", # CHANGING (packaged -> ignored)
|
|
|
|
"dir_deep_5/**", # CHANGING (packaged -> ignored)
|
|
|
|
]
|
2015-01-06 07:54:16 +00:00
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#)
|
|
|
|
.file("bar.txt", "")
|
2017-07-07 18:52:03 +00:00
|
|
|
.file("src/bar.txt", "")
|
|
|
|
// file in root
|
|
|
|
.file("file_root_1", "")
|
|
|
|
.file("file_root_2", "")
|
|
|
|
.file("file_root_3", "")
|
|
|
|
.file("file_root_4", "")
|
|
|
|
.file("file_root_5", "")
|
|
|
|
// file in sub-dir
|
|
|
|
.file("some_dir/file_deep_1", "")
|
|
|
|
.file("some_dir/file_deep_2", "")
|
|
|
|
.file("some_dir/file_deep_3", "")
|
|
|
|
.file("some_dir/file_deep_4", "")
|
|
|
|
.file("some_dir/file_deep_5", "")
|
|
|
|
// dir in root
|
|
|
|
.file("dir_root_1/some_dir/file", "")
|
|
|
|
.file("dir_root_2/some_dir/file", "")
|
|
|
|
.file("dir_root_3/some_dir/file", "")
|
|
|
|
.file("dir_root_4/some_dir/file", "")
|
|
|
|
.file("dir_root_5/some_dir/file", "")
|
|
|
|
// dir in sub-dir
|
|
|
|
.file("some_dir/dir_deep_1/some_dir/file", "")
|
|
|
|
.file("some_dir/dir_deep_2/some_dir/file", "")
|
|
|
|
.file("some_dir/dir_deep_3/some_dir/file", "")
|
|
|
|
.file("some_dir/dir_deep_4/some_dir/file", "")
|
|
|
|
.file("some_dir/dir_deep_5/some_dir/file", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-01-06 07:54:16 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("--no-verify").arg("-v"),
|
|
|
|
execs().with_status(0).with_stdout("").with_stderr(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no description[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([..])
|
2017-07-07 18:52:03 +00:00
|
|
|
[WARNING] [..] file `dir_root_1[/]some_dir[/]file` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[WARNING] [..] file `dir_root_2[/]some_dir[/]file` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[WARNING] [..] file `dir_root_3[/]some_dir[/]file` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[WARNING] [..] file `some_dir[/]dir_deep_1[/]some_dir[/]file` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[WARNING] [..] file `some_dir[/]dir_deep_3[/]some_dir[/]file` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[WARNING] [..] file `some_dir[/]file_deep_1` WILL be excluded [..]
|
|
|
|
See [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2017-07-07 18:52:03 +00:00
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2017-07-07 18:52:03 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
&p.root().join("target/package/foo-0.0.1.crate"),
|
|
|
|
existing_file(),
|
|
|
|
);
|
2017-07-07 18:52:03 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-l"),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2017-07-07 18:52:03 +00:00
|
|
|
Cargo.toml
|
|
|
|
dir_root_1[/]some_dir[/]file
|
|
|
|
dir_root_2[/]some_dir[/]file
|
|
|
|
dir_root_3[/]some_dir[/]file
|
|
|
|
file_root_3
|
|
|
|
file_root_4
|
|
|
|
file_root_5
|
|
|
|
some_dir[/]dir_deep_1[/]some_dir[/]file
|
|
|
|
some_dir[/]dir_deep_2[/]some_dir[/]file
|
|
|
|
some_dir[/]dir_deep_3[/]some_dir[/]file
|
|
|
|
some_dir[/]dir_deep_4[/]some_dir[/]file
|
|
|
|
some_dir[/]dir_deep_5[/]some_dir[/]file
|
|
|
|
some_dir[/]file_deep_1
|
|
|
|
some_dir[/]file_deep_2
|
|
|
|
some_dir[/]file_deep_3
|
|
|
|
some_dir[/]file_deep_4
|
|
|
|
some_dir[/]file_deep_5
|
|
|
|
src[/]main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-06 07:54:16 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn include() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-01-06 07:54:16 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
exclude = ["*.txt"]
|
|
|
|
include = ["foo.txt", "**/*.rs", "Cargo.toml"]
|
|
|
|
"#)
|
|
|
|
.file("foo.txt", "")
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/bar.txt", "") // should be ignored when packaging
|
|
|
|
.build();
|
2015-01-06 07:54:16 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("--no-verify").arg("-v"),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no description[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2016-05-12 15:23:53 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([..])
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
|
|
|
[ARCHIVING] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-03-11 20:32:59 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn package_lib_with_bin() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-03-11 20:32:59 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-03-11 20:32:59 +00:00
|
|
|
extern crate foo;
|
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2015-03-11 20:32:59 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(p.cargo("package").arg("-v"), execs().with_status(0));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-14 05:40:22 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn package_git_submodule() {
|
2015-06-02 13:56:44 +00:00
|
|
|
let project = git::new("foo", |project| {
|
2018-03-14 15:17:44 +00:00
|
|
|
project
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-06-02 13:56:44 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = ["foo@example.com"]
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
2015-06-02 13:56:44 +00:00
|
|
|
}).unwrap();
|
2018-03-14 15:17:44 +00:00
|
|
|
let library = git::new("bar", |library| library.file("Makefile", "all:")).unwrap();
|
2015-06-02 13:56:44 +00:00
|
|
|
|
|
|
|
let repository = git2::Repository::open(&project.root()).unwrap();
|
|
|
|
let url = path2url(library.root()).to_string();
|
|
|
|
git::add_submodule(&repository, &url, Path::new("bar"));
|
|
|
|
git::commit(&repository);
|
|
|
|
|
|
|
|
let repository = git2::Repository::open(&project.root().join("bar")).unwrap();
|
2018-03-14 15:17:44 +00:00
|
|
|
repository
|
|
|
|
.reset(
|
|
|
|
&repository.revparse_single("HEAD").unwrap(),
|
|
|
|
git2::ResetType::Hard,
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
cargo_process()
|
|
|
|
.arg("package")
|
|
|
|
.cwd(project.root())
|
|
|
|
.arg("--no-verify")
|
|
|
|
.arg("-v"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains("[ARCHIVING] bar/Makefile"),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-07-05 18:34:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn no_duplicates_from_modified_tracked_files() {
|
2016-01-10 19:47:02 +00:00
|
|
|
let root = paths::root().join("all");
|
|
|
|
let p = git::repo(&root)
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2016-01-10 19:47:02 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2016-01-10 19:47:02 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
File::create(p.root().join("src/main.rs"))
|
|
|
|
.unwrap()
|
|
|
|
.write_all(
|
|
|
|
br#"
|
2016-01-10 19:47:02 +00:00
|
|
|
fn main() { println!("A change!"); }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.unwrap();
|
2016-05-26 00:06:25 +00:00
|
|
|
let mut cargo = cargo_process();
|
2016-01-10 19:47:02 +00:00
|
|
|
cargo.cwd(p.root());
|
|
|
|
assert_that(cargo.clone().arg("build"), execs().with_status(0));
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
cargo.arg("package").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2016-01-10 19:47:02 +00:00
|
|
|
Cargo.toml
|
|
|
|
src/main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-01-10 19:47:02 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn ignore_nested() {
|
2015-07-05 18:34:43 +00:00
|
|
|
let cargo_toml = r#"
|
|
|
|
[project]
|
2018-07-20 17:41:44 +00:00
|
|
|
name = "foo"
|
2015-07-05 18:34:43 +00:00
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
2018-07-20 17:41:44 +00:00
|
|
|
description = "foo"
|
2015-07-05 18:34:43 +00:00
|
|
|
"#;
|
|
|
|
let main_rs = r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#;
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2015-07-05 18:34:43 +00:00
|
|
|
.file("Cargo.toml", cargo_toml)
|
|
|
|
.file("src/main.rs", main_rs)
|
|
|
|
// If a project happens to contain a copy of itself, we should
|
|
|
|
// ignore it.
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("a_dir/foo/Cargo.toml", cargo_toml)
|
|
|
|
.file("a_dir/foo/src/main.rs", main_rs)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-07-05 18:34:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-20 00:52:13 +00:00
|
|
|
[WARNING] manifest has no documentation[..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See http://doc.crates.io/manifest.html#package-metadata for more info.
|
2018-07-20 17:41:44 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2015-07-05 18:34:43 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
assert_that(
|
2018-07-20 17:41:44 +00:00
|
|
|
&p.root().join("target/package/foo-0.0.1.crate"),
|
2018-03-14 15:17:44 +00:00
|
|
|
existing_file(),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-l"),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2015-07-05 18:34:43 +00:00
|
|
|
Cargo.toml
|
|
|
|
src[..]main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
assert_that(p.cargo("package"), execs().with_status(0).with_stdout(""));
|
2015-07-05 18:34:43 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
2017-12-29 14:37:22 +00:00
|
|
|
let mut rdr = GzDecoder::new(f);
|
2015-07-05 18:34:43 +00:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
2016-01-20 17:07:47 +00:00
|
|
|
let mut ar = Archive::new(&contents[..]);
|
|
|
|
for f in ar.entries().unwrap() {
|
2015-07-05 18:34:43 +00:00
|
|
|
let f = f.unwrap();
|
2015-08-03 17:04:22 +00:00
|
|
|
let fname = f.header().path_bytes();
|
|
|
|
let fname = &*fname;
|
2018-03-14 15:17:44 +00:00
|
|
|
assert!(
|
2018-07-20 17:41:44 +00:00
|
|
|
fname == b"foo-0.0.1/Cargo.toml" || fname == b"foo-0.0.1/Cargo.toml.orig"
|
|
|
|
|| fname == b"foo-0.0.1/src/main.rs",
|
2018-03-14 15:17:44 +00:00
|
|
|
"unexpected filename: {:?}",
|
|
|
|
f.header().path()
|
|
|
|
)
|
2015-07-05 18:34:43 +00:00
|
|
|
}
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-11-04 21:11:19 +00:00
|
|
|
|
|
|
|
#[cfg(unix)] // windows doesn't allow these characters in filenames
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn package_weird_characters() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-11-04 21:11:19 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-11-04 21:11:19 +00:00
|
|
|
fn main() { println!("hello"); }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/:foo", "")
|
|
|
|
.build();
|
2015-11-04 21:11:19 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
"\
|
2015-11-04 21:11:19 +00:00
|
|
|
warning: [..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See [..]
|
2016-05-20 00:52:13 +00:00
|
|
|
[PACKAGING] foo [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] failed to prepare local package for uploading
|
2015-11-04 21:11:19 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
cannot package a filename with a special character `:`: src/:foo
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-07-05 19:32:04 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn repackage_on_source_change() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2016-07-05 19:32:04 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2016-07-05 19:32:04 +00:00
|
|
|
fn main() { println!("hello"); }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-05 19:32:04 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(p.cargo("package"), execs().with_status(0));
|
2016-07-05 19:32:04 +00:00
|
|
|
|
|
|
|
// Add another source file
|
|
|
|
let mut file = File::create(p.root().join("src").join("foo.rs")).unwrap_or_else(|e| {
|
2018-03-14 15:17:44 +00:00
|
|
|
panic!(
|
|
|
|
"could not create file {}: {}",
|
|
|
|
p.root().join("src/foo.rs").display(),
|
|
|
|
e
|
|
|
|
)
|
2016-07-05 19:32:04 +00:00
|
|
|
});
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
file.write_all(
|
|
|
|
br#"
|
2016-07-05 19:32:04 +00:00
|
|
|
fn main() { println!("foo"); }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
).unwrap();
|
2016-07-05 19:32:04 +00:00
|
|
|
std::mem::drop(file);
|
|
|
|
|
2017-03-02 06:38:54 +00:00
|
|
|
let mut pro = process(&cargo_exe());
|
2016-07-05 19:32:04 +00:00
|
|
|
pro.arg("package").cwd(p.root());
|
|
|
|
|
|
|
|
// Check that cargo rebuilds the tarball
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
pro,
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-07-05 19:32:04 +00:00
|
|
|
[WARNING] [..]
|
2016-09-01 00:04:29 +00:00
|
|
|
See [..]
|
2016-07-05 19:32:04 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-07-05 19:32:04 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-07-05 19:32:04 +00:00
|
|
|
|
|
|
|
// Check that the tarball contains the added file
|
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
2017-12-29 14:37:22 +00:00
|
|
|
let mut rdr = GzDecoder::new(f);
|
2016-07-05 19:32:04 +00:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
|
|
|
let entries = ar.entries().unwrap();
|
2018-03-14 15:17:44 +00:00
|
|
|
let entry_paths = entries
|
|
|
|
.map(|entry| entry.unwrap().path().unwrap().into_owned())
|
|
|
|
.collect::<Vec<PathBuf>>();
|
|
|
|
assert_that(
|
|
|
|
&entry_paths,
|
|
|
|
contains(vec![PathBuf::from("foo-0.0.1/src/foo.rs")]),
|
|
|
|
);
|
2016-07-05 19:32:04 +00:00
|
|
|
}
|
2016-07-26 19:55:10 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn broken_symlink() {
|
|
|
|
use std::os::unix::fs;
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2016-07-26 19:55:10 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = 'foo'
|
|
|
|
documentation = 'foo'
|
|
|
|
homepage = 'foo'
|
|
|
|
repository = 'foo'
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2016-07-26 19:55:10 +00:00
|
|
|
fn main() { println!("hello"); }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-26 19:55:10 +00:00
|
|
|
t!(fs::symlink("nowhere", &p.root().join("src/foo.rs")));
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-v"),
|
|
|
|
execs().with_status(101).with_stderr_contains(
|
|
|
|
"\
|
2016-07-26 19:55:10 +00:00
|
|
|
error: failed to prepare local package for uploading
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to open for archiving: `[..]foo.rs`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-07-26 19:55:10 +00:00
|
|
|
}
|
2016-09-03 01:05:26 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn do_not_package_if_repository_is_dirty() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2016-09-03 01:05:26 +00:00
|
|
|
// Create a Git repository containing a minimal Rust project.
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2016-09-03 01:05:26 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2016-09-03 01:05:26 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// Modify Cargo.toml without committing the change.
|
2018-03-14 15:17:44 +00:00
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-02-15 14:16:41 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
# change
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
);
|
2016-09-03 01:05:26 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
"\
|
2017-04-09 02:20:41 +00:00
|
|
|
error: 1 files in the working directory contain changes that were not yet \
|
|
|
|
committed into git:
|
2016-09-03 01:05:26 +00:00
|
|
|
|
|
|
|
Cargo.toml
|
|
|
|
|
|
|
|
to proceed despite this, pass the `--allow-dirty` flag
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-09-03 01:05:26 +00:00
|
|
|
}
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn generated_manifest() {
|
2017-10-02 10:04:02 +00:00
|
|
|
Package::new("abc", "1.0.0").publish();
|
2018-02-27 15:56:04 +00:00
|
|
|
Package::new("def", "1.0.0").alternative(true).publish();
|
2017-10-02 10:04:02 +00:00
|
|
|
Package::new("ghi", "1.0.0").publish();
|
2018-02-27 15:56:04 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-01-18 19:33:26 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
exclude = ["*.txt"]
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
2017-06-14 14:56:40 +00:00
|
|
|
[project.metadata]
|
|
|
|
foo = 'bar'
|
|
|
|
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[workspace]
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar", version = "0.1" }
|
2018-01-18 19:33:26 +00:00
|
|
|
def = { version = "1.0", registry = "alternative" }
|
2017-10-02 10:04:02 +00:00
|
|
|
ghi = "1.0"
|
|
|
|
abc = "1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
.file("src/main.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.arg("--no-verify"),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
|
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
2017-12-29 14:37:22 +00:00
|
|
|
let mut rdr = GzDecoder::new(f);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
2018-03-14 15:17:44 +00:00
|
|
|
let mut entry = ar.entries()
|
|
|
|
.unwrap()
|
|
|
|
.map(|f| f.unwrap())
|
|
|
|
.find(|e| e.path().unwrap().ends_with("Cargo.toml"))
|
|
|
|
.unwrap();
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
let mut contents = String::new();
|
|
|
|
entry.read_to_string(&mut contents).unwrap();
|
2017-10-02 10:04:02 +00:00
|
|
|
// BTreeMap makes the order of dependencies in the generated file deterministic
|
|
|
|
// by sorting alphabetically
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_eq!(
|
|
|
|
&contents[..],
|
|
|
|
&*format!(
|
|
|
|
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
#
|
|
|
|
# When uploading crates to the registry Cargo will automatically
|
|
|
|
# "normalize" Cargo.toml files for maximal compatibility
|
|
|
|
# with all versions of Cargo and also rewrite `path` dependencies
|
|
|
|
# to registry (e.g. crates.io) dependencies
|
|
|
|
#
|
|
|
|
# If you believe there's an error in this file please file an
|
|
|
|
# issue against the rust-lang/cargo repository. If you're
|
|
|
|
# editing this file be aware that the upstream Cargo.toml
|
|
|
|
# will likely look very different (and much more reasonable)
|
|
|
|
|
2018-01-18 19:33:26 +00:00
|
|
|
cargo-features = ["alternative-registries"]
|
|
|
|
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
exclude = ["*.txt"]
|
|
|
|
description = "foo"
|
|
|
|
license = "MIT"
|
2017-06-14 14:56:40 +00:00
|
|
|
|
|
|
|
[package.metadata]
|
|
|
|
foo = "bar"
|
2017-10-02 10:04:02 +00:00
|
|
|
[dependencies.abc]
|
|
|
|
version = "1.0"
|
|
|
|
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.1"
|
2017-10-02 10:04:02 +00:00
|
|
|
|
|
|
|
[dependencies.def]
|
|
|
|
version = "1.0"
|
2018-01-18 19:53:12 +00:00
|
|
|
registry-index = "{}"
|
2017-10-02 10:04:02 +00:00
|
|
|
|
|
|
|
[dependencies.ghi]
|
|
|
|
version = "1.0"
|
2018-01-18 19:33:26 +00:00
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
registry::alt_registry()
|
|
|
|
)
|
|
|
|
);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ignore_workspace_specifier() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2017-05-22 15:56:27 +00:00
|
|
|
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar", version = "0.1" }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
.file("src/main.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
workspace = ".."
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package")
|
|
|
|
.arg("--no-verify")
|
|
|
|
.cwd(p.root().join("bar")),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
|
|
|
|
let f = File::open(&p.root().join("target/package/bar-0.1.0.crate")).unwrap();
|
2017-12-29 14:37:22 +00:00
|
|
|
let mut rdr = GzDecoder::new(f);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
2018-03-14 15:17:44 +00:00
|
|
|
let mut entry = ar.entries()
|
|
|
|
.unwrap()
|
|
|
|
.map(|f| f.unwrap())
|
|
|
|
.find(|e| e.path().unwrap().ends_with("Cargo.toml"))
|
|
|
|
.unwrap();
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
let mut contents = String::new();
|
|
|
|
entry.read_to_string(&mut contents).unwrap();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_eq!(
|
|
|
|
&contents[..],
|
|
|
|
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
#
|
|
|
|
# When uploading crates to the registry Cargo will automatically
|
|
|
|
# "normalize" Cargo.toml files for maximal compatibility
|
|
|
|
# with all versions of Cargo and also rewrite `path` dependencies
|
|
|
|
# to registry (e.g. crates.io) dependencies
|
|
|
|
#
|
|
|
|
# If you believe there's an error in this file please file an
|
|
|
|
# issue against the rust-lang/cargo repository. If you're
|
|
|
|
# editing this file be aware that the upstream Cargo.toml
|
|
|
|
# will likely look very different (and much more reasonable)
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#
|
|
|
|
);
|
Rewrite Cargo.toml when packaging crates
This commit is an implementation of rewriting TOML manifests when we publish
them to the registry. The rationale for doing this is to provide a guarantee
that downloaded tarballs from crates.io can be built with `cargo build`
(literally). This in turn eases a number of other possible consumers of crates
from crates.io
* Vendored sources can now be more easily modified/checked as cargo build should
work and they're standalone crates that suffice for `path` dependencies
* Tools like cargobomb/crater no longer need to edit the manifest and can
instead perform regression testing on the literal tarballs they download
* Other systems such as packaging Rust code may be able to take advantage of
this, but this is a less clear benefit.
Overall I'm hesitatnt about this, unfortunately. This is a silent translation
happening on *publish*, a rare operation, that's difficult to inspect before it
flies up to crates.io. I wrote a script to run this transformation over all
crates.io crates and found a surprisingly large number of discrepancies. The
transformation basically just downloaded all crates at all versions,
regenerated the manifest, and then tested if the two manifests were (in memory)
the same.
Unfortunately historical Cargo had a critical bug which I think made this
exercise not too useful. Cargo used to *not* recreate tarballs if one already
existed, which I believe led to situations such as:
1. `cargo publish`
2. Cargo generates an error about a dependency. This could be that there's a
`version` not present in a `path` dependency, there could be a `git`
dependency, etc.
3. Errors are fixed.
4. `cargo publish`
5. Publish is successful
In step 4 above historical Cargo *would not recreate the tarball*. This means
that the contents of the index (what was published) aren't guaranteed to match
with the tarball's `Cargo.toml`. When building from crates.io this is ok as the
index is the source of truth for dependency information, but it means that *any*
transformation to rewrite Cargo.toml is impossible to verify against all crates
on crates.io (due to historical bugs like these).
I strove to read as many errors as possible regardless, attempting to suss out
bugs in the implementation here. To further guard against surprises I've updated
the verification step of packaging to work "normally" in these sense that it's
not rewriting dependencies itself or changing summaries. I'm hoping that this
serves as a good last-ditch effort that what we're about to publish will indeed
build as expected when uploaded to crates.io
Overall I'm probably 70% confident in this change. I think it's necessary to
make progress, but I think there are going to be very painful bugs that arise
from this feature. I'm open to ideas to help weed out these bugs ahead of time!
I've done what I can but I fear it may not be entirely enough.
Closes #4027
2017-05-11 05:09:44 +00:00
|
|
|
}
|
2017-05-22 15:56:27 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn package_two_kinds_of_deps() {
|
|
|
|
Package::new("other", "1.0.0").publish();
|
|
|
|
Package::new("other1", "1.0.0").publish();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-05-22 15:56:27 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
other = "1.0"
|
|
|
|
other1 = { version = "1.0" }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/main.rs", "")
|
|
|
|
.build();
|
2017-05-22 15:56:27 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("--no-verify"),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
2017-05-22 15:56:27 +00:00
|
|
|
}
|
2018-02-05 21:42:42 +00:00
|
|
|
|
|
|
|
#[test]
|
2018-03-21 16:41:22 +00:00
|
|
|
fn test_edition() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-03-21 16:41:22 +00:00
|
|
|
cargo-features = ["edition"]
|
2018-02-05 21:42:42 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-05-03 16:14:25 +00:00
|
|
|
edition = "2018"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-05 21:42:42 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
|
|
|
|
execs()
|
2018-04-22 19:14:21 +00:00
|
|
|
// --edition is still in flux and we're not passing -Zunstable-options
|
2018-02-05 21:42:42 +00:00
|
|
|
// from Cargo so it will probably error. Only partially match the output
|
|
|
|
// until stuff stabilizes
|
2018-05-15 16:29:34 +00:00
|
|
|
.with_stderr_contains("\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[RUNNING] `rustc [..]--edition=2018 [..]
|
|
|
|
"),
|
2018-03-14 15:17:44 +00:00
|
|
|
);
|
2018-02-05 21:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-03-21 16:41:22 +00:00
|
|
|
fn test_edition_missing() {
|
|
|
|
// no edition = 2015
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-03-21 16:41:22 +00:00
|
|
|
cargo-features = ["edition"]
|
2018-02-05 21:42:42 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-05 21:42:42 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
|
|
|
|
execs()
|
2018-04-22 19:14:21 +00:00
|
|
|
// --edition is still in flux and we're not passing -Zunstable-options
|
2018-02-05 21:42:42 +00:00
|
|
|
// from Cargo so it will probably error. Only partially match the output
|
|
|
|
// until stuff stabilizes
|
2018-05-15 16:29:34 +00:00
|
|
|
.with_stderr_contains("\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[RUNNING] `rustc [..]--edition=2015 [..]
|
|
|
|
"),
|
2018-03-14 15:17:44 +00:00
|
|
|
);
|
2018-02-05 21:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-03-21 16:41:22 +00:00
|
|
|
fn test_edition_malformed() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-03-21 16:41:22 +00:00
|
|
|
cargo-features = ["edition"]
|
2018-02-05 21:42:42 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-05-03 16:14:25 +00:00
|
|
|
edition = "chicken"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-05 21:42:42 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(101).with_stderr(format!(
|
|
|
|
"\
|
2018-02-05 21:42:42 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2018-05-03 16:14:25 +00:00
|
|
|
failed to parse the `edition` key
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
supported edition values are `2015` or `2018`, but `chicken` is unknown
|
2018-03-14 15:17:44 +00:00
|
|
|
"
|
|
|
|
)),
|
|
|
|
);
|
2018-02-05 21:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-03-21 16:41:22 +00:00
|
|
|
fn test_edition_nightly() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-02-05 21:42:42 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-05-03 16:14:25 +00:00
|
|
|
edition = "2015"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-05 21:42:42 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("build").arg("-v").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(101).with_stderr(format!(
|
|
|
|
"\
|
2018-02-05 21:42:42 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2018-04-10 07:22:29 +00:00
|
|
|
editions are unstable
|
2018-02-05 21:42:42 +00:00
|
|
|
|
|
|
|
Caused by:
|
2018-03-21 16:41:22 +00:00
|
|
|
feature `edition` is required
|
2018-02-05 21:42:42 +00:00
|
|
|
|
2018-03-21 16:41:22 +00:00
|
|
|
consider adding `cargo-features = [\"edition\"]` to the manifest
|
2018-03-14 15:17:44 +00:00
|
|
|
"
|
|
|
|
)),
|
|
|
|
);
|
2018-02-12 20:42:31 +00:00
|
|
|
}
|
2018-02-27 15:56:04 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn package_lockfile() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-02-27 15:56:04 +00:00
|
|
|
cargo-features = ["publish-lockfile"]
|
|
|
|
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish-lockfile = true
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-27 15:56:04 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2018-02-27 15:56:04 +00:00
|
|
|
[WARNING] manifest has no documentation[..]
|
|
|
|
See [..]
|
|
|
|
[PACKAGING] foo v0.0.1 ({dir})
|
|
|
|
[VERIFYING] foo v0.0.1 ({dir})
|
|
|
|
[COMPILING] foo v0.0.1 ({dir}[..])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.url()
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
&p.root().join("target/package/foo-0.0.1.crate"),
|
|
|
|
existing_file(),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-l").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2018-02-27 15:56:04 +00:00
|
|
|
Cargo.lock
|
|
|
|
Cargo.toml
|
|
|
|
src[/]main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0).with_stdout(""),
|
|
|
|
);
|
2018-02-27 15:56:04 +00:00
|
|
|
|
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
|
|
|
let mut rdr = GzDecoder::new(f);
|
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
|
|
|
for f in ar.entries().unwrap() {
|
|
|
|
let f = f.unwrap();
|
|
|
|
let fname = f.header().path_bytes();
|
|
|
|
let fname = &*fname;
|
2018-03-14 15:17:44 +00:00
|
|
|
assert!(
|
|
|
|
fname == b"foo-0.0.1/Cargo.toml" || fname == b"foo-0.0.1/Cargo.toml.orig"
|
|
|
|
|| fname == b"foo-0.0.1/Cargo.lock"
|
|
|
|
|| fname == b"foo-0.0.1/src/main.rs",
|
|
|
|
"unexpected filename: {:?}",
|
|
|
|
f.header().path()
|
|
|
|
)
|
2018-02-27 15:56:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn package_lockfile_git_repo() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2018-02-27 15:56:04 +00:00
|
|
|
|
|
|
|
// Create a Git repository containing a minimal Rust project.
|
|
|
|
let _ = git::repo(&paths::root().join("foo"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-02-27 15:56:04 +00:00
|
|
|
cargo-features = ["publish-lockfile"]
|
|
|
|
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
documentation = "foo"
|
|
|
|
homepage = "foo"
|
|
|
|
repository = "foo"
|
|
|
|
publish-lockfile = true
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-27 15:56:04 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").arg("-l").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0).with_stdout(
|
|
|
|
"\
|
2018-02-27 15:56:04 +00:00
|
|
|
Cargo.lock
|
|
|
|
Cargo.toml
|
|
|
|
src/main.rs
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2018-02-27 15:56:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_lock_file_with_library() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-02-27 15:56:04 +00:00
|
|
|
cargo-features = ["publish-lockfile"]
|
|
|
|
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish-lockfile = true
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-27 15:56:04 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package").masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
2018-02-27 15:56:04 +00:00
|
|
|
|
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
|
|
|
let mut rdr = GzDecoder::new(f);
|
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
|
|
|
for f in ar.entries().unwrap() {
|
|
|
|
let f = f.unwrap();
|
|
|
|
let fname = f.header().path().unwrap();
|
|
|
|
assert!(!fname.ends_with("Cargo.lock"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn lock_file_and_workspace() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2018-02-27 15:56:04 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
r#"
|
2018-02-27 15:56:04 +00:00
|
|
|
cargo-features = ["publish-lockfile"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
publish-lockfile = true
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-02-27 15:56:04 +00:00
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("package")
|
|
|
|
.cwd(p.root().join("foo"))
|
|
|
|
.masquerade_as_nightly_cargo(),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
2018-02-27 15:56:04 +00:00
|
|
|
|
|
|
|
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
|
|
|
let mut rdr = GzDecoder::new(f);
|
|
|
|
let mut contents = Vec::new();
|
|
|
|
rdr.read_to_end(&mut contents).unwrap();
|
|
|
|
let mut ar = Archive::new(&contents[..]);
|
2018-03-14 15:17:44 +00:00
|
|
|
assert!(ar.entries().unwrap().into_iter().any(|f| {
|
|
|
|
let f = f.unwrap();
|
|
|
|
let fname = f.header().path().unwrap();
|
|
|
|
fname.ends_with("Cargo.lock")
|
|
|
|
}));
|
2018-02-27 15:56:04 +00:00
|
|
|
}
|
2018-05-28 11:59:35 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn do_not_package_if_src_was_modified() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-28 11:59:35 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() { println!("hello"); }
|
|
|
|
"#)
|
|
|
|
.file("build.rs", r#"
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Write;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut file = File::create("src/generated.txt").expect("failed to create file");
|
|
|
|
file.write_all(b"Hello, world of generated files.").expect("failed to write");
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("package"),
|
2018-05-29 09:05:34 +00:00
|
|
|
execs().with_status(101)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
error: failed to verify package tarball
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Source directory was modified by build.rs during cargo publish. \
|
2018-05-29 09:38:27 +00:00
|
|
|
Build scripts should not modify anything outside of OUT_DIR. Modified file: [..]src[/]generated.txt
|
2018-05-29 09:05:34 +00:00
|
|
|
|
|
|
|
To proceed despite this, pass the `--no-verify` flag.",
|
|
|
|
),
|
2018-05-28 11:59:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
assert_that(
|
2018-05-28 12:43:17 +00:00
|
|
|
p.cargo("package --no-verify"),
|
2018-05-28 11:59:35 +00:00
|
|
|
execs().with_status(0),
|
|
|
|
);
|
|
|
|
}
|