flag_allow_dirty: allow_dirty,
flag_jobs: jobs,
flag_dry_run: dry_run,
+ flag_target: target,
..
} = options;
else { config.shell().warn(&msg)?; host }, // TODO: Deprecated, remove
verify: !no_verify,
allow_dirty: allow_dirty,
- target: options.flag_target.as_ref().map(|t| &t[..]),
+ target: target.as_ref().map(|t| &t[..]),
jobs: jobs,
dry_run: dry_run,
})?;
--- /dev/null
+use std::env;
+use std::process::Command;
+use std::sync::{Once, ONCE_INIT};
+use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
+
+use support::{project, main_file, basic_bin_manifest};
+
+pub fn disabled() -> bool {
+ // First, disable if ./configure requested so
+ match env::var("CFG_DISABLE_CROSS_TESTS") {
+ Ok(ref s) if *s == "1" => return true,
+ _ => {}
+ }
+
+ // Right now the windows bots cannot cross compile due to the mingw setup,
+ // so we disable ourselves on all but macos/linux setups where the rustc
+ // install script ensures we have both architectures
+ if !(cfg!(target_os = "macos") ||
+ cfg!(target_os = "linux") ||
+ cfg!(target_env = "msvc")) {
+ return true;
+ }
+
+ // It's not particularly common to have a cross-compilation setup, so
+ // try to detect that before we fail a bunch of tests through no fault
+ // of the user.
+ static CAN_RUN_CROSS_TESTS: AtomicBool = ATOMIC_BOOL_INIT;
+ static CHECK: Once = ONCE_INIT;
+
+ let cross_target = alternate();
+
+ CHECK.call_once(|| {
+ let p = project("cross_test")
+ .file("Cargo.toml", &basic_bin_manifest("cross_test"))
+ .file("src/cross_test.rs", &main_file(r#""testing!""#, &[]));
+
+ let result = p.cargo_process("build")
+ .arg("--target").arg(&cross_target)
+ .exec_with_output();
+
+ if result.is_ok() {
+ CAN_RUN_CROSS_TESTS.store(true, Ordering::SeqCst);
+ }
+ });
+
+ if CAN_RUN_CROSS_TESTS.load(Ordering::SeqCst) {
+ // We were able to compile a simple project, so the user has the
+ // necessary std:: bits installed. Therefore, tests should not
+ // be disabled.
+ return false;
+ }
+
+ // We can't compile a simple cross project. We want to warn the user
+ // by failing a single test and having the remainder of the cross tests
+ // pass. We don't use std::sync::Once here because panicing inside its
+ // call_once method would poison the Once instance, which is not what
+ // we want.
+ static HAVE_WARNED: AtomicBool = ATOMIC_BOOL_INIT;
+
+ if HAVE_WARNED.swap(true, Ordering::SeqCst) {
+ // We are some other test and somebody else is handling the warning.
+ // Just disable the current test.
+ return true;
+ }
+
+ // We are responsible for warning the user, which we do by panicing.
+ let rustup_available = Command::new("rustup").output().is_ok();
+
+ let linux_help = if cfg!(target_os = "linux") {
+ "
+
+You may need to install runtime libraries for your Linux distribution as well.".to_string()
+ } else {
+ "".to_string()
+ };
+
+ let rustup_help = if rustup_available {
+ format!("
+
+Alternatively, you can install the necessary libraries for cross-compilation with
+
+ rustup target add {}{}", cross_target, linux_help)
+ } else {
+ "".to_string()
+ };
+
+ panic!("Cannot cross compile to {}.
+
+This failure can be safely ignored. If you would prefer to not see this
+failure, you can set the environment variable CFG_DISABLE_CROSS_TESTS to \"1\".{}
+", cross_target, rustup_help);
+}
+
+pub fn alternate() -> String {
+ let platform = match env::consts::OS {
+ "linux" => "unknown-linux-gnu",
+ "macos" => "apple-darwin",
+ "windows" => "pc-windows-msvc",
+ _ => unreachable!(),
+ };
+ let arch = match env::consts::ARCH {
+ "x86" => "x86_64",
+ "x86_64" => "i686",
+ _ => unreachable!(),
+ };
+ format!("{}-{}", arch, platform)
+}
+
+pub fn alternate_arch() -> &'static str {
+ match env::consts::ARCH {
+ "x86" => "x86_64",
+ "x86_64" => "x86",
+ _ => unreachable!(),
+ }
+}
+
+pub fn host() -> String {
+ let platform = match env::consts::OS {
+ "linux" => "unknown-linux-gnu",
+ "macos" => "apple-darwin",
+ "windows" => "pc-windows-msvc",
+ _ => unreachable!(),
+ };
+ let arch = match env::consts::ARCH {
+ "x86" => "i686",
+ "x86_64" => "x86_64",
+ _ => unreachable!(),
+ };
+ format!("{}-{}", arch, platform)
+}
\ No newline at end of file
pub mod paths;
pub mod git;
pub mod registry;
+pub mod cross_compile;
+pub mod publish;
/*
*
--- /dev/null
+extern crate url;
+
+use std::path::PathBuf;
+use std::io::prelude::*;
+use std::fs::{self, File};
+
+use support::paths;
+use support::git::repo;
+
+use url::Url;
+
+pub fn setup() {
+ let config = paths::root().join(".cargo/config");
+ t!(fs::create_dir_all(config.parent().unwrap()));
+ t!(t!(File::create(&config)).write_all(br#"
+ [registry]
+ token = "api-token"
+ "#));
+ t!(fs::create_dir_all(&upload_path().join("api/v1/crates")));
+
+ repo(®istry_path())
+ .file("config.json", &format!(r#"{{
+ "dl": "{0}",
+ "api": "{0}"
+ }}"#, upload()))
+ .build();
+}
+
+fn registry_path() -> PathBuf { paths::root().join("registry") }
+pub fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() }
+pub fn upload_path() -> PathBuf { paths::root().join("upload") }
+fn upload() -> Url { Url::from_file_path(&*upload_path()).ok().unwrap() }
\ No newline at end of file
extern crate cargotest;
extern crate hamcrest;
-use std::env;
-use std::process::Command;
-use std::sync::{Once, ONCE_INIT};
-use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
-
use cargo::util::process;
use cargotest::{is_nightly, rustc_host};
-use cargotest::support::{project, execs, main_file, basic_bin_manifest};
+use cargotest::support::{project, execs, basic_bin_manifest, cross_compile};
use hamcrest::{assert_that, existing_file};
-fn disabled() -> bool {
- // First, disable if ./configure requested so
- match env::var("CFG_DISABLE_CROSS_TESTS") {
- Ok(ref s) if *s == "1" => return true,
- _ => {}
- }
-
- // Right now the windows bots cannot cross compile due to the mingw setup,
- // so we disable ourselves on all but macos/linux setups where the rustc
- // install script ensures we have both architectures
- if !(cfg!(target_os = "macos") ||
- cfg!(target_os = "linux") ||
- cfg!(target_env = "msvc")) {
- return true;
- }
-
- // It's not particularly common to have a cross-compilation setup, so
- // try to detect that before we fail a bunch of tests through no fault
- // of the user.
- static CAN_RUN_CROSS_TESTS: AtomicBool = ATOMIC_BOOL_INIT;
- static CHECK: Once = ONCE_INIT;
-
- let cross_target = alternate();
-
- CHECK.call_once(|| {
- let p = project("cross_test")
- .file("Cargo.toml", &basic_bin_manifest("cross_test"))
- .file("src/cross_test.rs", &main_file(r#""testing!""#, &[]));
-
- let result = p.cargo_process("build")
- .arg("--target").arg(&cross_target)
- .exec_with_output();
-
- if result.is_ok() {
- CAN_RUN_CROSS_TESTS.store(true, Ordering::SeqCst);
- }
- });
-
- if CAN_RUN_CROSS_TESTS.load(Ordering::SeqCst) {
- // We were able to compile a simple project, so the user has the
- // necessary std:: bits installed. Therefore, tests should not
- // be disabled.
- return false;
- }
-
- // We can't compile a simple cross project. We want to warn the user
- // by failing a single test and having the remainder of the cross tests
- // pass. We don't use std::sync::Once here because panicing inside its
- // call_once method would poison the Once instance, which is not what
- // we want.
- static HAVE_WARNED: AtomicBool = ATOMIC_BOOL_INIT;
-
- if HAVE_WARNED.swap(true, Ordering::SeqCst) {
- // We are some other test and somebody else is handling the warning.
- // Just disable the current test.
- return true;
- }
-
- // We are responsible for warning the user, which we do by panicing.
- let rustup_available = Command::new("rustup").output().is_ok();
-
- let linux_help = if cfg!(target_os = "linux") {
- "
-
-You may need to install runtime libraries for your Linux distribution as well.".to_string()
- } else {
- "".to_string()
- };
-
- let rustup_help = if rustup_available {
- format!("
-
-Alternatively, you can install the necessary libraries for cross-compilation with
-
- rustup target add {}{}", cross_target, linux_help)
- } else {
- "".to_string()
- };
-
- panic!("Cannot cross compile to {}.
-
-This failure can be safely ignored. If you would prefer to not see this
-failure, you can set the environment variable CFG_DISABLE_CROSS_TESTS to \"1\".{}
-", cross_target, rustup_help);
-}
-
-fn alternate() -> String {
- let platform = match env::consts::OS {
- "linux" => "unknown-linux-gnu",
- "macos" => "apple-darwin",
- "windows" => "pc-windows-msvc",
- _ => unreachable!(),
- };
- let arch = match env::consts::ARCH {
- "x86" => "x86_64",
- "x86_64" => "i686",
- _ => unreachable!(),
- };
- format!("{}-{}", arch, platform)
-}
-
-fn alternate_arch() -> &'static str {
- match env::consts::ARCH {
- "x86" => "x86_64",
- "x86_64" => "x86",
- _ => unreachable!(),
- }
-}
-
-fn host() -> String {
- let platform = match env::consts::OS {
- "linux" => "unknown-linux-gnu",
- "macos" => "apple-darwin",
- "windows" => "pc-windows-msvc",
- _ => unreachable!(),
- };
- let arch = match env::consts::ARCH {
- "x86" => "i686",
- "x86_64" => "x86_64",
- _ => unreachable!(),
- };
- format!("{}-{}", arch, platform)
-}
-
#[test]
fn simple_cross() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
fn main() {{
assert_eq!(std::env::var("TARGET").unwrap(), "{}");
}}
- "#, alternate()))
+ "#, cross_compile::alternate()))
.file("src/main.rs", &format!(r#"
use std::env;
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
#[test]
fn simple_cross_config() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file(".cargo/config", &format!(r#"
[build]
target = "{}"
- "#, alternate()))
+ "#, cross_compile::alternate()))
.file("Cargo.toml", r#"
[package]
name = "foo"
fn main() {{
assert_eq!(std::env::var("TARGET").unwrap(), "{}");
}}
- "#, alternate()))
+ "#, cross_compile::alternate()))
.file("src/main.rs", &format!(r#"
use std::env;
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
#[test]
fn simple_deps() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/lib.rs", "pub fn bar() {}");
p2.build();
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
#[test]
fn plugin_deps() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
if !is_nightly() { return }
let foo = project("foo")
bar.build();
baz.build();
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(foo.cargo_process("build").arg("--target").arg(&target),
execs().with_status(0));
assert_that(&foo.target_bin(&target, "foo"), existing_file());
#[test]
fn plugin_to_the_max() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
if !is_nightly() { return }
let foo = project("foo")
bar.build();
baz.build();
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(foo.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
println!("second");
#[test]
fn linker_and_ar() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let p = project("foo")
.file(".cargo/config", &format!(r#"
[target.{}]
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
assert_that(p.cargo_process("build").arg("--target").arg(&target)
.arg("-v"),
#[test]
fn plugin_with_extra_dylib_dep() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
if !is_nightly() { return }
let foo = project("foo")
bar.build();
baz.build();
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(foo.cargo_process("build").arg("--target").arg(&target),
execs().with_status(0));
}
#[test]
fn cross_tests() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
assert_eq!(env::consts::ARCH, "{}");
}}
#[test] fn test() {{ main() }}
- "#, alternate_arch()))
+ "#, cross_compile::alternate_arch()))
.file("src/lib.rs", &format!(r#"
use std::env;
pub fn foo() {{ assert_eq!(env::consts::ARCH, "{}"); }}
#[test] fn test_foo() {{ foo() }}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("test").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
#[test]
fn no_cross_doctests() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
.with_stderr(&host_output));
println!("b");
- let target = host();
+ let target = cross_compile::host();
assert_that(p.cargo("test").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
", foo = p.url(), triple = target)));
println!("c");
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo("test").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
#[test]
fn simple_cargo_run() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("run").arg("--target").arg(&target),
execs().with_status(0));
}
#[test]
fn cross_with_a_build_script() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let p = project("foo")
.file("Cargo.toml", r#"
[package]
#[test]
fn build_script_needed_for_host_and_target() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let host = rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
#[test]
fn build_deps_for_the_right_arch() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
.file("d2/build.rs", "extern crate d1; fn main() {}")
.file("d2/src/lib.rs", "");
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
}
#[test]
fn build_script_only_host() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
}
"#);
- let target = alternate();
+ let target = cross_compile::alternate();
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
}
#[test]
fn plugin_build_script_right_arch() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
let p = project("foo")
.file("Cargo.toml", r#"
[package]
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(alternate()),
+ assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(cross_compile::alternate()),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.0.1 ([..])
#[test]
fn build_script_with_platform_specific_dependencies() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let host = rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
#[test]
fn platform_specific_dependencies_do_not_leak() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let host = rustc_host();
let p = project("foo")
.file("Cargo.toml", r#"
#[test]
fn platform_specific_variables_reflected_in_build_scripts() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let host = rustc_host();
let p = project("foo")
.file("Cargo.toml", &format!(r#"
#[test]
fn cross_test_dylib() {
- if disabled() { return }
+ if cross_compile::disabled() { return }
- let target = alternate();
+ let target = cross_compile::alternate();
let p = project("foo")
.file("Cargo.toml", r#"
pub fn baz() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, alternate_arch()));
+ "#, cross_compile::alternate_arch()));
assert_that(p.cargo_process("test").arg("--target").arg(&target),
execs().with_status(0)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] target[/]{arch}[/]debug[/]deps[/]foo-[..][EXE]
[RUNNING] target[/]{arch}[/]debug[/]deps[/]test-[..][EXE]",
- dir = p.url(), arch = alternate()))
+ dir = p.url(), arch = cross_compile::alternate()))
.with_stdout_contains_n("test foo ... ok", 2));
}
--- /dev/null
+extern crate cargo;
+extern crate cargotest;
+extern crate hamcrest;
+extern crate flate2;
+extern crate tar;
+
+use std::fs::File;
+use std::path::PathBuf;
+use std::io::prelude::*;
+
+use cargotest::support::{project, execs, cross_compile, publish};
+use hamcrest::{assert_that, contains};
+use flate2::read::GzDecoder;
+use tar::Archive;
+
+#[test]
+fn simple_cross_package() {
+ if cross_compile::disabled() { return }
+
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ license = "MIT"
+ description = "foo"
+ repository = "bar"
+ "#)
+ .file("src/main.rs", &format!(r#"
+ use std::env;
+ fn main() {{
+ assert_eq!(env::consts::ARCH, "{}");
+ }}
+ "#, cross_compile::alternate_arch()));
+
+ let target = cross_compile::alternate();
+
+ assert_that(p.cargo_process("package").arg("--target").arg(&target),
+ execs().with_status(0).with_status(0).with_stderr(&format!(
+" Packaging foo v0.0.0 ({dir})
+ Verifying foo v0.0.0 ({dir})
+ Compiling foo v0.0.0 ({dir}/target/package/foo-0.0.0)
+ Finished dev [unoptimized + debuginfo] target(s) in [..]
+", dir = p.url())));
+
+ // Check that the tarball contains the files
+ let f = File::open(&p.root().join("target/package/foo-0.0.0.crate")).unwrap();
+ let mut rdr = GzDecoder::new(f).unwrap();
+ let mut contents = Vec::new();
+ rdr.read_to_end(&mut contents).unwrap();
+ let mut ar = Archive::new(&contents[..]);
+ let entries = ar.entries().unwrap();
+ 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.0/Cargo.toml")]));
+ assert_that(&entry_paths, contains(vec![PathBuf::from("foo-0.0.0/Cargo.toml.orig")]));
+ assert_that(&entry_paths, contains(vec![PathBuf::from("foo-0.0.0/src/main.rs")]));
+}
+
+#[test]
+fn publish_with_target() {
+ if cross_compile::disabled() { return }
+
+ publish::setup();
+
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ license = "MIT"
+ description = "foo"
+ repository = "bar"
+ "#)
+ .file("src/main.rs", &format!(r#"
+ use std::env;
+ fn main() {{
+ assert_eq!(env::consts::ARCH, "{}");
+ }}
+ "#, cross_compile::alternate_arch()));
+
+ p.build();
+
+ let target = cross_compile::alternate();
+
+ assert_that(p.cargo("publish")
+ .arg("--index").arg(publish::registry().to_string())
+ .arg("--target").arg(&target),
+ execs().with_status(0).with_stderr(&format!(
+" Updating registry `{registry}`
+ Packaging foo v0.0.0 ({dir})
+ Verifying foo v0.0.0 ({dir})
+ Compiling foo v0.0.0 ({dir}/target/package/foo-0.0.0)
+ Finished dev [unoptimized + debuginfo] target(s) in [..]
+ Uploading foo v0.0.0 ({dir})
+", dir = p.url(), registry = publish::registry())));
+}
\ No newline at end of file
-#[macro_use]
extern crate cargotest;
extern crate flate2;
extern crate hamcrest;
extern crate tar;
-extern crate url;
use std::io::prelude::*;
-use std::fs::{self, File};
+use std::fs::File;
use std::io::SeekFrom;
-use std::path::PathBuf;
use cargotest::support::git::repo;
use cargotest::support::paths;
-use cargotest::support::{project, execs};
+use cargotest::support::{project, execs, publish};
use flate2::read::GzDecoder;
use hamcrest::assert_that;
use tar::Archive;
-use url::Url;
-
-fn registry_path() -> PathBuf { paths::root().join("registry") }
-fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() }
-fn upload_path() -> PathBuf { paths::root().join("upload") }
-fn upload() -> Url { Url::from_file_path(&*upload_path()).ok().unwrap() }
-
-fn setup() {
- let config = paths::root().join(".cargo/config");
- t!(fs::create_dir_all(config.parent().unwrap()));
- t!(t!(File::create(&config)).write_all(br#"
- [registry]
- token = "api-token"
- "#));
- t!(fs::create_dir_all(&upload_path().join("api/v1/crates")));
-
- repo(®istry_path())
- .file("config.json", &format!(r#"{{
- "dl": "{0}",
- "api": "{0}"
- }}"#, upload()))
- .build();
-}
#[test]
fn simple() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("--no-verify")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[WARNING] manifest has no documentation, [..]
[UPLOADING] foo v0.0.1 ({dir})
",
dir = p.url(),
- reg = registry())));
+ reg = publish::registry())));
- let mut f = File::open(&upload_path().join("api/v1/crates/new")).unwrap();
+ let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap();
// Skip the metadata payload and the size of the tarball
let mut sz = [0; 4];
assert_eq!(f.read(&mut sz).unwrap(), 4);
// remove once it has been decided --host can be removed
#[test]
fn simple_with_host() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("--no-verify")
- .arg("--host").arg(registry().to_string()),
+ .arg("--host").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[WARNING] The flag '--host' is no longer valid.
[UPLOADING] foo v0.0.1 ({dir})
",
dir = p.url(),
- reg = registry())));
+ reg = publish::registry())));
- let mut f = File::open(&upload_path().join("api/v1/crates/new")).unwrap();
+ let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap();
// Skip the metadata payload and the size of the tarball
let mut sz = [0; 4];
assert_eq!(f.read(&mut sz).unwrap(), 4);
// remove once it has been decided --host can be removed
#[test]
fn simple_with_index_and_host() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("--no-verify")
- .arg("--index").arg(registry().to_string())
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string())
+ .arg("--host").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[WARNING] The flag '--host' is no longer valid.
[UPLOADING] foo v0.0.1 ({dir})
",
dir = p.url(),
- reg = registry())));
+ reg = publish::registry())));
- let mut f = File::open(&upload_path().join("api/v1/crates/new")).unwrap();
+ let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap();
// Skip the metadata payload and the size of the tarball
let mut sz = [0; 4];
assert_eq!(f.read(&mut sz).unwrap(), 4);
#[test]
fn git_deps() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] crates cannot be published to crates.io with dependencies sourced from \
#[test]
fn path_dependency_no_version() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("bar/src/lib.rs", "");
assert_that(p.cargo_process("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] all path dependencies must have a version specified when publishing.
#[test]
fn unpublishable_crate() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[ERROR] some crates cannot be published.
`foo` is marked as unpublishable
#[test]
fn dont_publish_dirty() {
- setup();
+ publish::setup();
let p = project("foo")
.file("bar", "");
p.build();
.build();
assert_that(p.cargo("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry `[..]`
error: 1 files in the working directory contain changes that were not yet \
#[test]
fn publish_clean() {
- setup();
+ publish::setup();
let p = project("foo");
p.build();
.build();
assert_that(p.cargo("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0));
}
#[test]
fn publish_in_sub_repo() {
- setup();
+ publish::setup();
let p = project("foo")
.file("baz", "");
.build();
assert_that(p.cargo("publish").cwd(p.root().join("bar"))
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0));
}
#[test]
fn publish_when_ignored() {
- setup();
+ publish::setup();
let p = project("foo")
.file("baz", "");
.build();
assert_that(p.cargo("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0));
}
#[test]
fn ignore_when_crate_ignored() {
- setup();
+ publish::setup();
let p = project("foo")
.file("bar/baz", "");
"#)
.nocommit_file("bar/src/main.rs", "fn main() {}");
assert_that(p.cargo("publish").cwd(p.root().join("bar"))
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0));
}
#[test]
fn new_crate_rejected() {
- setup();
+ publish::setup();
let p = project("foo")
.file("baz", "");
"#)
.nocommit_file("src/main.rs", "fn main() {}");
assert_that(p.cargo("publish")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(101));
}
#[test]
fn dry_run() {
- setup();
+ publish::setup();
let p = project("foo")
.file("Cargo.toml", r#"
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("--dry-run")
- .arg("--index").arg(registry().to_string()),
+ .arg("--index").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[WARNING] manifest has no documentation, [..]
dir = p.url())));
// Ensure the API request wasn't actually made
- assert!(!upload_path().join("api/v1/crates/new").exists());
+ assert!(!publish::upload_path().join("api/v1/crates/new").exists());
}