Fold cargotest into testsuite
authorAlex Crichton <alex@alexcrichton.com>
Thu, 1 Mar 2018 17:45:56 +0000 (09:45 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 1 Mar 2018 17:45:56 +0000 (09:45 -0800)
Now that there's only one crate with integration tests there's no need to have
this be a separate crate, yay!

13 files changed:
Cargo.toml
tests/testsuite/build_lib.rs
tests/testsuite/cargotest/Cargo.toml [deleted file]
tests/testsuite/cargotest/install.rs
tests/testsuite/cargotest/lib.rs [deleted file]
tests/testsuite/cargotest/mod.rs [new file with mode: 0644]
tests/testsuite/cargotest/support/cross_compile.rs
tests/testsuite/cargotest/support/git.rs
tests/testsuite/cargotest/support/mod.rs
tests/testsuite/cargotest/support/publish.rs
tests/testsuite/cargotest/support/registry.rs
tests/testsuite/lib.rs
tests/testsuite/rename_deps.rs

index ec9f99c2c9d048d4c27a9abe1da93b04c30eb3c9..1b71cc79702c601e3f2fa3de51f4f90c90c9789d 100644 (file)
@@ -80,7 +80,6 @@ features = [
 
 [dev-dependencies]
 bufstream = "0.1"
-cargotest = { path = "tests/testsuite/cargotest", version = "0.1" }
 filetime = "0.1"
 hamcrest = "=0.1.1"
 
index 682b7c7e8ea5f334fb175263346f174985d2e716..90a5a5097fca48fe30cd32032b634d60c4a77832 100644 (file)
@@ -1,4 +1,3 @@
-extern crate cargotest;
 extern crate hamcrest;
 
 use cargotest::support::{basic_bin_manifest, execs, project, Project};
diff --git a/tests/testsuite/cargotest/Cargo.toml b/tests/testsuite/cargotest/Cargo.toml
deleted file mode 100644 (file)
index c02c441..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-[package]
-name = "cargotest"
-version = "0.1.0"
-authors = ["Alex Crichton <alex@alexcrichton.com>"]
-
-[lib]
-path = "lib.rs"
-
-[dependencies]
-cargo = { path = "../../.." }
-filetime = "0.1"
-flate2 = "1.0"
-git2 = { version = "0.7", default-features = false }
-hamcrest = "=0.1.1"
-hex = "0.3"
-log = "0.4"
-serde_json = "1.0"
-tar = { version = "0.4", default-features = false }
-url = "1.1"
index e768e040e2bc59a3e634ea939768a485b94c11b4..b9905ea2459682d41e5fb16df2c574793ecbd2bd 100644 (file)
@@ -2,7 +2,8 @@ use std::fmt;
 use std::path::{PathBuf, Path};
 
 use hamcrest::{Matcher, MatchResult, existing_file};
-use support::paths;
+
+use cargotest::support::paths;
 
 pub use self::InstalledExe as has_installed_exe;
 
diff --git a/tests/testsuite/cargotest/lib.rs b/tests/testsuite/cargotest/lib.rs
deleted file mode 100644 (file)
index b29fde3..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#![deny(warnings)]
-
-extern crate cargo;
-extern crate filetime;
-extern crate flate2;
-extern crate git2;
-extern crate hamcrest;
-extern crate hex;
-#[macro_use]
-extern crate serde_json;
-extern crate tar;
-extern crate url;
-
-use std::ffi::OsStr;
-use std::time::Duration;
-
-use cargo::util::Rustc;
-use std::path::PathBuf;
-
-pub mod support;
-pub mod install;
-
-thread_local!(pub static RUSTC: Rustc = Rustc::new(PathBuf::from("rustc"), None).unwrap());
-
-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));
-}
diff --git a/tests/testsuite/cargotest/mod.rs b/tests/testsuite/cargotest/mod.rs
new file mode 100644 (file)
index 0000000..8063126
--- /dev/null
@@ -0,0 +1,89 @@
+use std::ffi::OsStr;
+use std::time::Duration;
+
+use cargo::util::Rustc;
+use cargo;
+use std::path::PathBuf;
+
+#[macro_use]
+pub mod support;
+
+pub mod install;
+
+thread_local!(pub static RUSTC: Rustc = Rustc::new(PathBuf::from("rustc"), None).unwrap());
+
+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));
+}
index fc274cb4280794896aba78739ea40b985c3c00c9..fca094ecf0bcbfb5ae53bfe35dac53ba8a7fd56f 100644 (file)
@@ -3,7 +3,7 @@ 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};
+use cargotest::support::{project, main_file, basic_bin_manifest};
 
 pub fn disabled() -> bool {
     // First, disable if ./configure requested so
index 43a188dddd4762e9d657c467a56e47168fe18636..2bac406e2b7761f013b22838d4c22d23652162a8 100644 (file)
@@ -2,11 +2,11 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 use std::path::{Path, PathBuf};
 
-use url::Url;
+use cargo::util::ProcessError;
 use git2;
+use url::Url;
 
-use cargo::util::ProcessError;
-use support::{ProjectBuilder, Project, project, path2url};
+use cargotest::support::{ProjectBuilder, Project, project, path2url};
 
 #[must_use]
 pub struct RepoBuilder {
index 07e5f6f3ceb72eaec184a7edc3cfe19c0b4eef7d..754d3c96f18ebbf280fb3b0a535f146219418748 100644 (file)
@@ -15,9 +15,8 @@ use hamcrest as ham;
 use cargo::util::ProcessBuilder;
 use cargo::util::{ProcessError};
 
-use support::paths::CargoPathExt;
+use cargotest::support::paths::CargoPathExt;
 
-#[macro_export]
 macro_rules! t {
     ($e:expr) => (match $e {
         Ok(e) => e,
@@ -110,10 +109,6 @@ impl ProjectBuilder {
         self.root.root()
     }
 
-    pub fn build_dir(&self) -> PathBuf {
-        self.root.build_dir()
-    }
-
     pub fn target_debug_dir(&self) -> PathBuf {
         self.root.target_debug_dir()
     }
@@ -218,7 +213,7 @@ impl Project {
     }
 
     pub fn process<T: AsRef<OsStr>>(&self, program: T) -> ProcessBuilder {
-        let mut p = ::process(program);
+        let mut p = ::cargotest::process(program);
         p.cwd(self.root());
         return p
     }
@@ -406,11 +401,6 @@ impl Execs {
         self
     }
 
-    pub fn with_neither_contains<S: ToString>(mut self, expected: S) -> Execs {
-        self.expect_neither_contains.push(expected.to_string());
-        self
-    }
-
     pub fn with_json(mut self, expected: &str) -> Execs {
         self.expect_json = Some(expected.split("\n\n").map(|obj| {
             obj.parse().unwrap()
@@ -803,31 +793,6 @@ pub fn execs() -> Execs {
     }
 }
 
-#[derive(Clone)]
-pub struct ShellWrites {
-    expected: String
-}
-
-impl fmt::Display for ShellWrites {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "`{}` written to the shell", self.expected)
-    }
-}
-
-impl<'a> ham::Matcher<&'a [u8]> for ShellWrites {
-    fn matches(&self, actual: &[u8])
-        -> ham::MatchResult
-    {
-        let actual = String::from_utf8_lossy(actual);
-        let actual = actual.to_string();
-        ham::expect(actual == self.expected, actual)
-    }
-}
-
-pub fn shell_writes<T: fmt::Display>(string: T) -> ShellWrites {
-    ShellWrites { expected: string.to_string() }
-}
-
 pub trait Tap {
     fn tap<F: FnOnce(&mut Self)>(self, callback: F) -> Self;
 }
index 63ab4b1e82bfc0cc20357ab4d32d6c0edc11a1f3..9e0b581f5b880d701a7f01b2a6611e6658f7fbf5 100644 (file)
@@ -2,8 +2,8 @@ use std::path::PathBuf;
 use std::io::prelude::*;
 use std::fs::{self, File};
 
-use support::paths;
-use support::git::{repo, Repository};
+use cargotest::support::paths;
+use cargotest::support::git::{repo, Repository};
 
 use url::Url;
 
index 7283ad78af0cf0f6fefef4c560364de171d8769c..321eb1bf05a45dc3bfe15ece3eb53dec27d61ad4 100644 (file)
@@ -3,6 +3,7 @@ use std::fs::{self, File};
 use std::io::prelude::*;
 use std::path::{PathBuf, Path};
 
+use cargo::util::Sha256;
 use flate2::Compression;
 use flate2::write::GzEncoder;
 use git2;
@@ -10,9 +11,8 @@ use hex;
 use tar::{Builder, Header};
 use url::Url;
 
-use support::paths;
-use support::git::repo;
-use cargo::util::Sha256;
+use cargotest::support::paths;
+use cargotest::support::git::repo;
 
 pub fn registry_path() -> PathBuf { paths::root().join("registry") }
 pub fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() }
index 94f6e3f8c1c613862b96c2c55e06d33c65413702..b804ab0d05f4ee0d928c90b867c5bc66899da7e6 100644 (file)
@@ -1,22 +1,25 @@
-extern crate cargo;
-#[macro_use]
-extern crate cargotest;
-extern crate hamcrest;
-extern crate tempdir;
 extern crate bufstream;
+extern crate cargo;
+extern crate filetime;
+extern crate flate2;
 extern crate git2;
 extern crate glob;
-extern crate flate2;
-extern crate tar;
+extern crate hamcrest;
+extern crate hex;
 extern crate libc;
-#[cfg(windows)]
-extern crate winapi;
 #[macro_use]
 extern crate serde_derive;
+#[macro_use]
 extern crate serde_json;
+extern crate tar;
+extern crate tempdir;
 extern crate toml;
 extern crate url;
+#[cfg(windows)]
+extern crate winapi;
 
+#[macro_use]
+mod cargotest;
 
 mod alt_registry;
 mod bad_config;
index f144acca27a236f4f53dc45168cffba5a99ffb25..cc8a28fa7b57e408a029011bad935c10b4e5917f 100644 (file)
@@ -1,5 +1,3 @@
-extern crate cargo;
-extern crate cargotest;
 extern crate hamcrest;
 
 use cargotest::support::{project, execs};