mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
Ensure crates are tested after packaged
The `target` directory was erroneously being used from the crate root rather than the root of the package directory itself, leading to packages not actually testing what's precisely being published.
This commit is contained in:
parent
1bdfb25de6
commit
6e81812eaa
|
@ -165,6 +165,7 @@ fn run_verify(pkg: &Package, shell: &mut MultiShell, tar: &Path)
|
|||
});
|
||||
let mut new_manifest = pkg.get_manifest().clone();
|
||||
new_manifest.set_summary(new_summary);
|
||||
new_manifest.set_target_dir(dst.join("target"));
|
||||
let new_pkg = Package::new(new_manifest, &manifest_path,
|
||||
pkg.get_package_id().get_source_id());
|
||||
|
||||
|
|
|
@ -98,7 +98,11 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
|
|||
try!(links::validate(deps));
|
||||
|
||||
let dest = uniq_target_dest(targets);
|
||||
let root = deps.iter().find(|p| p.get_package_id() == resolve.root()).unwrap();
|
||||
let root = if resolve.root() == pkg.get_package_id() {
|
||||
pkg
|
||||
} else {
|
||||
deps.iter().find(|p| p.get_package_id() == resolve.root()).unwrap()
|
||||
};
|
||||
let host_layout = Layout::new(root, None, dest);
|
||||
let target_layout = config.target().map(|target| {
|
||||
layout::Layout::new(root, Some(target), dest)
|
||||
|
|
|
@ -130,3 +130,28 @@ test!(metadata_warning {
|
|||
dir = p.url()).as_slice()));
|
||||
|
||||
})
|
||||
|
||||
test!(package_verification {
|
||||
let p = project("all")
|
||||
.file("Cargo.toml", r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
"#)
|
||||
.file("src/main.rs", r#"
|
||||
fn main() {}
|
||||
"#);
|
||||
assert_that(p.cargo_process("build"),
|
||||
execs().with_status(0));
|
||||
assert_that(p.process(cargo_dir().join("cargo")).arg("package"),
|
||||
execs().with_status(0).with_stdout(format!("\
|
||||
{packaging} foo v0.0.1 ({dir})
|
||||
{verifying} foo v0.0.1 ({dir})
|
||||
{compiling} foo v0.0.1 ({dir}[..])
|
||||
",
|
||||
packaging = PACKAGING,
|
||||
verifying = VERIFYING,
|
||||
compiling = COMPILING,
|
||||
dir = p.url()).as_slice()));
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue