cargo/tests/test_cargo_package.rs
Alex Crichton 9fba127e4f Update how cargo talks to the registry
This commit includes a laundry list of updates and tweaks to reflect the current
API of the registry:

* `registry.host` has been renamed to `registry.index`
* New top-level manifest keys are now accepted:
  * `homepage` - url
  * `documentation` - url
  * `repository` - url
  * `description` - a markdown-less blurb
  * `license` - string (verified by the registry on upload)
  * `keywords` - string array
  * `readme` - string pointing at a file
* Authors are now uploaded to the registry
* The upload format to the registry has changed to a body json payload
* Unpacking tarballs respects the executable bit for scripts and such.
* Downloading now follows redirects to go to S3.
* The download URL for a package has changed slightly.
* Verify path dependencies have a version listed when being uploaded
* Rename `upload` to `publish`
* Rename `ops::cargo_upload` to `ops::registry`
* Add a new `registry` package for interoperating with the registry
* Add the ability to modify owners via `cargo owner`
* Add a `readme` key to the manifest, and upload its contents to the registry.
* Add the ability to yank crates and their versions
* When packaging a library, verify that it builds from the packaged source by
  unpacking the tarball and simulate running `cargo build` inside of it.
2014-10-27 12:40:23 -07:00

53 lines
1.6 KiB
Rust

use std::io::{File, MemReader};
use tar::Archive;
use flate2::reader::GzDecoder;
use support::{project, execs, cargo_dir, ResultTest};
use support::{PACKAGING, VERIFYING, COMPILING};
use hamcrest::{assert_that, existing_file};
fn setup() {
}
test!(simple {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
exclude = ["*.txt"]
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#)
.file("src/bar.txt", ""); // should be ignored when packaging
assert_that(p.cargo_process("package"),
execs().with_status(0).with_stdout(format!("\
{packaging} foo v0.0.1 ({dir})
{verifying} foo v0.0.1 ({dir})
{compiling} foo v0.0.1 ({dir}[..])
",
packaging = PACKAGING,
verifying = VERIFYING,
compiling = COMPILING,
dir = p.url()).as_slice()));
assert_that(&p.root().join("foo-0.0.1.tar.gz"), existing_file());
assert_that(p.process(cargo_dir().join("cargo")).arg("package"),
execs().with_status(0).with_stdout(""));
let f = File::open(&p.root().join("foo-0.0.1.tar.gz")).assert();
let mut rdr = GzDecoder::new(f);
let contents = rdr.read_to_end().assert();
let ar = Archive::new(MemReader::new(contents));
for f in ar.files().assert() {
let f = f.assert();
let fname = f.filename_bytes();
assert!(fname == Path::new("foo-0.0.1/Cargo.toml").as_vec() ||
fname == Path::new("foo-0.0.1/src/main.rs").as_vec(),
"unexpected filename: {}", f.filename())
}
})