mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Reorganise the testsuite crate module hierarchy
* Collapse the nested cargotest::support module into the cargotest module (merge the mod.rs's) * Rename the cargotest module to support * Nest the top-level hamcrest module into support
This commit is contained in:
parent
ffcf739578
commit
43b42d6f4c
@ -1,7 +1,7 @@
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::registry::{self, alt_api_path, Package};
|
||||
use cargotest::support::{execs, paths, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::ChannelChanger;
|
||||
use support::registry::{self, alt_api_path, Package};
|
||||
use support::{execs, paths, project};
|
||||
use support::hamcrest::assert_that;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn bad1() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
|
||||
let p = project()
|
||||
|
@ -1,10 +1,10 @@
|
||||
use std::str;
|
||||
|
||||
use cargo::util::process;
|
||||
use cargotest::{is_nightly, ChannelChanger};
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, execs, project};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::{is_nightly, ChannelChanger};
|
||||
use support::paths::CargoPathExt;
|
||||
use support::{basic_bin_manifest, basic_lib_manifest, execs, project};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn cargo_bench_simple() {
|
||||
|
@ -4,13 +4,13 @@ use std::io::prelude::*;
|
||||
|
||||
use cargo::util::paths::dylib_path_envvar;
|
||||
use cargo::util::{process, ProcessBuilder};
|
||||
use cargotest::{is_nightly, rustc_host, sleep_ms};
|
||||
use cargotest::support::paths::{root, CargoPathExt};
|
||||
use cargotest::support::ProjectBuilder;
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::{is_nightly, rustc_host, sleep_ms};
|
||||
use support::paths::{root, CargoPathExt};
|
||||
use support::ProjectBuilder;
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::registry::Package;
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use tempfile;
|
||||
|
||||
#[test]
|
||||
|
@ -6,9 +6,9 @@ use std::thread;
|
||||
|
||||
use git2;
|
||||
use bufstream::BufStream;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::paths;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
// Test that HTTP auth is offered from `credential.helper`
|
||||
#[test]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, project, Project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, execs, project, Project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
fn verbose_output_for_lib(p: &Project) -> String {
|
||||
format!(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::ChannelChanger;
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn cargo_build_plan_simple() {
|
||||
|
@ -7,11 +7,11 @@ use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use cargo::util::paths::remove_dir_all;
|
||||
use cargotest::{rustc_host, sleep_ms};
|
||||
use cargotest::support::{cross_compile, execs, project};
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::{assert_that, existing_dir, existing_file};
|
||||
use support::{rustc_host, sleep_ms};
|
||||
use support::{cross_compile, execs, project};
|
||||
use support::paths::CargoPathExt;
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file};
|
||||
|
||||
#[test]
|
||||
fn custom_build_script_failed() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::fs::File;
|
||||
|
||||
use cargotest::sleep_ms;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::sleep_ms;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn rerun_if_env_changes() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn alias_incorrect_config_type() {
|
||||
|
@ -5,11 +5,11 @@ use std::path::{Path, PathBuf};
|
||||
use std::str;
|
||||
|
||||
use cargo;
|
||||
use cargotest::cargo_process;
|
||||
use cargotest::support::paths::{self, CargoPathExt};
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{basic_bin_manifest, cargo_exe, execs, project, Project};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::cargo_process;
|
||||
use support::paths::{self, CargoPathExt};
|
||||
use support::registry::Package;
|
||||
use support::{basic_bin_manifest, cargo_exe, execs, project, Project};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[cfg_attr(windows, allow(dead_code))]
|
||||
enum FakeKind<'a> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::{execs, project, publish};
|
||||
use hamcrest::assert_that;
|
||||
use support::ChannelChanger;
|
||||
use support::{execs, project, publish};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn feature_required() {
|
||||
|
@ -1,179 +0,0 @@
|
||||
/*
|
||||
# Introduction To `cargotest`
|
||||
|
||||
Cargo has a wide variety of integration tests that execute the `cargo` binary
|
||||
and verify its behavior. The `cargotest` module contains many helpers to make
|
||||
this process easy.
|
||||
|
||||
The general form of a test involves creating a "project", running cargo, and
|
||||
checking the result. Projects are created with the `ProjectBuilder` where you
|
||||
specify some files to create. The general form looks like this:
|
||||
|
||||
```
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/main.rs", r#"fn main() { println!("hi!"); }"#)
|
||||
.build();
|
||||
```
|
||||
|
||||
To run cargo, call the `cargo` method and use the `hamcrest` matchers to check
|
||||
the output.
|
||||
|
||||
```
|
||||
assert_that(
|
||||
p.cargo("run --bin foo"),
|
||||
execs()
|
||||
.with_status(0)
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo [..]
|
||||
[FINISHED] [..]
|
||||
[RUNNING] `target[/]debug[/]foo`
|
||||
",
|
||||
)
|
||||
.with_stdout("hi!"),
|
||||
);
|
||||
```
|
||||
|
||||
The project creates a mini sandbox under the "cargo integration test"
|
||||
directory with each test getting a separate directory such as
|
||||
`/path/to/cargo/target/cit/t123/`. Each project appears as a separate
|
||||
directory. There is also an empty `home` directory created that will be used
|
||||
as a home directory instead of your normal home directory.
|
||||
|
||||
See `cargotest::support::lines_match` for an explanation of the string pattern
|
||||
matching.
|
||||
|
||||
See the `hamcrest` module for other matchers like
|
||||
`is_not(existing_file(path))`. This is not the actual hamcrest library, but
|
||||
instead a lightweight subset of matchers that are used in cargo tests.
|
||||
|
||||
Browse the `pub` functions in the `cargotest` module for a variety of other
|
||||
helpful utilities.
|
||||
|
||||
## Testing Nightly Features
|
||||
|
||||
If you are testing a Cargo feature that only works on "nightly" cargo, then
|
||||
you need to call `masquerade_as_nightly_cargo` on the process builder like
|
||||
this:
|
||||
|
||||
```
|
||||
p.cargo("build").masquerade_as_nightly_cargo()
|
||||
```
|
||||
|
||||
If you are testing a feature that only works on *nightly rustc* (such as
|
||||
benchmarks), then you should exit the test if it is not running with nightly
|
||||
rust, like this:
|
||||
|
||||
```
|
||||
if !is_nightly() {
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
## Platform-specific Notes
|
||||
|
||||
When checking output, be sure to use `[/]` when checking paths to
|
||||
automatically support backslashes on Windows.
|
||||
|
||||
Be careful when executing binaries on Windows. You should not rename, delete,
|
||||
or overwrite a binary immediately after running it. Under some conditions
|
||||
Windows will fail with errors like "directory not empty" or "failed to remove"
|
||||
or "access is denied".
|
||||
|
||||
*/
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use cargo::util::Rustc;
|
||||
use cargo;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[macro_use]
|
||||
pub mod support;
|
||||
|
||||
pub mod install;
|
||||
|
||||
thread_local!(
|
||||
pub static RUSTC: Rustc = Rustc::new(
|
||||
PathBuf::from("rustc"),
|
||||
None,
|
||||
Path::new("should be path to rustup rustc, but we don't care in tests"),
|
||||
None,
|
||||
).unwrap()
|
||||
);
|
||||
|
||||
/// The rustc host such as `x86_64-unknown-linux-gnu`.
|
||||
pub fn rustc_host() -> String {
|
||||
RUSTC.with(|r| r.host.clone())
|
||||
}
|
||||
|
||||
pub fn is_nightly() -> bool {
|
||||
RUSTC.with(|r| r.verbose_version.contains("-nightly") || r.verbose_version.contains("-dev"))
|
||||
}
|
||||
|
||||
pub fn process<T: AsRef<OsStr>>(t: T) -> cargo::util::ProcessBuilder {
|
||||
_process(t.as_ref())
|
||||
}
|
||||
|
||||
fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
|
||||
let mut p = cargo::util::process(t);
|
||||
p.cwd(&support::paths::root())
|
||||
.env_remove("CARGO_HOME")
|
||||
.env("HOME", support::paths::home())
|
||||
.env("CARGO_HOME", support::paths::home().join(".cargo"))
|
||||
.env("__CARGO_TEST_ROOT", support::paths::root())
|
||||
|
||||
// Force cargo to think it's on the stable channel for all tests, this
|
||||
// should hopefully not surprise us as we add cargo features over time and
|
||||
// cargo rides the trains.
|
||||
.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "stable")
|
||||
|
||||
// For now disable incremental by default as support hasn't ridden to the
|
||||
// stable channel yet. Once incremental support hits the stable compiler we
|
||||
// can switch this to one and then fix the tests.
|
||||
.env("CARGO_INCREMENTAL", "0")
|
||||
|
||||
// This env var can switch the git backend from libgit2 to git2-curl, which
|
||||
// can tweak error messages and cause some tests to fail, so let's forcibly
|
||||
// remove it.
|
||||
.env_remove("CARGO_HTTP_CHECK_REVOKE")
|
||||
|
||||
.env_remove("__CARGO_DEFAULT_LIB_METADATA")
|
||||
.env_remove("RUSTC")
|
||||
.env_remove("RUSTDOC")
|
||||
.env_remove("RUSTC_WRAPPER")
|
||||
.env_remove("RUSTFLAGS")
|
||||
.env_remove("XDG_CONFIG_HOME") // see #2345
|
||||
.env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves
|
||||
.env_remove("EMAIL")
|
||||
.env_remove("MFLAGS")
|
||||
.env_remove("MAKEFLAGS")
|
||||
.env_remove("CARGO_MAKEFLAGS")
|
||||
.env_remove("GIT_AUTHOR_NAME")
|
||||
.env_remove("GIT_AUTHOR_EMAIL")
|
||||
.env_remove("GIT_COMMITTER_NAME")
|
||||
.env_remove("GIT_COMMITTER_EMAIL")
|
||||
.env_remove("CARGO_TARGET_DIR") // we assume 'target'
|
||||
.env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows
|
||||
return p;
|
||||
}
|
||||
|
||||
pub trait ChannelChanger: Sized {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self;
|
||||
}
|
||||
|
||||
impl ChannelChanger for cargo::util::ProcessBuilder {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self {
|
||||
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cargo_process() -> cargo::util::ProcessBuilder {
|
||||
process(&support::cargo_exe())
|
||||
}
|
||||
|
||||
pub fn sleep_ms(ms: u64) {
|
||||
::std::thread::sleep(Duration::from_millis(ms));
|
||||
}
|
@ -2,10 +2,10 @@ use std::str::FromStr;
|
||||
use std::fmt;
|
||||
|
||||
use cargo::util::{Cfg, CfgExpr};
|
||||
use cargotest::rustc_host;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::rustc_host;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
macro_rules! c {
|
||||
($a:ident) => (
|
||||
|
@ -1,10 +1,10 @@
|
||||
use cargotest::install::exe;
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use support::install::exe;
|
||||
use support::is_nightly;
|
||||
use support::paths::CargoPathExt;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use glob::glob;
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
const SIMPLE_MANIFEST: &str = r#"
|
||||
[package]
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::env;
|
||||
|
||||
use cargotest::support::{basic_bin_manifest, execs, git, main_file, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::{basic_bin_manifest, execs, git, main_file, project};
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn cargo_clean_simple() {
|
||||
|
@ -8,12 +8,12 @@ use std::sync::mpsc::channel;
|
||||
use std::time::Duration;
|
||||
|
||||
use git2;
|
||||
use cargotest;
|
||||
use cargotest::install::{cargo_home, has_installed_exe};
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support;
|
||||
use support::install::{cargo_home, has_installed_exe};
|
||||
use support::git;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
fn pkg(name: &str, vers: &str) {
|
||||
Package::new(name, vers)
|
||||
@ -72,11 +72,11 @@ fn concurrent_installs() {
|
||||
pkg("foo", "0.0.1");
|
||||
pkg("bar", "0.0.1");
|
||||
|
||||
let mut a = cargotest::cargo_process()
|
||||
let mut a = support::cargo_process()
|
||||
.arg("install")
|
||||
.arg("foo")
|
||||
.build_command();
|
||||
let mut b = cargotest::cargo_process()
|
||||
let mut b = support::cargo_process()
|
||||
.arg("install")
|
||||
.arg("bar")
|
||||
.build_command();
|
||||
|
@ -2,8 +2,8 @@ use cargo::core::{Shell, enable_nightly_features};
|
||||
use cargo::util::config::{self, Config};
|
||||
use cargo::util::toml::{self, VecStringOrBool as VSOB};
|
||||
use cargo::CargoError;
|
||||
use cargotest::support::{execs, lines_match, paths, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, lines_match, paths, project};
|
||||
use support::hamcrest::assert_that;
|
||||
use std::collections;
|
||||
use std::fs;
|
||||
|
||||
|
@ -2,9 +2,9 @@ use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use cargo::util::paths as cargopaths;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::{execs, git, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::paths;
|
||||
use support::{execs, git, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn deleting_database_files() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use cargo::util::process;
|
||||
use cargotest::{is_nightly, rustc_host};
|
||||
use cargotest::support::{basic_bin_manifest, cross_compile, execs, project};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::{is_nightly, rustc_host};
|
||||
use support::{basic_bin_manifest, cross_compile, execs, project};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn simple_cross() {
|
||||
|
@ -2,8 +2,8 @@ use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::support::{cross_compile, execs, project, publish};
|
||||
use hamcrest::{assert_that, contains};
|
||||
use support::{cross_compile, execs, project, publish};
|
||||
use support::hamcrest::{assert_that, contains};
|
||||
use flate2::read::GzDecoder;
|
||||
use tar::Archive;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::is_nightly;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn custom_target_minimal() {
|
||||
|
@ -5,7 +5,7 @@ use std::process::{Child, Stdio};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use cargotest::support::project;
|
||||
use support::project;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn enabled() -> bool {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use filetime::FileTime;
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn build_dep_info() {
|
||||
|
@ -4,12 +4,12 @@ use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
use std::str;
|
||||
|
||||
use cargotest::cargo_process;
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::registry::{cksum, Package};
|
||||
use cargotest::support::{execs, project, ProjectBuilder};
|
||||
use hamcrest::assert_that;
|
||||
use support::cargo_process;
|
||||
use support::git;
|
||||
use support::paths;
|
||||
use support::registry::{cksum, Package};
|
||||
use support::{execs, project, ProjectBuilder};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
fn setup() {
|
||||
let root = paths::root();
|
||||
|
@ -1,13 +1,13 @@
|
||||
use cargotest;
|
||||
use support;
|
||||
use std::str;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Read;
|
||||
|
||||
use cargotest::{is_nightly, rustc_host, ChannelChanger};
|
||||
use cargotest::support::{basic_lib_manifest, execs, git, project, path2url};
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::{is_nightly, rustc_host, ChannelChanger};
|
||||
use support::{basic_lib_manifest, execs, git, project, path2url};
|
||||
use support::paths::CargoPathExt;
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use cargo::util::ProcessError;
|
||||
use glob::glob;
|
||||
|
||||
@ -1216,7 +1216,7 @@ fn document_only_lib() {
|
||||
|
||||
#[test]
|
||||
fn plugins_no_use_target() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
return;
|
||||
}
|
||||
let p = project()
|
||||
@ -1591,7 +1591,7 @@ fn doc_workspace_open_binary_and_library() {
|
||||
|
||||
#[test]
|
||||
fn doc_edition() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
// Stable rustdoc won't have the edition option. Remove this once it
|
||||
// is stabilized.
|
||||
return;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::assert_that;
|
||||
use cargotest::support::registry::Package;
|
||||
use support::paths::CargoPathExt;
|
||||
use support::{execs, project};
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::assert_that;
|
||||
use support::registry::Package;
|
||||
|
||||
#[test]
|
||||
fn invalid1() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use cargotest::rustc_host;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{cross_compile, execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::rustc_host;
|
||||
use support::registry::Package;
|
||||
use support::{cross_compile, execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn no_deps() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::{is_nightly, ChannelChanger};
|
||||
use support::git;
|
||||
use support::{execs, project};
|
||||
use support::{is_nightly, ChannelChanger};
|
||||
use git2;
|
||||
use hamcrest::assert_that;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn do_not_fix_broken_builds() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::sleep_ms;
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, path2url, project};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::sleep_ms;
|
||||
use support::paths::CargoPathExt;
|
||||
use support::registry::Package;
|
||||
use support::{execs, path2url, project};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn modifying_and_moving() {
|
||||
|
@ -1,10 +1,10 @@
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, paths, project, ProjectBuilder};
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::registry::Package;
|
||||
use support::{execs, paths, project, ProjectBuilder};
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn adding_and_removing_packages() {
|
||||
|
@ -8,11 +8,11 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::thread;
|
||||
|
||||
use cargo::util::process;
|
||||
use cargotest::sleep_ms;
|
||||
use cargotest::support::paths::{self, CargoPathExt};
|
||||
use cargotest::support::{execs, git, main_file, project, path2url};
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::sleep_ms;
|
||||
use support::paths::{self, CargoPathExt};
|
||||
use support::{execs, git, main_file, project, path2url};
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn cargo_compile_simple_git_dep() {
|
||||
|
@ -1,15 +1,15 @@
|
||||
use cargotest;
|
||||
use support;
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
use std::env;
|
||||
|
||||
use cargo::util::ProcessBuilder;
|
||||
use cargotest::support::{cargo_exe, execs, paths};
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::{cargo_exe, execs, paths};
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use tempfile;
|
||||
|
||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||
let mut p = cargotest::process(&cargo_exe());
|
||||
let mut p = support::process(&cargo_exe());
|
||||
p.arg(s).cwd(&paths::root()).env("HOME", &paths::home());
|
||||
p
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
use cargotest;
|
||||
use support;
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargo::util::ProcessBuilder;
|
||||
use cargotest::install::{cargo_home, has_installed_exe};
|
||||
use cargotest::support::cross_compile;
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::ChannelChanger;
|
||||
use support::install::{cargo_home, has_installed_exe};
|
||||
use support::cross_compile;
|
||||
use support::git;
|
||||
use support::paths;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::ChannelChanger;
|
||||
use git2;
|
||||
use hamcrest::{assert_that, existing_dir, is_not};
|
||||
use support::hamcrest::{assert_that, existing_dir, is_not};
|
||||
|
||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||
let mut p = cargotest::cargo_process();
|
||||
let mut p = support::cargo_process();
|
||||
p.arg(s);
|
||||
p
|
||||
}
|
||||
@ -1050,7 +1050,7 @@ warning: To build the current package use `cargo build`, to install the current
|
||||
|
||||
#[test]
|
||||
fn installs_from_cwd_with_2018_warnings() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
// Stable rust won't have the edition option. Remove this once it
|
||||
// is stabilized.
|
||||
return;
|
||||
@ -1343,7 +1343,7 @@ fn install_target_native() {
|
||||
cargo_process("install")
|
||||
.arg("foo")
|
||||
.arg("--target")
|
||||
.arg(cargotest::rustc_host()),
|
||||
.arg(support::rustc_host()),
|
||||
execs()
|
||||
.with_status(0),
|
||||
);
|
||||
|
@ -2,8 +2,8 @@ use std::net::TcpListener;
|
||||
use std::thread;
|
||||
use std::process::Command;
|
||||
|
||||
use cargotest::support::{cargo_exe, execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{cargo_exe, execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn jobserver_exists() {
|
||||
|
@ -1,10 +1,10 @@
|
||||
use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::support::paths::{self, CargoPathExt};
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::paths::{self, CargoPathExt};
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
fn setup() {
|
||||
let root = paths::root();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, lines_match, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::git;
|
||||
use support::registry::Package;
|
||||
use support::{execs, lines_match, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn oldest_lockfile_still_works() {
|
||||
|
@ -2,13 +2,13 @@ use std::io::prelude::*;
|
||||
use std::fs::{self, File};
|
||||
|
||||
use toml;
|
||||
use cargotest::{cargo_process, ChannelChanger};
|
||||
use cargotest::support::execs;
|
||||
use cargotest::support::registry::registry;
|
||||
use cargotest::install::cargo_home;
|
||||
use support::{cargo_process, ChannelChanger};
|
||||
use support::execs;
|
||||
use support::registry::registry;
|
||||
use support::install::cargo_home;
|
||||
use cargo::util::config::Config;
|
||||
use cargo::core::Shell;
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
const TOKEN: &str = "test-token";
|
||||
const ORIGINAL_TOKEN: &str = "api-token";
|
||||
|
@ -20,8 +20,7 @@ extern crate url;
|
||||
extern crate winapi;
|
||||
|
||||
#[macro_use]
|
||||
mod cargotest;
|
||||
mod hamcrest;
|
||||
mod support;
|
||||
|
||||
mod alt_registry;
|
||||
mod bad_config;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, execs, main_file, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::registry::Package;
|
||||
use support::{basic_bin_manifest, basic_lib_manifest, execs, main_file, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn cargo_metadata_simple() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn net_retry_loads_from_config() {
|
||||
|
@ -2,15 +2,15 @@ use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
use std::env;
|
||||
|
||||
use cargotest;
|
||||
use support;
|
||||
use cargo::util::ProcessBuilder;
|
||||
use cargotest::process;
|
||||
use cargotest::support::{execs, paths};
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::process;
|
||||
use support::{execs, paths};
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use tempfile;
|
||||
|
||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||
let mut p = cargotest::cargo_process();
|
||||
let mut p = support::cargo_process();
|
||||
p.arg(s);
|
||||
p
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ use std::path::Path;
|
||||
use std::fs::{self, File};
|
||||
use std::env;
|
||||
|
||||
use hamcrest::assert_that;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
use cargotest::{process, sleep_ms, ChannelChanger};
|
||||
use cargotest::support::{execs, project};
|
||||
use support::{process, sleep_ms, ChannelChanger};
|
||||
use support::{execs, project};
|
||||
|
||||
#[test]
|
||||
fn binary_with_debug() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::git;
|
||||
use support::paths;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn override_simple() {
|
||||
|
@ -4,11 +4,11 @@ use std::io::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use git2;
|
||||
use cargotest::{cargo_process, process, sleep_ms, ChannelChanger};
|
||||
use cargotest::support::{cargo_exe, execs, git, paths, project, registry, path2url};
|
||||
use cargotest::support::registry::Package;
|
||||
use support::{cargo_process, process, sleep_ms, ChannelChanger};
|
||||
use support::{cargo_exe, execs, git, paths, project, registry, path2url};
|
||||
use support::registry::Package;
|
||||
use flate2::read::GzDecoder;
|
||||
use hamcrest::{assert_that, contains, existing_file};
|
||||
use support::hamcrest::{assert_that, contains, existing_file};
|
||||
use tar::Archive;
|
||||
|
||||
#[test]
|
||||
|
@ -2,11 +2,11 @@ use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use toml;
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::git;
|
||||
use support::paths;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn replace() {
|
||||
|
@ -2,11 +2,11 @@ use std::fs::{self, File};
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargo::util::process;
|
||||
use cargotest::sleep_ms;
|
||||
use cargotest::support::paths::{self, CargoPathExt};
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, main_file, project};
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::sleep_ms;
|
||||
use support::paths::{self, CargoPathExt};
|
||||
use support::registry::Package;
|
||||
use support::{execs, main_file, project};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))] // I have no idea why this is failing spuriously on
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::fs;
|
||||
use std::env;
|
||||
|
||||
use cargotest::{is_nightly, rustc_host};
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{is_nightly, rustc_host};
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn plugin_to_the_max() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::is_nightly;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn probe_cfg_before_crate_type_discovery() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{basic_lib_manifest, execs, paths, project};
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_lib_manifest, execs, paths, project};
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn profile_config_gated() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{basic_lib_manifest, execs, project};
|
||||
use cargotest::ChannelChanger;
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_lib_manifest, execs, project};
|
||||
use support::ChannelChanger;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn profile_override_gated() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::support::{execs, project, Project};
|
||||
use hamcrest::assert_that;
|
||||
use support::is_nightly;
|
||||
use support::{execs, project, Project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
// These tests try to exercise exactly which profiles are selected for every
|
||||
// target.
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::env;
|
||||
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::is_nightly;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn profile_overrides() {
|
||||
|
@ -2,12 +2,12 @@ use std::io::prelude::*;
|
||||
use std::fs::{self, File};
|
||||
use std::io::SeekFrom;
|
||||
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::git::repo;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::{execs, project, publish};
|
||||
use support::ChannelChanger;
|
||||
use support::git::repo;
|
||||
use support::paths;
|
||||
use support::{execs, project, publish};
|
||||
use flate2::read::GzDecoder;
|
||||
use hamcrest::assert_that;
|
||||
use support::hamcrest::assert_that;
|
||||
use tar::Archive;
|
||||
|
||||
#[test]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
static MANIFEST_OUTPUT: &'static str = r#"
|
||||
{
|
||||
|
@ -3,12 +3,12 @@ use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use cargo::util::paths::remove_dir_all;
|
||||
use cargotest::cargo_process;
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths::{self, CargoPathExt};
|
||||
use cargotest::support::registry::{self, Package};
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::cargo_process;
|
||||
use support::git;
|
||||
use support::paths::{self, CargoPathExt};
|
||||
use support::registry::{self, Package};
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
use url::Url;
|
||||
|
||||
fn registry_path() -> PathBuf {
|
||||
@ -762,7 +762,7 @@ fn update_lockfile() {
|
||||
|
||||
#[test]
|
||||
fn update_offline() {
|
||||
use cargotest::ChannelChanger;
|
||||
use support::ChannelChanger;
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
|
@ -1,9 +1,9 @@
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::git;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::ChannelChanger;
|
||||
use support::git;
|
||||
use support::paths;
|
||||
use support::registry::Package;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn gated() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use cargotest::is_nightly;
|
||||
use cargotest::install::{cargo_home, has_installed_exe};
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::is_nightly;
|
||||
use support::install::{cargo_home, has_installed_exe};
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn build_bin_default_features() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
use hamcrest::{assert_that, contains, is_not};
|
||||
use support::hamcrest::{assert_that, contains, is_not};
|
||||
|
||||
use cargo::core::source::{GitReference, SourceId};
|
||||
use cargo::core::dependency::Kind::{self, Development};
|
||||
@ -8,9 +8,9 @@ use cargo::core::{Dependency, PackageId, Registry, Summary, enable_nightly_featu
|
||||
use cargo::util::{CargoResult, Config, ToUrl};
|
||||
use cargo::core::resolver::{self, Method};
|
||||
|
||||
use cargotest::ChannelChanger;
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use support::ChannelChanger;
|
||||
use support::{execs, project};
|
||||
use support::registry::Package;
|
||||
|
||||
fn resolve(
|
||||
pkg: &PackageId,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use cargo::util::paths::dylib_path_envvar;
|
||||
use cargotest::{self, ChannelChanger};
|
||||
use cargotest::support::{execs, project, Project, path2url};
|
||||
use hamcrest::{assert_that, existing_file};
|
||||
use support::{self, ChannelChanger};
|
||||
use support::{execs, project, Project, path2url};
|
||||
use support::hamcrest::{assert_that, existing_file};
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
@ -596,7 +596,7 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option<bool>)
|
||||
|
||||
#[test]
|
||||
fn run_example_autodiscover_2015() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ error: no example target named `a`
|
||||
|
||||
#[test]
|
||||
fn run_example_autodiscover_2015_with_autoexamples_enabled() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@ fn run_example_autodiscover_2015_with_autoexamples_enabled() {
|
||||
|
||||
#[test]
|
||||
fn run_example_autodiscover_2015_with_autoexamples_disabled() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() {
|
||||
|
||||
#[test]
|
||||
fn run_example_autodiscover_2018() {
|
||||
if !cargotest::is_nightly() {
|
||||
if !support::is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, basic_lib_manifest, execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
const CARGO_RUSTC_ERROR: &'static str =
|
||||
"[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::paths::CargoPathExt;
|
||||
use support::hamcrest::assert_that;
|
||||
use std::env;
|
||||
|
||||
#[test]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn rustdoc_simple() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn parses_env() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::io::Write;
|
||||
use std::fs::{self, File};
|
||||
|
||||
use cargotest::rustc_host;
|
||||
use cargotest::support::{execs, paths, project, project_in_home};
|
||||
use hamcrest::assert_that;
|
||||
use support::rustc_host;
|
||||
use support::{execs, paths, project, project_in_home};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn env_rustflags_normal_source() {
|
||||
|
@ -3,11 +3,11 @@ use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use cargo::util::ProcessBuilder;
|
||||
use cargotest;
|
||||
use cargotest::support::execs;
|
||||
use cargotest::support::git::repo;
|
||||
use cargotest::support::paths;
|
||||
use hamcrest::assert_that;
|
||||
use support;
|
||||
use support::execs;
|
||||
use support::git::repo;
|
||||
use support::paths;
|
||||
use support::hamcrest::assert_that;
|
||||
use url::Url;
|
||||
|
||||
fn registry_path() -> PathBuf {
|
||||
@ -43,7 +43,7 @@ fn setup() {
|
||||
}
|
||||
|
||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||
let mut b = cargotest::cargo_process();
|
||||
let mut b = support::cargo_process();
|
||||
b.arg(s);
|
||||
b
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
//! in the output, their arguments are quoted properly
|
||||
//! so that the command can be run in a terminal
|
||||
|
||||
use cargotest::support::{
|
||||
use support::{
|
||||
execs,
|
||||
project,
|
||||
};
|
||||
use hamcrest::assert_that;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn features_are_quoted() {
|
||||
|
@ -4,11 +4,11 @@ use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use git2;
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::git;
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::registry::Package;
|
||||
use support::paths;
|
||||
use support::git;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
use url::Url;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::process::Command;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
|
||||
|
||||
use cargotest::support::{basic_bin_manifest, main_file, project};
|
||||
use support::{basic_bin_manifest, main_file, project};
|
||||
|
||||
pub fn disabled() -> bool {
|
||||
// First, disable if ./configure requested so
|
@ -6,7 +6,7 @@ use cargo::util::ProcessError;
|
||||
use git2;
|
||||
use url::Url;
|
||||
|
||||
use cargotest::support::{project, Project, ProjectBuilder, path2url};
|
||||
use support::{project, Project, ProjectBuilder, path2url};
|
||||
|
||||
#[must_use]
|
||||
pub struct RepoBuilder {
|
@ -1,9 +1,9 @@
|
||||
use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use hamcrest::{existing_file, MatchResult, Matcher};
|
||||
use support::hamcrest::{existing_file, MatchResult, Matcher};
|
||||
|
||||
use cargotest::support::paths;
|
||||
use support::paths;
|
||||
|
||||
pub use self::InstalledExe as has_installed_exe;
|
||||
|
@ -1,3 +1,87 @@
|
||||
/*
|
||||
# Introduction To `support`
|
||||
|
||||
Cargo has a wide variety of integration tests that execute the `cargo` binary
|
||||
and verify its behavior. The `support` module contains many helpers to make
|
||||
this process easy.
|
||||
|
||||
The general form of a test involves creating a "project", running cargo, and
|
||||
checking the result. Projects are created with the `ProjectBuilder` where you
|
||||
specify some files to create. The general form looks like this:
|
||||
|
||||
```
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/main.rs", r#"fn main() { println!("hi!"); }"#)
|
||||
.build();
|
||||
```
|
||||
|
||||
To run cargo, call the `cargo` method and use the `hamcrest` matchers to check
|
||||
the output.
|
||||
|
||||
```
|
||||
assert_that(
|
||||
p.cargo("run --bin foo"),
|
||||
execs()
|
||||
.with_status(0)
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo [..]
|
||||
[FINISHED] [..]
|
||||
[RUNNING] `target[/]debug[/]foo`
|
||||
",
|
||||
)
|
||||
.with_stdout("hi!"),
|
||||
);
|
||||
```
|
||||
|
||||
The project creates a mini sandbox under the "cargo integration test"
|
||||
directory with each test getting a separate directory such as
|
||||
`/path/to/cargo/target/cit/t123/`. Each project appears as a separate
|
||||
directory. There is also an empty `home` directory created that will be used
|
||||
as a home directory instead of your normal home directory.
|
||||
|
||||
See `support::lines_match` for an explanation of the string pattern matching.
|
||||
|
||||
See the `hamcrest` module for other matchers like
|
||||
`is_not(existing_file(path))`. This is not the actual hamcrest library, but
|
||||
instead a lightweight subset of matchers that are used in cargo tests.
|
||||
|
||||
Browse the `pub` functions in the `support` module for a variety of other
|
||||
helpful utilities.
|
||||
|
||||
## Testing Nightly Features
|
||||
|
||||
If you are testing a Cargo feature that only works on "nightly" cargo, then
|
||||
you need to call `masquerade_as_nightly_cargo` on the process builder like
|
||||
this:
|
||||
|
||||
```
|
||||
p.cargo("build").masquerade_as_nightly_cargo()
|
||||
```
|
||||
|
||||
If you are testing a feature that only works on *nightly rustc* (such as
|
||||
benchmarks), then you should exit the test if it is not running with nightly
|
||||
rust, like this:
|
||||
|
||||
```
|
||||
if !is_nightly() {
|
||||
return;
|
||||
}
|
||||
```
|
||||
|
||||
## Platform-specific Notes
|
||||
|
||||
When checking output, be sure to use `[/]` when checking paths to
|
||||
automatically support backslashes on Windows.
|
||||
|
||||
Be careful when executing binaries on Windows. You should not rename, delete,
|
||||
or overwrite a binary immediately after running it. Under some conditions
|
||||
Windows will fail with errors like "directory not empty" or "failed to remove"
|
||||
or "access is denied".
|
||||
|
||||
*/
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt;
|
||||
@ -7,16 +91,17 @@ use std::os;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Output;
|
||||
use std::str;
|
||||
use std::time::Duration;
|
||||
use std::usize;
|
||||
|
||||
use cargo::util::ProcessBuilder;
|
||||
use cargo::util::ProcessError;
|
||||
use hamcrest as ham;
|
||||
use cargo::util::{ProcessBuilder, ProcessError, Rustc};
|
||||
use cargo;
|
||||
use serde_json::{self, Value};
|
||||
use url::Url;
|
||||
use tempfile::TempDir;
|
||||
use url::Url;
|
||||
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use self::hamcrest as ham;
|
||||
use self::paths::CargoPathExt;
|
||||
|
||||
macro_rules! t {
|
||||
($e:expr) => {
|
||||
@ -29,6 +114,7 @@ macro_rules! t {
|
||||
|
||||
pub mod cross_compile;
|
||||
pub mod git;
|
||||
pub mod hamcrest;
|
||||
pub mod paths;
|
||||
pub mod publish;
|
||||
pub mod registry;
|
||||
@ -263,7 +349,7 @@ impl Project {
|
||||
/// execs().with_status(0).with_stdout("bar\n"),
|
||||
/// );
|
||||
pub fn process<T: AsRef<OsStr>>(&self, program: T) -> ProcessBuilder {
|
||||
let mut p = ::cargotest::process(program);
|
||||
let mut p = ::support::process(program);
|
||||
p.cwd(self.root());
|
||||
return p;
|
||||
}
|
||||
@ -1078,9 +1164,9 @@ impl<'a> ham::Matcher<&'a mut ProcessBuilder> for Execs {
|
||||
output: Some(ref out),
|
||||
..
|
||||
}) = err
|
||||
{
|
||||
return self.match_output(out);
|
||||
}
|
||||
{
|
||||
return self.match_output(out);
|
||||
}
|
||||
let mut s = format!("could not exec process {}: {}", process, e);
|
||||
for cause in e.causes() {
|
||||
s.push_str(&format!("\ncaused by: {}", cause));
|
||||
@ -1199,3 +1285,88 @@ fn substitute_macros(input: &str) -> String {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
pub mod install;
|
||||
|
||||
thread_local!(
|
||||
pub static RUSTC: Rustc = Rustc::new(
|
||||
PathBuf::from("rustc"),
|
||||
None,
|
||||
Path::new("should be path to rustup rustc, but we don't care in tests"),
|
||||
None,
|
||||
).unwrap()
|
||||
);
|
||||
|
||||
/// The rustc host such as `x86_64-unknown-linux-gnu`.
|
||||
pub fn rustc_host() -> String {
|
||||
RUSTC.with(|r| r.host.clone())
|
||||
}
|
||||
|
||||
pub fn is_nightly() -> bool {
|
||||
RUSTC.with(|r| r.verbose_version.contains("-nightly") || r.verbose_version.contains("-dev"))
|
||||
}
|
||||
|
||||
pub fn process<T: AsRef<OsStr>>(t: T) -> cargo::util::ProcessBuilder {
|
||||
_process(t.as_ref())
|
||||
}
|
||||
|
||||
fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
|
||||
let mut p = cargo::util::process(t);
|
||||
p.cwd(&paths::root())
|
||||
.env_remove("CARGO_HOME")
|
||||
.env("HOME", paths::home())
|
||||
.env("CARGO_HOME", paths::home().join(".cargo"))
|
||||
.env("__CARGO_TEST_ROOT", paths::root())
|
||||
|
||||
// Force cargo to think it's on the stable channel for all tests, this
|
||||
// should hopefully not surprise us as we add cargo features over time and
|
||||
// cargo rides the trains.
|
||||
.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "stable")
|
||||
|
||||
// For now disable incremental by default as support hasn't ridden to the
|
||||
// stable channel yet. Once incremental support hits the stable compiler we
|
||||
// can switch this to one and then fix the tests.
|
||||
.env("CARGO_INCREMENTAL", "0")
|
||||
|
||||
// This env var can switch the git backend from libgit2 to git2-curl, which
|
||||
// can tweak error messages and cause some tests to fail, so let's forcibly
|
||||
// remove it.
|
||||
.env_remove("CARGO_HTTP_CHECK_REVOKE")
|
||||
|
||||
.env_remove("__CARGO_DEFAULT_LIB_METADATA")
|
||||
.env_remove("RUSTC")
|
||||
.env_remove("RUSTDOC")
|
||||
.env_remove("RUSTC_WRAPPER")
|
||||
.env_remove("RUSTFLAGS")
|
||||
.env_remove("XDG_CONFIG_HOME") // see #2345
|
||||
.env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves
|
||||
.env_remove("EMAIL")
|
||||
.env_remove("MFLAGS")
|
||||
.env_remove("MAKEFLAGS")
|
||||
.env_remove("CARGO_MAKEFLAGS")
|
||||
.env_remove("GIT_AUTHOR_NAME")
|
||||
.env_remove("GIT_AUTHOR_EMAIL")
|
||||
.env_remove("GIT_COMMITTER_NAME")
|
||||
.env_remove("GIT_COMMITTER_EMAIL")
|
||||
.env_remove("CARGO_TARGET_DIR") // we assume 'target'
|
||||
.env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows
|
||||
return p;
|
||||
}
|
||||
|
||||
pub trait ChannelChanger: Sized {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self;
|
||||
}
|
||||
|
||||
impl ChannelChanger for cargo::util::ProcessBuilder {
|
||||
fn masquerade_as_nightly_cargo(&mut self) -> &mut Self {
|
||||
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cargo_process() -> cargo::util::ProcessBuilder {
|
||||
process(&cargo_exe())
|
||||
}
|
||||
|
||||
pub fn sleep_ms(ms: u64) {
|
||||
::std::thread::sleep(Duration::from_millis(ms));
|
||||
}
|
@ -2,8 +2,8 @@ use std::path::PathBuf;
|
||||
use std::io::prelude::*;
|
||||
use std::fs::{self, File};
|
||||
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::git::{repo, Repository};
|
||||
use support::paths;
|
||||
use support::git::{repo, Repository};
|
||||
|
||||
use url::Url;
|
||||
|
@ -11,8 +11,8 @@ use hex;
|
||||
use tar::{Builder, Header};
|
||||
use url::Url;
|
||||
|
||||
use cargotest::support::paths;
|
||||
use cargotest::support::git::repo;
|
||||
use support::paths;
|
||||
use support::git::repo;
|
||||
|
||||
pub fn registry_path() -> PathBuf {
|
||||
paths::root().join("registry")
|
@ -4,11 +4,11 @@ use std::str;
|
||||
|
||||
use cargo;
|
||||
use cargo::util::process;
|
||||
use cargotest::support::paths::CargoPathExt;
|
||||
use cargotest::support::registry::Package;
|
||||
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, cargo_exe, execs, project};
|
||||
use cargotest::{is_nightly, rustc_host, sleep_ms};
|
||||
use hamcrest::{assert_that, existing_file, is_not};
|
||||
use support::paths::CargoPathExt;
|
||||
use support::registry::Package;
|
||||
use support::{basic_bin_manifest, basic_lib_manifest, cargo_exe, execs, project};
|
||||
use support::{is_nightly, rustc_host, sleep_ms};
|
||||
use support::hamcrest::{assert_that, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn cargo_test_simple() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::rustc_host;
|
||||
use cargotest::support::{execs, project, path2url};
|
||||
use hamcrest::assert_that;
|
||||
use support::rustc_host;
|
||||
use support::{execs, project, path2url};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn pathless_tools() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use cargotest::support::{execs, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn minor_update_two_places() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{basic_bin_manifest, execs, main_file, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
fn verify_project_success_output() -> String {
|
||||
r#"{"success":"true"}"#.into()
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargo;
|
||||
use cargotest::support::{execs, project};
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project};
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use cargotest::support::{execs, project, Project};
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::assert_that;
|
||||
use support::{execs, project, Project};
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::assert_that;
|
||||
|
||||
static WARNING1: &'static str = "Hello! I'm a warning. :)";
|
||||
static WARNING2: &'static str = "And one more!";
|
||||
|
@ -2,10 +2,10 @@ use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use cargotest::sleep_ms;
|
||||
use cargotest::support::{basic_lib_manifest, execs, git, project};
|
||||
use cargotest::support::registry::Package;
|
||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
use support::sleep_ms;
|
||||
use support::{basic_lib_manifest, execs, git, project};
|
||||
use support::registry::Package;
|
||||
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||
|
||||
#[test]
|
||||
fn simple_explicit() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user