diff --git a/Cargo.toml b/Cargo.toml index b234f2861a0..918d83dbe25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,6 +103,7 @@ features = [ [dev-dependencies] cargo-test-macro = { path = "crates/cargo-test-macro", version = "0.1.0" } +cargo-test-support = { path = "crates/cargo-test-support", version = "0.1.0" } [[bin]] name = "cargo" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5bb3f65094f..503ef785266 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -43,6 +43,7 @@ jobs: x86_64-msvc: TOOLCHAIN: stable-x86_64-pc-windows-msvc OTHER_TARGET: i686-pc-windows-msvc + - job: rustfmt pool: vmImage: ubuntu-16.04 @@ -54,6 +55,8 @@ jobs: displayName: "Check rustfmt (cargo)" - bash: cd crates/cargo-test-macro && cargo fmt --all -- --check displayName: "Check rustfmt (cargo-test-macro)" + - bash: cd crates/cargo-test-support && cargo fmt --all -- --check + displayName: "Check rustfmt (cargo-test-support)" - bash: cd crates/crates-io && cargo fmt --all -- --check displayName: "Check rustfmt (crates-io)" - bash: cd crates/resolver-tests && cargo fmt --all -- --check @@ -71,6 +74,20 @@ jobs: variables: TOOLCHAIN: stable +- job: build_std + pool: + vmImage: ubuntu-16.04 + steps: + - template: ci/azure-install-rust.yml + - bash: rustup component add rust-src + displayName: "Install rust-src" + - bash: cargo build + - bash: cargo test --test build-std + displayName: "tests" + variables: + TOOLCHAIN: nightly + CARGO_RUN_BUILD_STD_TESTS: 1 + - job: docs pool: vmImage: ubuntu-16.04 @@ -88,4 +105,3 @@ jobs: displayName: "Build mdbook documentation" variables: TOOLCHAIN: stable - diff --git a/ci/azure-test-all.yml b/ci/azure-test-all.yml index ad6c2fed59d..4b4cc9c2134 100644 --- a/ci/azure-test-all.yml +++ b/ci/azure-test-all.yml @@ -16,11 +16,6 @@ steps: - bash: rustup component add clippy || echo "clippy not available" displayName: "Install clippy (maybe)" -# This is needed for standard library tests. -- bash: rustup component add rust-src - condition: and(succeeded(), eq(variables['TOOLCHAIN'], 'nightly')) - displayName: "Install rust-src (maybe)" - # Deny warnings on CI to avoid warnings getting into the codebase, and note the # `force-system-lib-on-osx` which is intended to fix compile issues on OSX where # compiling curl from source on OSX yields linker errors on Azure. @@ -31,3 +26,6 @@ steps: # fix the link errors. - bash: cargo test --features 'deny-warnings curl/force-system-lib-on-osx' displayName: "cargo test" + +- bash: cargo test -p cargo-test-support + displayName: "cargo test -p cargo-test-support" diff --git a/crates/cargo-test-macro/src/lib.rs b/crates/cargo-test-macro/src/lib.rs index 678bb83c0cb..b16915762a4 100644 --- a/crates/cargo-test-macro/src/lib.rs +++ b/crates/cargo-test-macro/src/lib.rs @@ -3,7 +3,7 @@ extern crate proc_macro; use proc_macro::*; #[proc_macro_attribute] -pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn cargo_test(attr: TokenStream, item: TokenStream) -> TokenStream { let span = Span::call_site(); let mut ret = TokenStream::new(); ret.extend(Some(TokenTree::from(Punct::new('#', Spacing::Alone)))); @@ -13,6 +13,8 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream { test.into(), )))); + let build_std = contains_ident(&attr, "build_std"); + for token in item { let group = match token { TokenTree::Group(g) => { @@ -29,25 +31,20 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream { } }; - let mut new_body = vec![ - TokenTree::from(Ident::new("let", span)), - TokenTree::from(Ident::new("_test_guard", span)), - TokenTree::from(Punct::new('=', Spacing::Alone)), - TokenTree::from(Ident::new("crate", span)), - TokenTree::from(Punct::new(':', Spacing::Joint)), - TokenTree::from(Punct::new(':', Spacing::Alone)), - TokenTree::from(Ident::new("support", span)), - TokenTree::from(Punct::new(':', Spacing::Joint)), - TokenTree::from(Punct::new(':', Spacing::Alone)), - TokenTree::from(Ident::new("paths", span)), - TokenTree::from(Punct::new(':', Spacing::Joint)), - TokenTree::from(Punct::new(':', Spacing::Alone)), - TokenTree::from(Ident::new("init_root", span)), - TokenTree::from(Group::new(Delimiter::Parenthesis, TokenStream::new())), - TokenTree::from(Punct::new(';', Spacing::Alone)), - ] - .into_iter() - .collect::(); + let mut new_body = + to_token_stream("let _test_guard = cargo_test_support::paths::init_root();"); + + // If this is a `build_std` test (aka `tests/build-std/*.rs`) then they + // only run on nightly and they only run when specifically instructed to + // on CI. + if build_std { + let ts = to_token_stream("if !cargo_test_support::is_nightly() { return }"); + new_body.extend(ts); + let ts = to_token_stream( + "if std::env::var(\"CARGO_RUN_BUILD_STD_TESTS\").is_err() { return }", + ); + new_body.extend(ts); + } new_body.extend(group.stream()); ret.extend(Some(TokenTree::from(Group::new( group.delimiter(), @@ -57,3 +54,14 @@ pub fn cargo_test(_attr: TokenStream, item: TokenStream) -> TokenStream { return ret; } + +fn contains_ident(t: &TokenStream, ident: &str) -> bool { + t.clone().into_iter().any(|t| match t { + TokenTree::Ident(i) => i.to_string() == ident, + _ => false, + }) +} + +fn to_token_stream(code: &str) -> TokenStream { + code.parse().unwrap() +} diff --git a/crates/cargo-test-support/Cargo.toml b/crates/cargo-test-support/Cargo.toml new file mode 100644 index 00000000000..bf9983dc207 --- /dev/null +++ b/crates/cargo-test-support/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "cargo-test-support" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +doctest = false + +[dependencies] +cargo = { path = "../.." } +cargo-test-macro = { path = "../cargo-test-macro" } +filetime = "0.2" +flate2 = "1.0" +git2 = "0.10" +glob = "0.3" +lazy_static = "1.0" +remove_dir_all = "0.5" +serde_json = "1.0" +tar = "0.4" +url = "2.0" diff --git a/tests/testsuite/support/cross_compile.rs b/crates/cargo-test-support/src/cross_compile.rs similarity index 98% rename from tests/testsuite/support/cross_compile.rs rename to crates/cargo-test-support/src/cross_compile.rs index ac072822dba..ce3d0444251 100644 --- a/tests/testsuite/support/cross_compile.rs +++ b/crates/cargo-test-support/src/cross_compile.rs @@ -1,10 +1,9 @@ +use crate::{basic_bin_manifest, main_file, project}; use std::env; use std::process::Command; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Once; -use crate::support::{basic_bin_manifest, main_file, project}; - pub fn disabled() -> bool { // First, disable if `./configure` requested so. match env::var("CFG_DISABLE_CROSS_TESTS") { diff --git a/tests/testsuite/support/git.rs b/crates/cargo-test-support/src/git.rs similarity index 98% rename from tests/testsuite/support/git.rs rename to crates/cargo-test-support/src/git.rs index 1213594c2cd..d9184061e08 100644 --- a/tests/testsuite/support/git.rs +++ b/crates/cargo-test-support/src/git.rs @@ -38,15 +38,13 @@ use some of the helper functions in this file to interact with the repository. */ +use crate::{path2url, project, Project, ProjectBuilder}; +use git2; use std::fs::{self, File}; use std::io::prelude::*; use std::path::{Path, PathBuf}; - -use git2; use url::Url; -use crate::support::{path2url, project, Project, ProjectBuilder}; - #[must_use] pub struct RepoBuilder { repo: git2::Repository, diff --git a/tests/testsuite/support/install.rs b/crates/cargo-test-support/src/install.rs similarity index 96% rename from tests/testsuite/support/install.rs rename to crates/cargo-test-support/src/install.rs index 8e5bbd073bc..bd228bf345c 100644 --- a/tests/testsuite/support/install.rs +++ b/crates/cargo-test-support/src/install.rs @@ -1,8 +1,7 @@ +use crate::paths; use std::env::consts::EXE_SUFFIX; use std::path::{Path, PathBuf}; -use crate::support::paths; - /// Used by `cargo install` tests to assert an executable binary /// has been installed. Example usage: /// diff --git a/tests/testsuite/support/mod.rs b/crates/cargo-test-support/src/lib.rs similarity index 99% rename from tests/testsuite/support/mod.rs rename to crates/cargo-test-support/src/lib.rs index 063f82fae10..2ceb6bf6526 100644 --- a/tests/testsuite/support/mod.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -125,6 +125,7 @@ use url::Url; use self::paths::CargoPathExt; +#[macro_export] macro_rules! t { ($e:expr) => { match $e { @@ -134,6 +135,8 @@ macro_rules! t { }; } +pub use cargo_test_macro::cargo_test; + pub mod cross_compile; pub mod git; pub mod paths; @@ -409,7 +412,7 @@ impl Project { /// .with_stdout("bar\n") /// .run(); pub fn process>(&self, program: T) -> Execs { - let mut p = crate::support::process(program); + let mut p = process(program); p.cwd(self.root()); execs().with_process_builder(p) } @@ -1425,7 +1428,7 @@ pub fn lines_match(expected: &str, mut actual: &str) -> bool { actual.is_empty() || expected.ends_with("[..]") } -#[cargo_test] +#[test] fn lines_match_works() { assert!(lines_match("a b", "a b")); assert!(lines_match("a[..]b", "a b")); diff --git a/tests/testsuite/support/paths.rs b/crates/cargo-test-support/src/paths.rs similarity index 99% rename from tests/testsuite/support/paths.rs rename to crates/cargo-test-support/src/paths.rs index bf3c763de87..6b3af85c6d1 100644 --- a/tests/testsuite/support/paths.rs +++ b/crates/cargo-test-support/src/paths.rs @@ -1,3 +1,5 @@ +use filetime::{self, FileTime}; +use lazy_static::lazy_static; use std::cell::RefCell; use std::collections::HashMap; use std::env; @@ -7,9 +9,6 @@ use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; -use filetime::{self, FileTime}; -use lazy_static::lazy_static; - static CARGO_INTEGRATION_TEST_DIR: &str = "cit"; lazy_static! { diff --git a/tests/testsuite/support/publish.rs b/crates/cargo-test-support/src/publish.rs similarity index 98% rename from tests/testsuite/support/publish.rs rename to crates/cargo-test-support/src/publish.rs index 545007515db..36afd91a150 100644 --- a/tests/testsuite/support/publish.rs +++ b/crates/cargo-test-support/src/publish.rs @@ -1,12 +1,10 @@ +use crate::registry::{self, alt_api_path}; +use crate::{find_json_mismatch, lines_match}; +use flate2::read::GzDecoder; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{self, prelude::*, SeekFrom}; use std::path::{Path, PathBuf}; - -use crate::support::registry::{self, alt_api_path}; -use crate::support::{find_json_mismatch, lines_match}; - -use flate2::read::GzDecoder; use tar::Archive; fn read_le_u32(mut reader: R) -> io::Result diff --git a/tests/testsuite/support/registry.rs b/crates/cargo-test-support/src/registry.rs similarity index 99% rename from tests/testsuite/support/registry.rs rename to crates/cargo-test-support/src/registry.rs index 709f748ce6a..88b24672f99 100644 --- a/tests/testsuite/support/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -1,18 +1,16 @@ -use std::collections::HashMap; -use std::fs::{self, File}; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; - +use crate::git::repo; +use crate::paths; use cargo::sources::CRATES_IO_INDEX; use cargo::util::Sha256; use flate2::write::GzEncoder; use flate2::Compression; +use std::collections::HashMap; +use std::fs::{self, File}; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; use tar::{Builder, Header}; use url::Url; -use crate::support::git::repo; -use crate::support::paths; - /// Gets the path to the local index pretending to be crates.io. This is a Git repo /// initialized with a `config.json` file pointing to `dl_path` for downloads /// and `api_path` for uploads. diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index fb58363f0d5..a6fced9cc1b 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -7,6 +7,7 @@ use crate::core::{Dependency, PackageId, PackageSet, Resolve, SourceId, Workspac use crate::ops::{self, Packages}; use crate::util::errors::CargoResult; use std::collections::{HashMap, HashSet}; +use std::env; use std::path::PathBuf; /// Parse the `-Zbuild-std` flag. @@ -148,6 +149,10 @@ pub fn generate_std_roots<'a>( } fn detect_sysroot_src_path(ws: &Workspace<'_>) -> CargoResult { + if let Some(s) = env::var_os("__CARGO_TESTS_ONLY_SRC_ROOT") { + return Ok(s.into()); + } + // NOTE: This is temporary until we figure out how to acquire the source. // If we decide to keep the sysroot probe, then BuildConfig will need to // be restructured so that the TargetInfo is created earlier and passed diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs new file mode 100644 index 00000000000..6e2dbc03019 --- /dev/null +++ b/tests/build-std/main.rs @@ -0,0 +1,180 @@ +//! A test suite for `-Zbuild-std` which is much more expensive than the +//! standard test suite. +//! +//! This test suite attempts to perform a full integration test where we +//! actually compile the standard library from source (like the real one) and +//! the various tests associated with that. +//! +//! YOU SHOULD IDEALLY NOT WRITE TESTS HERE. +//! +//! If possible, use `tests/testsuite/standard_lib.rs` instead. That uses a +//! 'mock' sysroot which is much faster to compile. The tests here are +//! extremely intensive and are only intended to run on CI and are theoretically +//! not catching any regressions that `tests/testsuite/standard_lib.rs` isn't +//! already catching. +//! +//! All tests here should use `#[cargo_test(build_std)]` to indicate that +//! boilerplate should be generated to require the nightly toolchain and the +//! `CARGO_RUN_BUILD_STD_TESTS` env var to be set to actually run these tests. +//! Otherwise the tests are skipped. + +use cargo_test_support::*; + +fn enable_build_std(e: &mut Execs, arg: Option<&str>) { + e.env_remove("CARGO_HOME"); + e.env_remove("HOME"); + e.arg("-Zno-index-update"); + + // And finally actually enable `build-std` for now + let arg = match arg { + Some(s) => format!("-Zbuild-std={}", s), + None => "-Zbuild-std".to_string(), + }; + e.arg(arg); + e.masquerade_as_nightly_cargo(); +} + +// Helper methods used in the tests below +trait BuildStd: Sized { + fn build_std(&mut self) -> &mut Self; + fn build_std_arg(&mut self, arg: &str) -> &mut Self; + fn target_host(&mut self) -> &mut Self; +} + +impl BuildStd for Execs { + fn build_std(&mut self) -> &mut Self { + enable_build_std(self, None); + self + } + + fn build_std_arg(&mut self, arg: &str) -> &mut Self { + enable_build_std(self, Some(arg)); + self + } + + fn target_host(&mut self) -> &mut Self { + self.arg("--target").arg(rustc_host()); + self + } +} + +#[cargo_test(build_std)] +fn basic() { + let p = project() + .file( + "src/main.rs", + " + fn main() { + foo::f(); + } + + #[test] + fn smoke_bin_unit() { + foo::f(); + } + ", + ) + .file( + "src/lib.rs", + " + extern crate alloc; + extern crate proc_macro; + + /// ``` + /// foo::f(); + /// ``` + pub fn f() { + } + + #[test] + fn smoke_lib_unit() { + f(); + } + ", + ) + .file( + "tests/smoke.rs", + " + #[test] + fn smoke_integration() { + foo::f(); + } + ", + ) + .build(); + + p.cargo("check").build_std().target_host().run(); + p.cargo("build").build_std().target_host().run(); + p.cargo("run").build_std().target_host().run(); + p.cargo("test").build_std().target_host().run(); +} + +#[cargo_test(build_std)] +fn cross_custom() { + let p = project() + .file("src/lib.rs", "#![no_std] pub fn f() {}") + .file( + "custom-target.json", + r#" + { + "llvm-target": "x86_64-unknown-none-gnu", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "linker-flavor": "ld.lld" + } + "#, + ) + .build(); + + p.cargo("build --target custom-target.json -v") + .build_std_arg("core") + .run(); +} + +#[cargo_test(build_std)] +fn custom_test_framework() { + let p = project() + .file( + "src/lib.rs", + r#" + #![no_std] + #![cfg_attr(test, no_main)] + #![feature(custom_test_frameworks)] + #![test_runner(crate::test_runner)] + + pub fn test_runner(_tests: &[&dyn Fn()]) {} + + #[panic_handler] + fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} + } + "#, + ) + .file( + "target.json", + r#" + { + "llvm-target": "x86_64-unknown-none-gnu", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "executables": true, + "panic-strategy": "abort" + } + "#, + ) + .build(); + + p.cargo("test --target target.json --no-run -v") + .build_std_arg("core") + .run(); +} diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index fd5729e6073..6441ab0a8c4 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -1,7 +1,7 @@ -use crate::support::publish::validate_alt_upload; -use crate::support::registry::{self, Package}; -use crate::support::{basic_manifest, git, paths, project}; use cargo::util::IntoUrl; +use cargo_test_support::publish::validate_alt_upload; +use cargo_test_support::registry::{self, Package}; +use cargo_test_support::{basic_manifest, git, paths, project}; use std::fs::{self, File}; use std::io::Write; diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index cab90956d83..e932b68a353 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn bad1() { diff --git a/tests/testsuite/bad_manifest_path.rs b/tests/testsuite/bad_manifest_path.rs index 83990a5a7be..8e54f5f641b 100644 --- a/tests/testsuite/bad_manifest_path.rs +++ b/tests/testsuite/bad_manifest_path.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, main_file, project}; +use cargo_test_support::{basic_bin_manifest, main_file, project}; fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { let p = project() diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 0e8c78543fd..17574dc91f9 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1,6 +1,6 @@ -use crate::support::is_nightly; -use crate::support::paths::CargoPathExt; -use crate::support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::is_nightly; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; #[cargo_test] fn cargo_bench_simple() { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 016eaac8d5a..7e8708a27ec 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1,15 +1,14 @@ +use cargo::util::paths::dylib_path_envvar; +use cargo_test_support::paths::{root, CargoPathExt}; +use cargo_test_support::registry::Package; +use cargo_test_support::{ + basic_bin_manifest, basic_lib_manifest, basic_manifest, main_file, project, rustc_host, + sleep_ms, symlink_supported, t, Execs, ProjectBuilder, +}; use std::env; use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::paths::{root, CargoPathExt}; -use crate::support::registry::Package; -use crate::support::{ - basic_bin_manifest, basic_lib_manifest, basic_manifest, main_file, project, rustc_host, - sleep_ms, symlink_supported, Execs, ProjectBuilder, -}; -use cargo::util::paths::dylib_path_envvar; - #[cargo_test] fn cargo_compile_simple() { let p = project() @@ -4541,7 +4540,7 @@ Caused by: #[cargo_test] fn tricky_pipelining() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -4571,7 +4570,7 @@ fn tricky_pipelining() { #[cargo_test] fn pipelining_works() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -4606,7 +4605,7 @@ fn pipelining_works() { #[cargo_test] fn pipelining_big_graph() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } diff --git a/tests/testsuite/build_auth.rs b/tests/testsuite/build_auth.rs index 2509f90a32f..d76f93e90b6 100644 --- a/tests/testsuite/build_auth.rs +++ b/tests/testsuite/build_auth.rs @@ -6,8 +6,8 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use std::sync::Arc; use std::thread; -use crate::support::paths; -use crate::support::{basic_manifest, project}; +use cargo_test_support::paths; +use cargo_test_support::{basic_manifest, project}; use git2; // Tests that HTTP auth is offered from `credential.helper`. diff --git a/tests/testsuite/build_lib.rs b/tests/testsuite/build_lib.rs index f93187d535d..2e4d181248d 100644 --- a/tests/testsuite/build_lib.rs +++ b/tests/testsuite/build_lib.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, basic_manifest, project}; +use cargo_test_support::{basic_bin_manifest, basic_manifest, project}; #[cargo_test] fn build_lib_only() { diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index f23078e4ba3..3874986c245 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{basic_bin_manifest, basic_manifest, main_file, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project}; #[cargo_test] fn cargo_build_plan_simple() { diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index c4f39f3ff7a..a3a13caf81c 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -4,11 +4,11 @@ use std::io; use std::io::prelude::*; use std::thread; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{basic_manifest, cross_compile, project}; -use crate::support::{rustc_host, sleep_ms, slow_cpu_multiplier}; use cargo::util::paths::remove_dir_all; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, cross_compile, project}; +use cargo_test_support::{rustc_host, sleep_ms, slow_cpu_multiplier}; #[cargo_test] fn custom_build_script_failed() { @@ -2277,7 +2277,7 @@ fn flags_go_into_tests() { #[cargo_test] fn diamond_passes_args_only_once() { // FIXME: when pipelining rides to stable, enable this test on all channels. - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index 5b2a5795b66..f45a430d6cc 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -1,7 +1,7 @@ use std::fs::File; -use crate::support::project; -use crate::support::sleep_ms; +use cargo_test_support::project; +use cargo_test_support::sleep_ms; #[cargo_test] fn rerun_if_env_changes() { diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs index 2582d191810..7a104e959f3 100644 --- a/tests/testsuite/cache_messages.rs +++ b/tests/testsuite/cache_messages.rs @@ -1,4 +1,4 @@ -use crate::support::{clippy_is_available, is_nightly, process, project, registry::Package}; +use cargo_test_support::{clippy_is_available, is_nightly, process, project, registry::Package}; use std::path::Path; fn as_str(bytes: &[u8]) -> &str { diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index 3d0e14c127c..8ce0f51adfe 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, project}; +use cargo_test_support::{basic_bin_manifest, project}; #[cargo_test] fn alias_incorrect_config_type() { diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index dbc53bf0631..e0f4cda2e6b 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -4,11 +4,11 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::str; -use crate::support::cargo_process; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::Package; -use crate::support::{basic_bin_manifest, basic_manifest, cargo_exe, project, Project}; use cargo; +use cargo_test_support::cargo_process; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_bin_manifest, basic_manifest, cargo_exe, project, Project}; #[cfg_attr(windows, allow(dead_code))] enum FakeKind<'a> { diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index 0dd4af06aa6..45524d1c7e1 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -1,4 +1,4 @@ -use crate::support::{project, registry}; +use cargo_test_support::{project, registry}; #[cargo_test] fn feature_required() { diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index 81eab7e7b6e..abba59e3523 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -1,10 +1,10 @@ use std::fmt; use std::str::FromStr; -use crate::support::registry::Package; -use crate::support::rustc_host; -use crate::support::{basic_manifest, project}; use cargo::util::{Cfg, CfgExpr}; +use cargo_test_support::registry::Package; +use cargo_test_support::rustc_host; +use cargo_test_support::{basic_manifest, project}; macro_rules! c { ($a:ident) => { diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 8fc886a88a4..a4eab3b2229 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1,9 +1,9 @@ use std::fmt::{self, Write}; -use crate::support::install::exe; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::install::exe; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn check_success() { diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index c3ee4c7becc..103b707f1e5 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -1,7 +1,7 @@ use std::env; -use crate::support::registry::Package; -use crate::support::{basic_bin_manifest, basic_manifest, git, main_file, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_bin_manifest, basic_manifest, git, main_file, project}; #[cargo_test] fn cargo_clean_simple() { diff --git a/tests/testsuite/clippy.rs b/tests/testsuite/clippy.rs index 271f6878a02..5e5000ff83f 100644 --- a/tests/testsuite/clippy.rs +++ b/tests/testsuite/clippy.rs @@ -1,4 +1,4 @@ -use crate::support::{clippy_is_available, project, registry::Package}; +use cargo_test_support::{clippy_is_available, project, registry::Package}; #[cargo_test] // Clippy should never be considered fresh. diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index bca9fb3f8c1..f1fb4bacfb6 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, project}; use std::env; #[cargo_test] diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index 9336c51cdfb..43b4363c908 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -6,11 +6,11 @@ use std::sync::mpsc::channel; use std::thread; use std::{env, str}; -use crate::support::cargo_process; -use crate::support::git; -use crate::support::install::{assert_has_installed_exe, cargo_home}; -use crate::support::registry::Package; -use crate::support::{basic_manifest, execs, project, slow_cpu_multiplier}; +use cargo_test_support::cargo_process; +use cargo_test_support::git; +use cargo_test_support::install::{assert_has_installed_exe, cargo_home}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, execs, project, slow_cpu_multiplier}; use git2; fn pkg(name: &str, vers: &str) { diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index bd56e996e0a..d65fe7a9af0 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -5,16 +5,16 @@ use std::io; use std::os; use std::path::Path; -use crate::support::{paths, project}; use cargo::core::{enable_nightly_features, Shell}; use cargo::util::config::{self, Config}; use cargo::util::toml::{self, VecStringOrBool as VSOB}; +use cargo_test_support::{paths, project, t}; use serde::Deserialize; fn lines_match(a: &str, b: &str) -> bool { // Perform a small amount of normalization for filesystem paths before we // send this to the `lines_match` function. - crate::support::lines_match(&a.replace("\\", "/"), &b.replace("\\", "/")) + cargo_test_support::lines_match(&a.replace("\\", "/"), &b.replace("\\", "/")) } #[cargo_test] diff --git a/tests/testsuite/corrupt_git.rs b/tests/testsuite/corrupt_git.rs index 16900e73ec3..39b9e258474 100644 --- a/tests/testsuite/corrupt_git.rs +++ b/tests/testsuite/corrupt_git.rs @@ -1,9 +1,9 @@ use std::fs; use std::path::{Path, PathBuf}; -use crate::support::paths; -use crate::support::{basic_manifest, git, project}; use cargo::util::paths as cargopaths; +use cargo_test_support::paths; +use cargo_test_support::{basic_manifest, git, project}; #[cargo_test] fn deleting_database_files() { diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index cf0be0e2786..671afe7003a 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -1,5 +1,5 @@ -use crate::support::{basic_bin_manifest, basic_manifest, cross_compile, project}; -use crate::support::{is_nightly, rustc_host}; +use cargo_test_support::{basic_bin_manifest, basic_manifest, cross_compile, project}; +use cargo_test_support::{is_nightly, rustc_host}; #[cargo_test] fn simple_cross() { diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index 076a90361b4..95ed071a4e8 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -1,6 +1,6 @@ use std::fs::File; -use crate::support::{cross_compile, project, publish, registry}; +use cargo_test_support::{cross_compile, project, publish, registry}; #[cargo_test] fn simple_cross_package() { diff --git a/tests/testsuite/custom_target.rs b/tests/testsuite/custom_target.rs index adcec16bb13..ca28b28238b 100644 --- a/tests/testsuite/custom_target.rs +++ b/tests/testsuite/custom_target.rs @@ -1,5 +1,5 @@ -use crate::support::is_nightly; -use crate::support::{basic_manifest, project}; +use cargo_test_support::is_nightly; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn custom_target_minimal() { diff --git a/tests/testsuite/death.rs b/tests/testsuite/death.rs index 1c1addb3311..9fae5448084 100644 --- a/tests/testsuite/death.rs +++ b/tests/testsuite/death.rs @@ -4,7 +4,7 @@ use std::net::TcpListener; use std::process::{Child, Stdio}; use std::thread; -use crate::{support::project, support::slow_cpu_multiplier}; +use cargo_test_support::{project, slow_cpu_multiplier}; #[cfg(unix)] fn enabled() -> bool { diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs index 439621e42e9..dc116f848b6 100644 --- a/tests/testsuite/dep_info.rs +++ b/tests/testsuite/dep_info.rs @@ -1,6 +1,6 @@ -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::Package; -use crate::support::{ +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::Package; +use cargo_test_support::{ basic_bin_manifest, basic_manifest, is_nightly, main_file, project, rustc_host, Project, }; use filetime::FileTime; @@ -478,7 +478,7 @@ fn canonical_path() { // See https://github.com/rust-lang/rust/issues/63012 return; } - if !crate::support::symlink_supported() { + if !cargo_test_support::symlink_supported() { return; } Package::new("regdep", "0.1.0") diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index d4e7701497b..a7d60d1a7d2 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -5,11 +5,11 @@ use std::str; use serde::Serialize; -use crate::support::cargo_process; -use crate::support::git; -use crate::support::paths; -use crate::support::registry::{cksum, Package}; -use crate::support::{basic_manifest, project, ProjectBuilder}; +use cargo_test_support::cargo_process; +use cargo_test_support::git; +use cargo_test_support::paths; +use cargo_test_support::registry::{cksum, Package}; +use cargo_test_support::{basic_manifest, project, t, ProjectBuilder}; fn setup() { let root = paths::root(); diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index f2909b1321f..53470eecf4f 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -2,10 +2,10 @@ use std::fs::{self, File}; use std::io::Read; use std::str; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{basic_lib_manifest, basic_manifest, git, project}; -use crate::support::{is_nightly, rustc_host}; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project}; +use cargo_test_support::{is_nightly, rustc_host}; #[cargo_test] fn simple() { diff --git a/tests/testsuite/edition.rs b/tests/testsuite/edition.rs index 5d3f04d9f5a..7007f67a462 100644 --- a/tests/testsuite/edition.rs +++ b/tests/testsuite/edition.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_lib_manifest, project}; +use cargo_test_support::{basic_lib_manifest, project}; #[cargo_test] fn edition_works_for_build_script() { diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index fae985c3a4e..a167b78185e 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -1,9 +1,9 @@ use std::fs::File; use std::io::prelude::*; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project, t}; #[cargo_test] fn invalid1() { diff --git a/tests/testsuite/fetch.rs b/tests/testsuite/fetch.rs index 088f683c1bc..2978962025f 100644 --- a/tests/testsuite/fetch.rs +++ b/tests/testsuite/fetch.rs @@ -1,6 +1,6 @@ -use crate::support::registry::Package; -use crate::support::rustc_host; -use crate::support::{basic_manifest, cross_compile, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::rustc_host; +use cargo_test_support::{basic_manifest, cross_compile, project}; #[cargo_test] fn no_deps() { diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index eaaf4cc2f19..f30dbf28933 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -1,7 +1,7 @@ use std::fs::File; -use crate::support::git; -use crate::support::{basic_manifest, clippy_is_available, is_nightly, project}; +use cargo_test_support::git; +use cargo_test_support::{basic_manifest, clippy_is_available, is_nightly, project}; use std::io::Write; diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 03777719455..1b4527c3905 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -7,10 +7,10 @@ use std::path::{Path, PathBuf}; use std::thread; use std::time::SystemTime; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::Package; -use crate::support::sleep_ms; -use crate::support::{basic_manifest, is_coarse_mtime, project}; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::Package; +use cargo_test_support::sleep_ms; +use cargo_test_support::{basic_manifest, is_coarse_mtime, project}; #[cargo_test] fn modifying_and_moving() { diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index 0df2c091694..23a71408b41 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -1,8 +1,8 @@ use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::registry::Package; -use crate::support::{basic_manifest, paths, project, ProjectBuilder}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, paths, project, ProjectBuilder}; #[cargo_test] fn adding_and_removing_packages() { diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index cdc2dd4ef0a..523fbb79434 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -8,10 +8,9 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::sleep_ms; -use crate::support::Project; -use crate::support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; +use cargo_test_support::{sleep_ms, t, Project}; fn disable_git_cli() -> bool { // mingw git on Windows does not support Windows-style file URIs. diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 84e0b9d3691..e0e6620be60 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -1,13 +1,13 @@ -use crate::support; +use cargo_test_support; use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::process::Command; -use crate::support::{paths, Execs}; +use cargo_test_support::{paths, Execs}; fn cargo_process(s: &str) -> Execs { - let mut execs = support::cargo_process(s); + let mut execs = cargo_test_support::cargo_process(s); execs.cwd(&paths::root()).env("HOME", &paths::home()); execs } diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index ef909f1eb23..2a829bc30b2 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -3,13 +3,14 @@ use std::io::prelude::*; use git2; -use crate::support; -use crate::support::cross_compile; -use crate::support::git; -use crate::support::install::{assert_has_installed_exe, assert_has_not_installed_exe, cargo_home}; -use crate::support::paths; -use crate::support::registry::Package; -use crate::support::{basic_manifest, cargo_process, project}; +use cargo_test_support::cross_compile; +use cargo_test_support::git; +use cargo_test_support::install::{ + assert_has_installed_exe, assert_has_not_installed_exe, cargo_home, +}; +use cargo_test_support::paths; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, cargo_process, project}; fn pkg(name: &str, vers: &str) { Package::new(name, vers) @@ -1057,7 +1058,7 @@ fn install_target_native() { pkg("foo", "0.1.0"); cargo_process("install foo --target") - .arg(support::rustc_host()) + .arg(cargo_test_support::rustc_host()) .run(); assert_has_installed_exe(cargo_home(), "foo"); } diff --git a/tests/testsuite/install_upgrade.rs b/tests/testsuite/install_upgrade.rs index 821bda7c383..256bb164de3 100644 --- a/tests/testsuite/install_upgrade.rs +++ b/tests/testsuite/install_upgrade.rs @@ -5,10 +5,10 @@ use std::fs; use std::path::PathBuf; use std::sync::atomic::{AtomicUsize, Ordering}; -use crate::support::install::{cargo_home, exe}; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{ +use cargo_test_support::install::{cargo_home, exe}; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{ basic_manifest, cargo_process, cross_compile, execs, git, process, project, Execs, }; diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs index 59300b6762c..b0d90cc36f5 100644 --- a/tests/testsuite/jobserver.rs +++ b/tests/testsuite/jobserver.rs @@ -2,7 +2,7 @@ use std::net::TcpListener; use std::process::Command; use std::thread; -use crate::support::{cargo_exe, project}; +use cargo_test_support::{cargo_exe, project}; #[cargo_test] fn jobserver_exists() { diff --git a/tests/testsuite/list_targets.rs b/tests/testsuite/list_targets.rs index 9db79afb525..a370a368292 100644 --- a/tests/testsuite/list_targets.rs +++ b/tests/testsuite/list_targets.rs @@ -1,4 +1,4 @@ -use crate::support::project; +use cargo_test_support::project; const EXAMPLE: u8 = 0x1; const BIN: u8 = 0x2; diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index 7df486dd997..8cffb29568e 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -1,9 +1,9 @@ use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::{registry_path, Package}; -use crate::support::{basic_manifest, project}; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::{registry_path, Package}; +use cargo_test_support::{basic_manifest, project, t}; fn setup() { let root = paths::root(); diff --git a/tests/testsuite/lockfile_compat.rs b/tests/testsuite/lockfile_compat.rs index 85ee88f16c2..abe4e4397f3 100644 --- a/tests/testsuite/lockfile_compat.rs +++ b/tests/testsuite/lockfile_compat.rs @@ -1,6 +1,6 @@ -use crate::support::git; -use crate::support::registry::Package; -use crate::support::{basic_manifest, lines_match, project}; +use cargo_test_support::git; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, lines_match, project}; #[cargo_test] fn oldest_lockfile_still_works() { diff --git a/tests/testsuite/login.rs b/tests/testsuite/login.rs index d203d818fdb..69822207ada 100644 --- a/tests/testsuite/login.rs +++ b/tests/testsuite/login.rs @@ -2,11 +2,11 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::path::PathBuf; -use crate::support::cargo_process; -use crate::support::install::cargo_home; -use crate::support::registry::{self, registry_url}; use cargo::core::Shell; use cargo::util::config::Config; +use cargo_test_support::install::cargo_home; +use cargo_test_support::registry::{self, registry_url}; +use cargo_test_support::{cargo_process, t}; use toml; const TOKEN: &str = "test-token"; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 60002361b49..237a58ac7d6 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -9,9 +9,6 @@ #[macro_use] extern crate cargo_test_macro; -#[macro_use] -mod support; - mod alt_registry; mod bad_config; mod bad_manifest_path; @@ -104,5 +101,5 @@ mod workspaces; #[cargo_test] fn aaa_trigger_cross_compile_disabled_check() { // This triggers the cross compile disabled check to run ASAP, see #5141 - support::cross_compile::disabled(); + cargo_test_support::cross_compile::disabled(); } diff --git a/tests/testsuite/member_errors.rs b/tests/testsuite/member_errors.rs index a4d17d8f1c7..09e7a7961b5 100644 --- a/tests/testsuite/member_errors.rs +++ b/tests/testsuite/member_errors.rs @@ -3,9 +3,9 @@ use cargo::core::{compiler::CompileMode, Shell, Workspace}; use cargo::ops::{self, CompileOptions}; use cargo::util::{config::Config, errors::ManifestError}; -use crate::support::install::cargo_home; -use crate::support::project; -use crate::support::registry; +use cargo_test_support::install::cargo_home; +use cargo_test_support::project; +use cargo_test_support::registry; /// Tests inclusion of a `ManifestError` pointing to a member manifest /// when that manifest fails to deserialize. diff --git a/tests/testsuite/message_format.rs b/tests/testsuite/message_format.rs index 06969e7a631..361c03fc7db 100644 --- a/tests/testsuite/message_format.rs +++ b/tests/testsuite/message_format.rs @@ -1,8 +1,8 @@ -use crate::support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn cannot_specify_two() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -26,7 +26,7 @@ fn cannot_specify_two() { #[cargo_test] fn double_json_works() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -51,7 +51,7 @@ fn double_json_works() { #[cargo_test] fn cargo_renders() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -87,7 +87,7 @@ error[..]`main`[..] #[cargo_test] fn cargo_renders_short() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } @@ -110,7 +110,7 @@ error[..]`main`[..] #[cargo_test] fn cargo_renders_ansi() { - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } diff --git a/tests/testsuite/metabuild.rs b/tests/testsuite/metabuild.rs index 2f6486beee6..60b3f6ae2b3 100644 --- a/tests/testsuite/metabuild.rs +++ b/tests/testsuite/metabuild.rs @@ -1,4 +1,4 @@ -use crate::support::{ +use cargo_test_support::{ basic_lib_manifest, basic_manifest, is_coarse_mtime, project, registry::Package, rustc_host, Project, }; diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 713c9d4a83a..ef37256a0ea 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{basic_bin_manifest, basic_lib_manifest, main_file, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, main_file, project}; #[cargo_test] fn cargo_metadata_simple() { diff --git a/tests/testsuite/mock-std/Cargo.toml b/tests/testsuite/mock-std/Cargo.toml new file mode 100644 index 00000000000..a2fdae3b7f0 --- /dev/null +++ b/tests/testsuite/mock-std/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] +members = [ + "src/libtest", +] + +[patch.crates-io] +rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' } +rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' } +rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' } diff --git a/tests/testsuite/mock-std/src/liballoc/Cargo.toml b/tests/testsuite/mock-std/src/liballoc/Cargo.toml new file mode 100644 index 00000000000..128600df51a --- /dev/null +++ b/tests/testsuite/mock-std/src/liballoc/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "alloc" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +core = { path = "../libcore" } diff --git a/tests/testsuite/mock-std/src/liballoc/lib.rs b/tests/testsuite/mock-std/src/liballoc/lib.rs new file mode 100644 index 00000000000..e29525b6a50 --- /dev/null +++ b/tests/testsuite/mock-std/src/liballoc/lib.rs @@ -0,0 +1 @@ +pub fn custom_api() {} diff --git a/tests/testsuite/mock-std/src/libcompiler_builtins/Cargo.toml b/tests/testsuite/mock-std/src/libcompiler_builtins/Cargo.toml new file mode 100644 index 00000000000..27141f23250 --- /dev/null +++ b/tests/testsuite/mock-std/src/libcompiler_builtins/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "compiler_builtins" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +core = { path = "../libcore" } diff --git a/tests/testsuite/mock-std/src/libcompiler_builtins/lib.rs b/tests/testsuite/mock-std/src/libcompiler_builtins/lib.rs new file mode 100644 index 00000000000..65e2cc34045 --- /dev/null +++ b/tests/testsuite/mock-std/src/libcompiler_builtins/lib.rs @@ -0,0 +1 @@ +// intentionally blank diff --git a/tests/testsuite/mock-std/src/libcore/Cargo.toml b/tests/testsuite/mock-std/src/libcore/Cargo.toml new file mode 100644 index 00000000000..b448bdb085d --- /dev/null +++ b/tests/testsuite/mock-std/src/libcore/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "core" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/tests/testsuite/mock-std/src/libcore/build.rs b/tests/testsuite/mock-std/src/libcore/build.rs new file mode 100644 index 00000000000..53d4e145d35 --- /dev/null +++ b/tests/testsuite/mock-std/src/libcore/build.rs @@ -0,0 +1,23 @@ +//! This build script is basically the whole hack that makes this entire "mock +//! std" feature work. Here we print out `rustc-link-search` pointing to the +//! sysroot of the actual compiler itself, and that way we can indeed implicitly +//! pull in those crates, but only via `extern crate`. That means that we can +//! build tiny shim core/std/etc crates while they actually load all the various +//! language/library details from the actual crates, meaning that instead of +//! literally compiling libstd we compile just our own tiny shims. + +use std::process::Command; +use std::env; + +fn main() { + let output = Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output() + .unwrap(); + assert!(output.status.success()); + let stdout = String::from_utf8(output.stdout).unwrap(); + let stdout = stdout.trim(); + let host = env::var("HOST").unwrap(); + println!("cargo:rustc-link-search={}/lib/rustlib/{}/lib", stdout, host); +} diff --git a/tests/testsuite/mock-std/src/libcore/lib.rs b/tests/testsuite/mock-std/src/libcore/lib.rs new file mode 100644 index 00000000000..73e79b9a905 --- /dev/null +++ b/tests/testsuite/mock-std/src/libcore/lib.rs @@ -0,0 +1,4 @@ +#![no_std] +pub use core::*; + +pub fn custom_api() {} diff --git a/tests/testsuite/mock-std/src/libpanic_unwind/Cargo.toml b/tests/testsuite/mock-std/src/libpanic_unwind/Cargo.toml new file mode 100644 index 00000000000..af06d7736e1 --- /dev/null +++ b/tests/testsuite/mock-std/src/libpanic_unwind/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "panic_unwind" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +core = { path = "../libcore" } diff --git a/tests/testsuite/mock-std/src/libpanic_unwind/lib.rs b/tests/testsuite/mock-std/src/libpanic_unwind/lib.rs new file mode 100644 index 00000000000..6af65d87507 --- /dev/null +++ b/tests/testsuite/mock-std/src/libpanic_unwind/lib.rs @@ -0,0 +1,5 @@ +#![feature(panic_unwind, panic_runtime)] +#![panic_runtime] +#![no_std] + +extern crate panic_unwind; diff --git a/tests/testsuite/mock-std/src/libproc_macro/Cargo.toml b/tests/testsuite/mock-std/src/libproc_macro/Cargo.toml new file mode 100644 index 00000000000..bc93bfcc785 --- /dev/null +++ b/tests/testsuite/mock-std/src/libproc_macro/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "proc_macro" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +std = { path = "../libstd" } diff --git a/tests/testsuite/mock-std/src/libproc_macro/lib.rs b/tests/testsuite/mock-std/src/libproc_macro/lib.rs new file mode 100644 index 00000000000..73825ac07c2 --- /dev/null +++ b/tests/testsuite/mock-std/src/libproc_macro/lib.rs @@ -0,0 +1,3 @@ +extern crate proc_macro; +pub use proc_macro::*; +pub fn custom_api() {} diff --git a/tests/testsuite/mock-std/src/libstd/Cargo.toml b/tests/testsuite/mock-std/src/libstd/Cargo.toml new file mode 100644 index 00000000000..9338f036826 --- /dev/null +++ b/tests/testsuite/mock-std/src/libstd/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "std" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +core = { path = "../libcore" } +compiler_builtins = { path = "../libcompiler_builtins" } +panic_unwind = { path = "../libpanic_unwind" } +registry-dep-using-core = { version = "1.0", features = ['mockbuild'] } +registry-dep-using-alloc = { version = "1.0", features = ['mockbuild'] } diff --git a/tests/testsuite/mock-std/src/libstd/lib.rs b/tests/testsuite/mock-std/src/libstd/lib.rs new file mode 100644 index 00000000000..e7e64f1f643 --- /dev/null +++ b/tests/testsuite/mock-std/src/libstd/lib.rs @@ -0,0 +1,6 @@ +pub use std::*; + +pub fn custom_api() { + registry_dep_using_core::custom_api(); + registry_dep_using_alloc::custom_api(); +} diff --git a/tests/testsuite/mock-std/src/libtest/Cargo.toml b/tests/testsuite/mock-std/src/libtest/Cargo.toml new file mode 100644 index 00000000000..a81a2dd6a2a --- /dev/null +++ b/tests/testsuite/mock-std/src/libtest/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "test" +version = "0.1.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +proc_macro = { path = "../libproc_macro" } +registry-dep-using-std = { version = "1.0", features = ['mockbuild'] } +std = { path = "../libstd" } + +[features] +panic-unwind = [] +backtrace = [] diff --git a/tests/testsuite/mock-std/src/libtest/lib.rs b/tests/testsuite/mock-std/src/libtest/lib.rs new file mode 100644 index 00000000000..34c0e532ba6 --- /dev/null +++ b/tests/testsuite/mock-std/src/libtest/lib.rs @@ -0,0 +1,9 @@ +#![feature(test)] + +extern crate test; + +pub use test::*; + +pub fn custom_api() { + registry_dep_using_std::custom_api(); +} diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/Cargo.toml b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/Cargo.toml new file mode 100644 index 00000000000..54d9ff4fd59 --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "rustc-std-workspace-alloc" +version = "1.9.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +name = "alloc" +path = "lib.rs" + +[dependencies] +alloc = { path = "../../liballoc" } diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/lib.rs b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/lib.rs new file mode 100644 index 00000000000..2bbfa1a49a7 --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-alloc/lib.rs @@ -0,0 +1,3 @@ +#![no_std] + +pub use alloc::*; diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/Cargo.toml b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/Cargo.toml new file mode 100644 index 00000000000..d62698f62f3 --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "rustc-std-workspace-core" +version = "1.9.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +name = "core" +path = "lib.rs" + +[dependencies] +core = { path = "../../libcore" } diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/lib.rs b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/lib.rs new file mode 100644 index 00000000000..816251790a9 --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-core/lib.rs @@ -0,0 +1,3 @@ +#![no_std] + +pub use core::*; diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/Cargo.toml b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/Cargo.toml new file mode 100644 index 00000000000..0a4bd3a7e46 --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "rustc-std-workspace-std" +version = "1.9.0" +authors = ["Alex Crichton "] +edition = "2018" + +[lib] +name = "std" +path = "lib.rs" + +[dependencies] +std = { path = "../../libstd" } diff --git a/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/lib.rs b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/lib.rs new file mode 100644 index 00000000000..f40d09cafbb --- /dev/null +++ b/tests/testsuite/mock-std/src/tools/rustc-std-workspace-std/lib.rs @@ -0,0 +1 @@ +pub use std::*; diff --git a/tests/testsuite/net_config.rs b/tests/testsuite/net_config.rs index 7d8456ca776..e62e0bd577a 100644 --- a/tests/testsuite/net_config.rs +++ b/tests/testsuite/net_config.rs @@ -1,4 +1,4 @@ -use crate::support::project; +use cargo_test_support::project; #[cargo_test] fn net_retry_loads_from_config() { diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index ee6408026e4..08894c93951 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -2,8 +2,8 @@ use std::env; use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::paths; -use crate::support::{cargo_process, git_process}; +use cargo_test_support::paths; +use cargo_test_support::{cargo_process, git_process}; fn create_empty_gitconfig() { // This helps on Windows where libgit2 is very aggressive in attempting to diff --git a/tests/testsuite/offline.rs b/tests/testsuite/offline.rs index c8736232da2..0ca57953390 100644 --- a/tests/testsuite/offline.rs +++ b/tests/testsuite/offline.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_manifest, git, main_file, path2url, project, registry::Package}; +use cargo_test_support::{basic_manifest, git, main_file, path2url, project, registry::Package}; use std::fs; #[cargo_test] diff --git a/tests/testsuite/out_dir.rs b/tests/testsuite/out_dir.rs index e57d98b9d69..24aa304b08a 100644 --- a/tests/testsuite/out_dir.rs +++ b/tests/testsuite/out_dir.rs @@ -2,8 +2,8 @@ use std::env; use std::fs::{self, File}; use std::path::Path; -use crate::support::sleep_ms; -use crate::support::{basic_manifest, project}; +use cargo_test_support::sleep_ms; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn binary_with_debug() { diff --git a/tests/testsuite/overrides.rs b/tests/testsuite/overrides.rs index 1a9dd1c592f..341dba6f4b6 100644 --- a/tests/testsuite/overrides.rs +++ b/tests/testsuite/overrides.rs @@ -1,7 +1,7 @@ -use crate::support::git; -use crate::support::paths; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::git; +use cargo_test_support::paths; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn override_simple() { diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 9aa6ddc15e2..feb272f78da 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -3,11 +3,11 @@ use std::fs::File; use std::io::prelude::*; use std::path::Path; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{ +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{ basic_manifest, cargo_process, git, path2url, paths, project, publish::validate_crate_contents, - registry, symlink_supported, + registry, symlink_supported, t, }; use git2; diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index 8c1459c916c..e2357ffceac 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -1,10 +1,10 @@ use std::fs::{self, File}; use std::io::{Read, Write}; -use crate::support::git; -use crate::support::paths; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::git; +use cargo_test_support::paths; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project, t}; use toml; #[cargo_test] @@ -1187,7 +1187,7 @@ fn patch_same_version() { .file("src/lib.rs", "") .build(); - crate::support::registry::init(); + cargo_test_support::registry::init(); let p = project() .file( @@ -1236,7 +1236,7 @@ fn two_semver_compatible() { .file("src/lib.rs", "") .build(); - crate::support::registry::init(); + cargo_test_support::registry::init(); let p = project() .file( @@ -1291,7 +1291,7 @@ fn multipatch_select_big() { .file("src/lib.rs", "") .build(); - crate::support::registry::init(); + cargo_test_support::registry::init(); let p = project() .file( diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 226668ceb63..362531ee592 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -1,10 +1,10 @@ use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::Package; -use crate::support::sleep_ms; -use crate::support::{basic_lib_manifest, basic_manifest, main_file, project}; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_lib_manifest, basic_manifest, main_file, project}; +use cargo_test_support::{sleep_ms, t}; #[cargo_test] // I have no idea why this is failing spuriously on Windows; diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 1eda532b419..54701393496 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -1,5 +1,5 @@ -use crate::support::{basic_manifest, project}; -use crate::support::{is_nightly, rustc_host}; +use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{is_nightly, rustc_host}; #[cargo_test] fn plugin_to_the_max() { diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index 8e9ee23edcd..d3774bf09c6 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -1,5 +1,5 @@ -use crate::support::is_nightly; -use crate::support::project; +use cargo_test_support::is_nightly; +use cargo_test_support::project; #[cargo_test] fn probe_cfg_before_crate_type_discovery() { diff --git a/tests/testsuite/profile_config.rs b/tests/testsuite/profile_config.rs index 6513177737b..87b571a62bd 100644 --- a/tests/testsuite/profile_config.rs +++ b/tests/testsuite/profile_config.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_lib_manifest, is_nightly, paths, project}; +use cargo_test_support::{basic_lib_manifest, is_nightly, paths, project}; #[cargo_test] fn profile_config_gated() { diff --git a/tests/testsuite/profile_overrides.rs b/tests/testsuite/profile_overrides.rs index 17b3c25c18b..a3f867a64da 100644 --- a/tests/testsuite/profile_overrides.rs +++ b/tests/testsuite/profile_overrides.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_lib_manifest, basic_manifest, project}; #[cargo_test] fn profile_override_gated() { diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 718ec2fb211..0532656a35c 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_manifest, project, Project}; +use cargo_test_support::{basic_manifest, project, Project}; // These tests try to exercise exactly which profiles are selected for every target. diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index ad7c5c63b2c..4fbbefa120c 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -1,6 +1,6 @@ use std::env; -use crate::support::project; +use cargo_test_support::project; #[cargo_test] fn profile_overrides() { diff --git a/tests/testsuite/pub_priv.rs b/tests/testsuite/pub_priv.rs index 4a9f53ef2c9..d17e2365294 100644 --- a/tests/testsuite/pub_priv.rs +++ b/tests/testsuite/pub_priv.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{is_nightly, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{is_nightly, project}; #[cargo_test] fn exported_priv_warning() { diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index bb9c1edb752..e282796662b 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -1,10 +1,10 @@ use std::fs::{self, File}; use std::io::prelude::*; -use crate::support::git::{self, repo}; -use crate::support::paths; -use crate::support::registry::{self, registry_path, registry_url, Package}; -use crate::support::{basic_manifest, project, publish}; +use cargo_test_support::git::{self, repo}; +use cargo_test_support::paths; +use cargo_test_support::registry::{self, registry_path, registry_url, Package}; +use cargo_test_support::{basic_manifest, project, publish}; const CLEAN_FOO_JSON: &str = r#" { diff --git a/tests/testsuite/publish_lockfile.rs b/tests/testsuite/publish_lockfile.rs index 201e7959cb8..3daef142b27 100644 --- a/tests/testsuite/publish_lockfile.rs +++ b/tests/testsuite/publish_lockfile.rs @@ -1,8 +1,8 @@ use std; use std::fs::File; -use crate::support::registry::Package; -use crate::support::{ +use cargo_test_support::registry::Package; +use cargo_test_support::{ basic_manifest, cargo_process, git, paths, project, publish::validate_crate_contents, }; diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index b72060f3faf..33f86c6eee8 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, main_file, project}; +use cargo_test_support::{basic_bin_manifest, main_file, project}; static MANIFEST_OUTPUT: &str = r#" { diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 2db759ac1e2..b4de94e21e3 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -2,12 +2,12 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::path::Path; -use crate::support::cargo_process; -use crate::support::git; -use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::{self, registry_path, registry_url, Dependency, Package}; -use crate::support::{basic_manifest, project}; use cargo::util::paths::remove_dir_all; +use cargo_test_support::cargo_process; +use cargo_test_support::git; +use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::registry::{self, registry_path, registry_url, Dependency, Package}; +use cargo_test_support::{basic_manifest, project, t}; #[cargo_test] fn simple() { diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index e94ac67eec7..ade3867d36c 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -1,7 +1,7 @@ -use crate::support::git; -use crate::support::paths; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::git; +use cargo_test_support::paths; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn rename_dependency() { diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 1e82b0fda71..fd3d72c676c 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -1,6 +1,8 @@ -use crate::support::install::{assert_has_installed_exe, assert_has_not_installed_exe, cargo_home}; -use crate::support::is_nightly; -use crate::support::project; +use cargo_test_support::install::{ + assert_has_installed_exe, assert_has_not_installed_exe, cargo_home, +}; +use cargo_test_support::is_nightly; +use cargo_test_support::project; #[cargo_test] fn build_bin_default_features() { diff --git a/tests/testsuite/resolve.rs b/tests/testsuite/resolve.rs index ae428d9a99f..f20008ecf0a 100644 --- a/tests/testsuite/resolve.rs +++ b/tests/testsuite/resolve.rs @@ -1,5 +1,5 @@ -use crate::support::project; -use crate::support::registry::Package; +use cargo_test_support::project; +use cargo_test_support::registry::Package; // Ensure that the "-Z minimal-versions" CLI option works and the minimal // version of a dependency ends up in the lock file. diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 04afa8fc244..959873edf66 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -1,5 +1,5 @@ -use crate::support::{basic_bin_manifest, basic_lib_manifest, project, Project}; use cargo::util::paths::dylib_path_envvar; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, Project}; #[cargo_test] fn simple() { @@ -1071,7 +1071,7 @@ fn default_run_workspace() { #[cargo_test] #[cfg(target_os = "macos")] fn run_link_system_path_macos() { - use crate::support::paths::{self, CargoPathExt}; + use cargo_test_support::paths::{self, CargoPathExt}; use std::fs; // Check that the default system library path is honored. // First, build a shared library that will be accessed from diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 9fb3ad240cc..4af6dfe675b 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; const CARGO_RUSTC_ERROR: &str = "[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering diff --git a/tests/testsuite/rustc_info_cache.rs b/tests/testsuite/rustc_info_cache.rs index ceed53ee3a8..39a6d769328 100644 --- a/tests/testsuite/rustc_info_cache.rs +++ b/tests/testsuite/rustc_info_cache.rs @@ -1,11 +1,11 @@ -use crate::support::paths::CargoPathExt; -use crate::support::{basic_manifest, project}; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::{basic_manifest, project}; use std::env; #[cargo_test] fn rustc_info_cache() { // FIXME: when pipelining rides to stable, enable this test on all channels. - if !crate::support::is_nightly() { + if !cargo_test_support::is_nightly() { return; } diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 50e613eeb0b..fd8ba61476d 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_manifest, is_nightly, project}; +use cargo_test_support::{basic_manifest, is_nightly, project}; #[cargo_test] fn rustdoc_simple() { diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index cc8a8730af9..7cfb220c851 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -1,4 +1,4 @@ -use crate::support::project; +use cargo_test_support::project; #[cargo_test] fn parses_env() { diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 0589b49accc..47221bd2a1c 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -1,8 +1,8 @@ use std::fs::{self, File}; use std::io::Write; -use crate::support::registry::Package; -use crate::support::{ +use cargo_test_support::registry::Package; +use cargo_test_support::{ basic_lib_manifest, basic_manifest, paths, project, project_in_home, rustc_host, }; diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs index 8cd0d7a107d..cc464cc7b18 100644 --- a/tests/testsuite/search.rs +++ b/tests/testsuite/search.rs @@ -3,10 +3,10 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::path::Path; -use crate::support::cargo_process; -use crate::support::git::repo; -use crate::support::paths; -use crate::support::registry::{api_path, registry_path, registry_url}; +use cargo_test_support::cargo_process; +use cargo_test_support::git::repo; +use cargo_test_support::paths; +use cargo_test_support::registry::{api_path, registry_path, registry_url}; use url::Url; fn api() -> Url { diff --git a/tests/testsuite/shell_quoting.rs b/tests/testsuite/shell_quoting.rs index 410f95b365c..50d58d559ff 100644 --- a/tests/testsuite/shell_quoting.rs +++ b/tests/testsuite/shell_quoting.rs @@ -2,7 +2,7 @@ //! in the output, their arguments are quoted properly //! so that the command can be run in a terminal -use crate::support::project; +use cargo_test_support::project; #[cargo_test] fn features_are_quoted() { diff --git a/tests/testsuite/small_fd_limits.rs b/tests/testsuite/small_fd_limits.rs index f0ca6988e32..2a468e588b8 100644 --- a/tests/testsuite/small_fd_limits.rs +++ b/tests/testsuite/small_fd_limits.rs @@ -3,10 +3,10 @@ use std::ffi::OsStr; use std::path::PathBuf; use std::process::Command; -use crate::support::git; -use crate::support::paths; -use crate::support::project; -use crate::support::registry::Package; +use cargo_test_support::git; +use cargo_test_support::paths; +use cargo_test_support::project; +use cargo_test_support::registry::Package; use git2; use url::Url; diff --git a/tests/testsuite/standard_lib.rs b/tests/testsuite/standard_lib.rs index 0ca7856d979..80db0fcee20 100644 --- a/tests/testsuite/standard_lib.rs +++ b/tests/testsuite/standard_lib.rs @@ -1,283 +1,395 @@ -use crate::support::{is_nightly, paths, project, rustc_host, Execs, Project}; +use cargo_test_support::registry::{Dependency, Package}; +use cargo_test_support::{is_nightly, paths, project, rustc_host, Execs}; -fn cargo_build_std(project: &Project, cmd: &str, crates: &str) -> Execs { - let unstable = if crates.is_empty() { - "-Zbuild-std".to_string() - } else { - format!("-Zbuild-std={}", crates) +fn setup() -> bool { + if !is_nightly() { + // -Zbuild-std is nightly + // We don't want these tests to run on rust-lang/rust. + return false; + } + + // Our mock sysroot requires a few packages from crates.io, so make sure + // they're "published" to crates.io. Also edit their code a bit to make sure + // that they have access to our custom crates with custom apis. + Package::new("registry-dep-using-core", "1.0.0") + .file( + "src/lib.rs", + " + #![no_std] + + #[cfg(feature = \"mockbuild\")] + pub fn custom_api() { + core::custom_api(); + } + + #[cfg(not(feature = \"mockbuild\"))] + pub fn non_sysroot_api() { + core::custom_api(); + } + ", + ) + .add_dep(Dependency::new("rustc-std-workspace-core", "*").optional(true)) + .feature("mockbuild", &["rustc-std-workspace-core"]) + .publish(); + Package::new("registry-dep-using-alloc", "1.0.0") + .file( + "src/lib.rs", + " + #![no_std] + + extern crate alloc; + + #[cfg(feature = \"mockbuild\")] + pub fn custom_api() { + core::custom_api(); + alloc::custom_api(); + } + + #[cfg(not(feature = \"mockbuild\"))] + pub fn non_sysroot_api() { + core::custom_api(); + alloc::custom_api(); + } + ", + ) + .add_dep(Dependency::new("rustc-std-workspace-core", "*").optional(true)) + .add_dep(Dependency::new("rustc-std-workspace-alloc", "*").optional(true)) + .feature( + "mockbuild", + &["rustc-std-workspace-core", "rustc-std-workspace-alloc"], + ) + .publish(); + Package::new("registry-dep-using-std", "1.0.0") + .file( + "src/lib.rs", + " + #[cfg(feature = \"mockbuild\")] + pub fn custom_api() { + std::custom_api(); + } + + #[cfg(not(feature = \"mockbuild\"))] + pub fn non_sysroot_api() { + std::custom_api(); + } + ", + ) + .add_dep(Dependency::new("rustc-std-workspace-std", "*").optional(true)) + .feature("mockbuild", &["rustc-std-workspace-std"]) + .publish(); + return true; +} + +fn enable_build_std(e: &mut Execs, arg: Option<&str>) { + // First up, force Cargo to use our "mock sysroot" which mimics what + // libstd looks like upstream. + let root = paths::root(); + let root = root + .parent() // chop off test name + .unwrap() + .parent() // chop off `citN` + .unwrap() + .parent() // chop off `target` + .unwrap() + .join("tests/testsuite/mock-std"); + e.env("__CARGO_TESTS_ONLY_SRC_ROOT", &root); + + // Next, make sure it doesn't have implicit access to the host's sysroot + e.env("RUSTFLAGS", "--sysroot=/path/to/nowhere"); + + // And finally actually enable `build-std` for now + let arg = match arg { + Some(s) => format!("-Zbuild-std={}", s), + None => "-Zbuild-std".to_string(), }; - let target = paths::root().join("target"); - let mut execs = project.cargo(cmd); - if !cmd.contains("--target") { - execs.arg("--target").arg(rustc_host()); + e.arg(arg); + e.masquerade_as_nightly_cargo(); +} + +// Helper methods used in the tests below +trait BuildStd: Sized { + fn build_std(&mut self) -> &mut Self; + fn build_std_arg(&mut self, arg: &str) -> &mut Self; + fn target_host(&mut self) -> &mut Self; +} + +impl BuildStd for Execs { + fn build_std(&mut self) -> &mut Self { + enable_build_std(self, None); + self + } + + fn build_std_arg(&mut self, arg: &str) -> &mut Self { + enable_build_std(self, Some(arg)); + self + } + + fn target_host(&mut self) -> &mut Self { + self.arg("--target").arg(rustc_host()); + self } - execs - .arg(unstable) - .arg("-Zno-index-update") - .env_remove("CARGO_HOME") - .env_remove("HOME") - .env("CARGO_TARGET_DIR", target.as_os_str()) - .masquerade_as_nightly_cargo(); - execs } #[cargo_test] -fn std_lib() { - if !is_nightly() { - // -Zbuild-std is nightly - // -Zno-index-update is nightly - // We don't want these tests to run on rust-lang/rust. +fn basic() { + if !setup() { return; } - simple_lib_std(); - simple_bin_std(); - lib_nostd(); - check_core(); - cross_custom(); - hashbrown(); - libc(); - test(); - custom_test_framework(); - target_proc_macro(); - bench(); - doc(); - check_std(); - doctest(); + + let p = project() + .file( + "src/main.rs", + " + fn main() { + std::custom_api(); + foo::f(); + } + + #[test] + fn smoke_bin_unit() { + std::custom_api(); + foo::f(); + } + ", + ) + .file( + "src/lib.rs", + " + extern crate alloc; + extern crate proc_macro; + + /// ``` + /// foo::f(); + /// ``` + pub fn f() { + core::custom_api(); + std::custom_api(); + alloc::custom_api(); + proc_macro::custom_api(); + } + + #[test] + fn smoke_lib_unit() { + std::custom_api(); + f(); + } + ", + ) + .file( + "tests/smoke.rs", + " + #[test] + fn smoke_integration() { + std::custom_api(); + foo::f(); + } + ", + ) + .build(); + + p.cargo("check").build_std().target_host().run(); + p.cargo("build").build_std().target_host().run(); + p.cargo("run").build_std().target_host().run(); + p.cargo("test").build_std().target_host().run(); } +#[cargo_test] fn simple_lib_std() { + if !setup() { + return; + } let p = project().file("src/lib.rs", "").build(); - cargo_build_std(&p, "build -v", "") + p.cargo("build -v") + .build_std() + .target_host() .with_stderr_contains("[RUNNING] `rustc [..]--crate-name std [..]") .run(); // Check freshness. p.change_file("src/lib.rs", " "); - cargo_build_std(&p, "build -v", "std") + p.cargo("build -v") + .build_std() + .target_host() .with_stderr_contains("[FRESH] std[..]") .run(); } +#[cargo_test] fn simple_bin_std() { + if !setup() { + return; + } let p = project().file("src/main.rs", "fn main() {}").build(); - cargo_build_std(&p, "run -v", "std").run(); + p.cargo("run -v").build_std().target_host().run(); } +#[cargo_test] fn lib_nostd() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - #![no_std] - pub fn foo() { - assert_eq!(core::u8::MIN, 0); - } + #![no_std] + pub fn foo() { + assert_eq!(core::u8::MIN, 0); + } "#, ) .build(); - cargo_build_std(&p, "build -v --lib", "core") + p.cargo("build -v --lib") + .build_std_arg("core") + .target_host() .with_stderr_does_not_contain("[..]libstd[..]") .run(); } +#[cargo_test] fn check_core() { + if !setup() { + return; + } let p = project() .file("src/lib.rs", "#![no_std] fn unused_fn() {}") .build(); - cargo_build_std(&p, "check -v", "core") + p.cargo("check -v") + .build_std_arg("core") + .target_host() .with_stderr_contains("[WARNING] [..]unused_fn[..]`") .run(); } -fn cross_custom() { - let p = project() - .file("src/lib.rs", "#![no_std] pub fn f() {}") - .file( - "custom-target.json", - r#" - { - "llvm-target": "x86_64-unknown-none-gnu", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "arch": "x86_64", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "os": "none", - "linker-flavor": "ld.lld" - } - "#, - ) - .build(); - - cargo_build_std(&p, "build --target custom-target.json -v", "core").run(); -} - -fn hashbrown() { - let p = project() - .file( - "src/lib.rs", - r#" - pub fn f() -> hashbrown::HashMap { - hashbrown::HashMap::new() - } - "#, - ) - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.1.0" - edition = "2018" - - [dependencies] - hashbrown = "=0.4.0" - "#, - ) - .build(); - - cargo_build_std(&p, "build -v", "std").run(); -} +#[cargo_test] +fn depend_same_as_std() { + if !setup() { + return; + } -fn libc() { let p = project() .file( "src/lib.rs", r#" - pub fn f() -> ! { - unsafe { libc::exit(123); } - } + pub fn f() { + registry_dep_using_core::non_sysroot_api(); + registry_dep_using_alloc::non_sysroot_api(); + registry_dep_using_std::non_sysroot_api(); + } "#, ) .file( "Cargo.toml", r#" - [package] - name = "foo" - version = "0.1.0" - edition = "2018" - - [dependencies] - libc = "=0.2.54" + [package] + name = "foo" + version = "0.1.0" + edition = "2018" + + [dependencies] + registry-dep-using-core = "1.0" + registry-dep-using-alloc = "1.0" + registry-dep-using-std = "1.0" "#, ) .build(); - cargo_build_std(&p, "build -v", "std").run(); + p.cargo("build -v").build_std().target_host().run(); } +#[cargo_test] fn test() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - #[cfg(test)] - mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); + #[cfg(test)] + mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } } - } "#, ) .build(); - cargo_build_std(&p, "test -v", "std") + p.cargo("test -v") + .build_std() + .target_host() .with_stdout_contains("test tests::it_works ... ok") .run(); } -fn custom_test_framework() { - let p = project() - .file( - "src/lib.rs", - r#" - #![no_std] - #![cfg_attr(test, no_main)] - #![feature(custom_test_frameworks)] - #![test_runner(crate::test_runner)] - - pub fn test_runner(_tests: &[&dyn Fn()]) {} - - #[panic_handler] - fn panic(_info: &core::panic::PanicInfo) -> ! { - loop {} - } - "#, - ) - .file( - "target.json", - r#" - { - "llvm-target": "x86_64-unknown-none-gnu", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "arch": "x86_64", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "os": "none", - "linker-flavor": "ld.lld", - "linker": "rust-lld", - "executables": true, - "panic-strategy": "abort" - } - "#, - ) - .build(); - - cargo_build_std(&p, "test --target target.json --no-run -v", "core").run(); -} - +#[cargo_test] fn target_proc_macro() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - extern crate proc_macro; - pub fn f() { - let _ts = proc_macro::TokenStream::new(); - } + extern crate proc_macro; + pub fn f() { + let _ts = proc_macro::TokenStream::new(); + } "#, ) .build(); - cargo_build_std(&p, "build -v", "std,proc_macro").run(); + p.cargo("build -v").build_std().target_host().run(); } +#[cargo_test] fn bench() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - #![feature(test)] - extern crate test; + #![feature(test)] + extern crate test; - #[bench] - fn b1(b: &mut test::Bencher) { - b.iter(|| ()) - } + #[bench] + fn b1(b: &mut test::Bencher) { + b.iter(|| ()) + } "#, ) .build(); - cargo_build_std(&p, "bench -v", "std").run(); + p.cargo("bench -v").build_std().target_host().run(); } +#[cargo_test] fn doc() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - /// Doc - pub fn f() -> Result<(), ()> {Ok(())} + /// Doc + pub fn f() -> Result<(), ()> {Ok(())} "#, ) .build(); - cargo_build_std(&p, "doc -v", "std").run(); + p.cargo("doc -v").build_std().target_host().run(); } +#[cargo_test] fn check_std() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", @@ -292,31 +404,41 @@ fn check_std() { .file( "tests/t1.rs", r#" - #[test] - fn t1() { - assert_eq!(1, 2); - } + #[test] + fn t1() { + assert_eq!(1, 2); + } "#, ) .build(); - cargo_build_std(&p, "check -v --all-targets", "std").run(); - cargo_build_std(&p, "check -v --all-targets --profile=test", "std").run(); + p.cargo("check -v --all-targets") + .build_std() + .target_host() + .run(); + p.cargo("check -v --all-targets --profile=test") + .build_std() + .target_host() + .run(); } +#[cargo_test] fn doctest() { + if !setup() { + return; + } let p = project() .file( "src/lib.rs", r#" - /// Doc - /// ``` - /// assert_eq!(1, 1); - /// ``` - pub fn f() {} + /// Doc + /// ``` + /// assert_eq!(1, 1); + /// ``` + pub fn f() {} "#, ) .build(); - cargo_build_std(&p, "test --doc -v", "std").run(); + p.cargo("test --doc -v").build_std().target_host().run(); } diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index bfb6e0e11c5..c61924577b7 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -3,10 +3,12 @@ use std::io::prelude::*; use cargo; -use crate::support::paths::CargoPathExt; -use crate::support::registry::Package; -use crate::support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, project}; -use crate::support::{rustc_host, sleep_ms}; +use cargo_test_support::paths::CargoPathExt; +use cargo_test_support::registry::Package; +use cargo_test_support::{ + basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, project, +}; +use cargo_test_support::{rustc_host, sleep_ms}; #[cargo_test] fn cargo_test_simple() { diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index 07dfa082999..a198176ab82 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -1,5 +1,5 @@ -use crate::support::rustc_host; -use crate::support::{basic_lib_manifest, project}; +use cargo_test_support::rustc_host; +use cargo_test_support::{basic_lib_manifest, project}; #[cargo_test] fn pathless_tools() { diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index eaeb806138a..1f7a2ed594b 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -1,8 +1,8 @@ use std::fs::File; use std::io::prelude::*; -use crate::support::registry::Package; -use crate::support::{basic_manifest, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_manifest, project}; #[cargo_test] fn minor_update_two_places() { diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 42dbcca2345..61f1d2452a5 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -1,6 +1,6 @@ -use crate::support::git; -use crate::support::registry::Package; -use crate::support::{basic_lib_manifest, project, Project}; +use cargo_test_support::git; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_lib_manifest, project, Project}; #[cargo_test] fn vendor_simple() { diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs index 0bebf359def..a9bdb909b6b 100644 --- a/tests/testsuite/verify_project.rs +++ b/tests/testsuite/verify_project.rs @@ -1,4 +1,4 @@ -use crate::support::{basic_bin_manifest, main_file, project}; +use cargo_test_support::{basic_bin_manifest, main_file, project}; fn verify_project_success_output() -> String { r#"{"success":"true"}"#.into() diff --git a/tests/testsuite/version.rs b/tests/testsuite/version.rs index 7a04bde0405..0cb9fcc97b5 100644 --- a/tests/testsuite/version.rs +++ b/tests/testsuite/version.rs @@ -1,5 +1,5 @@ -use crate::support::project; use cargo; +use cargo_test_support::project; #[cargo_test] fn simple() { diff --git a/tests/testsuite/warn_on_failure.rs b/tests/testsuite/warn_on_failure.rs index bf662d81a77..0688326fd0f 100644 --- a/tests/testsuite/warn_on_failure.rs +++ b/tests/testsuite/warn_on_failure.rs @@ -1,5 +1,5 @@ -use crate::support::registry::Package; -use crate::support::{project, Project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{project, Project}; static WARNING1: &str = "Hello! I'm a warning. :)"; static WARNING2: &str = "And one more!"; diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 0ec72048032..a86955f908b 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2,9 +2,9 @@ use std::env; use std::fs::{self, File}; use std::io::{Read, Write}; -use crate::support::registry::Package; -use crate::support::sleep_ms; -use crate::support::{basic_lib_manifest, basic_manifest, git, project}; +use cargo_test_support::registry::Package; +use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project}; +use cargo_test_support::{sleep_ms, t}; #[cargo_test] fn simple_explicit() {