refactor: Migrate from extern crate to test-support prelude

We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
This commit is contained in:
Ed Page 2024-07-12 00:22:40 -05:00
parent 090064cc14
commit 5b9799c6f4
164 changed files with 301 additions and 118 deletions

1
Cargo.lock generated
View file

@ -279,7 +279,6 @@ dependencies = [
"cargo-credential-macos-keychain",
"cargo-credential-wincred",
"cargo-platform 0.1.8",
"cargo-test-macro",
"cargo-test-support",
"cargo-util",
"cargo-util-schemas",

View file

@ -237,7 +237,6 @@ features = [
[dev-dependencies]
annotate-snippets = { workspace = true, features = ["testing-colors"] }
cargo-test-macro.workspace = true
cargo-test-support.workspace = true
gix = { workspace = true, features = ["revision"] }
same-file.workspace = true

View file

@ -21,7 +21,7 @@
#![allow(clippy::disallowed_methods)]
use cargo_test_support::prelude::*;
use cargo_test_support::*;
use cargo_test_support::{basic_manifest, paths, project, rustc_host, str, Execs};
use std::env;
use std::path::Path;

View file

@ -1,5 +1,6 @@
//! -Zadvanced-env tests
use cargo_test_support::prelude::*;
use cargo_test_support::{paths, project, registry::Package};
#[cargo_test]

View file

@ -1,12 +1,13 @@
//! Tests for alternative registries.
use std::fs;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::prelude::*;
use cargo_test_support::publish::validate_alt_upload;
use cargo_test_support::registry::{self, Package, RegistryBuilder};
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, paths, project};
use std::fs;
#[cargo_test]
fn depend_on_alt_registry() {

View file

@ -1,12 +1,13 @@
//! Tests for --artifact-dir flag.
use std::env;
use std::fs;
use std::path::Path;
use cargo_test_support::prelude::*;
use cargo_test_support::sleep_ms;
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, project};
use std::env;
use std::fs;
use std::path::Path;
#[cargo_test]
fn binary_with_debug() {

View file

@ -1,5 +1,10 @@
//! Tests for the `cargo build` command.
use std::env;
use std::fs;
use std::io::Read;
use std::process::Stdio;
use cargo::{
core::compiler::CompileMode,
core::{Shell, Workspace},
@ -17,10 +22,6 @@ use cargo_test_support::{
tools, Execs, ProjectBuilder,
};
use cargo_util::paths::dylib_path_envvar;
use std::env;
use std::fs;
use std::io::Read;
use std::process::Stdio;
#[cargo_test]
fn cargo_compile_simple() {

View file

@ -1,5 +1,10 @@
//! Tests for build.rs scripts.
use std::env;
use std::fs;
use std::io;
use std::thread;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::install::cargo_home;
use cargo_test_support::paths::CargoPathExt;
@ -12,10 +17,6 @@ use cargo_test_support::{
};
use cargo_test_support::{rustc_host, sleep_ms, slow_cpu_multiplier, symlink_supported};
use cargo_util::paths::{self, remove_dir_all};
use std::env;
use std::fs;
use std::io;
use std::thread;
#[cargo_test]
fn custom_build_script_failed() {

View file

@ -1,6 +1,7 @@
//! Tests for build.rs rerun-if-env-changed and rustc-env
use cargo_test_support::basic_manifest;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::sleep_ms;
use cargo_test_support::str;

View file

@ -4,6 +4,7 @@
// because MSVC link.exe just gives a warning on unknown flags (how helpful!),
// and other linkers will return an error.
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project};

View file

@ -1,10 +1,13 @@
//! Tests for `CacheLock`.
use crate::config::GlobalContextBuilder;
use std::thread::JoinHandle;
use cargo::util::cache_lock::{CacheLockMode, CacheLocker};
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::prelude::*;
use cargo_test_support::{retry, thread_wait_timeout, threaded_timeout};
use std::thread::JoinHandle;
use crate::config::GlobalContextBuilder;
/// Helper to verify that it is OK to acquire the given lock (it shouldn't block).
fn verify_lock_is_ok(mode: CacheLockMode) {

View file

@ -1,10 +1,12 @@
//! Tests for caching compiler diagnostics.
use super::messages::raw_rustc_output;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::tools;
use cargo_test_support::{basic_manifest, is_coarse_mtime, project, registry::Package, sleep_ms};
use super::messages::raw_rustc_output;
fn as_str(bytes: &[u8]) -> &str {
std::str::from_utf8(bytes).expect("valid utf-8")
}

View file

@ -2,6 +2,7 @@
use std::env;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::tools::echo_subcommand;
use cargo_test_support::{basic_bin_manifest, project};

View file

@ -1,5 +1,6 @@
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -9,6 +9,7 @@ use std::str;
use cargo_test_support::basic_manifest;
use cargo_test_support::paths::CargoPathExt;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::tools::echo_subcommand;

View file

@ -1,6 +1,7 @@
//! Tests for `[env]` config.
use cargo_test_support::basic_manifest;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::{basic_bin_manifest, project};

View file

@ -1,5 +1,6 @@
//! Tests for `cargo-features` definitions.
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{project, registry};

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,8 +1,9 @@
use std::fs;
use cargo_test_support::file;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use std::fs;
#[cargo_test]
fn case() {

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -3,6 +3,7 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::git;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,6 +1,7 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,5 +1,6 @@
//! Tests specifically related to target handling (lib, bins, examples, tests, benches).
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;

View file

@ -1,5 +1,6 @@
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

View file

@ -1,5 +1,6 @@
//! Tests for cfg() expressions.
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::rustc_host;
use cargo_test_support::{basic_manifest, project, str};

View file

@ -10,6 +10,7 @@ use std::{env, str};
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::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, execs, project, slow_cpu_multiplier};

View file

@ -1,5 +1,12 @@
//! Tests for config settings.
use std::borrow::Borrow;
use std::collections::{BTreeMap, HashMap};
use std::fs;
use std::io;
use std::os;
use std::path::{Path, PathBuf};
use cargo::core::features::{GitFeatures, GitoxideFeatures};
use cargo::core::{PackageIdSpec, Shell};
use cargo::util::context::{
@ -14,12 +21,6 @@ use cargo_util_schemas::manifest::TomlTrimPaths;
use cargo_util_schemas::manifest::TomlTrimPathsValue;
use cargo_util_schemas::manifest::{self as cargo_toml, TomlDebugInfo, VecStringOrBool as VSOB};
use serde::Deserialize;
use std::borrow::Borrow;
use std::collections::{BTreeMap, HashMap};
use std::fs;
use std::io;
use std::os;
use std::path::{Path, PathBuf};
/// Helper for constructing a `GlobalContext` object.
pub struct GlobalContextBuilder {

View file

@ -1,13 +1,16 @@
//! Tests for the --config CLI option.
use std::{collections::HashMap, fs};
use cargo::util::context::Definition;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use super::config::{
assert_error, read_output, write_config_at, write_config_toml, GlobalContextBuilder,
};
use cargo::util::context::Definition;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::paths;
use cargo_test_support::str;
use std::{collections::HashMap, fs};
#[cargo_test]
fn basic() {

View file

@ -1,9 +1,11 @@
//! Tests for `include` config field.
use super::config::{assert_error, write_config_at, write_config_toml, GlobalContextBuilder};
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;
use super::config::{assert_error, write_config_at, write_config_toml, GlobalContextBuilder};
#[cargo_test]
fn gated() {
// Requires -Z flag.

View file

@ -1,11 +1,13 @@
//! Tests for corrupt git repos.
use cargo_test_support::paths;
use cargo_test_support::{basic_manifest, git, project};
use cargo_util::paths as cargopaths;
use std::fs;
use std::path::{Path, PathBuf};
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::{basic_manifest, git, project};
use cargo_util::paths as cargopaths;
#[cargo_test]
fn deleting_database_files() {
let project = project();

View file

@ -1,5 +1,6 @@
//! Tests for credential-process.
use cargo_test_support::prelude::*;
use cargo_test_support::registry::{Package, TestRegistry};
use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, str, Project};

View file

@ -2,6 +2,7 @@
use std::fs::File;
use cargo_test_support::prelude::*;
use cargo_test_support::{cross_compile, project, publish, registry, str};
#[cargo_test]

View file

@ -1,8 +1,10 @@
//! Tests for custom json target specifications.
use cargo_test_support::{basic_manifest, project, str};
use std::fs;
use cargo_test_support::prelude::*;
use cargo_test_support::{basic_manifest, project, str};
const MINIMAL_LIB: &str = r#"
#![allow(internal_features)]
#![feature(no_core)]

View file

@ -1,12 +1,14 @@
//! Tests for ctrl-C handling.
use cargo_test_support::{project, slow_cpu_multiplier};
use std::fs;
use std::io::{self, Read};
use std::net::TcpListener;
use std::process::{Child, Stdio};
use std::thread;
use cargo_test_support::prelude::*;
use cargo_test_support::{project, slow_cpu_multiplier};
#[cargo_test]
fn ctrl_c_kills_everyone() {
let listener = TcpListener::bind("127.0.0.1:0").unwrap();

View file

@ -1,17 +1,19 @@
//! Tests for dep-info files. This includes the dep-info file Cargo creates in
//! the output directory, and the ones stored in the fingerprint.
use std::fs;
use std::path::Path;
use std::str;
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{
basic_bin_manifest, basic_manifest, main_file, project, rustc_host, Project,
};
use filetime::FileTime;
use std::fs;
use std::path::Path;
use std::str;
// Helper for testing dep-info files in the fingerprint dir.
#[track_caller]

View file

@ -1,3 +1,4 @@
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;

View file

@ -2,6 +2,7 @@
//!
//! Note: Some tests are located in the resolver-tests package.
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::registry::Package;
use cargo_test_support::str;

View file

@ -4,14 +4,14 @@ use std::collections::HashMap;
use std::fs;
use std::str;
use serde::Serialize;
use cargo_test_support::cargo_process;
use cargo_test_support::git;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::{cksum, Package};
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, project, t, ProjectBuilder};
use serde::Serialize;
fn setup() {
let root = paths::root();

View file

@ -1,5 +1,8 @@
//! Tests for the `cargo doc` command.
use std::fs;
use std::str;
use cargo::core::compiler::RustDocFingerprint;
use cargo_test_support::paths::CargoPathExt;
use cargo_test_support::prelude::*;
@ -7,8 +10,6 @@ use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project};
use cargo_test_support::{rustc_host, symlink_supported, tools};
use std::fs;
use std::str;
#[cargo_test]
fn simple() {

View file

@ -1,6 +1,7 @@
//! Tests for edition setting.
use cargo::core::Edition;
use cargo_test_support::prelude::*;
use cargo_test_support::{basic_lib_manifest, project, str};
#[cargo_test]

View file

@ -1,6 +1,7 @@
//! General error tests that don't belong anywhere else.
use cargo_test_support::cargo_process;
use cargo_test_support::prelude::*;
#[cargo_test]
fn internal_error() {

View file

@ -1,5 +1,7 @@
//! Tests for the new feature resolver.
use std::fs::File;
use cargo_test_support::cross_compile::{self, alternate};
use cargo_test_support::install::cargo_home;
use cargo_test_support::paths::CargoPathExt;
@ -8,7 +10,6 @@ use cargo_test_support::publish::validate_crate_contents;
use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, cargo_process, project, rustc_host, Project};
use std::fs::File;
/// Switches Cargo.toml to use `resolver = "2"`.
pub fn switch_to_resolver_2(p: &Project) {

View file

@ -1,11 +1,12 @@
//! Tests for namespaced features.
use super::features2::switch_to_resolver_2;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::{Dependency, Package, RegistryBuilder};
use cargo_test_support::str;
use cargo_test_support::{project, publish};
use super::features2::switch_to_resolver_2;
#[cargo_test]
fn dependency_with_crate_syntax() {
// Registry dependency uses dep: syntax.

View file

@ -2,6 +2,7 @@
#![allow(deprecated)]
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::rustc_host;
use cargo_test_support::{basic_manifest, cross_compile, project};

View file

@ -14,11 +14,12 @@
//! The [`expect_fix_runs_rustc_n_times`] function handles setting everything
//! up, and verifying the results.
use cargo_test_support::{basic_manifest, paths, project, str, tools, Execs};
use snapbox::IntoData;
use std::path::PathBuf;
use std::sync::{Mutex, OnceLock};
use cargo_test_support::prelude::*;
use cargo_test_support::{basic_manifest, paths, project, str, tools, Execs};
/// The action that the `rustc` shim should take in the current sequence of
/// events.
#[derive(Clone, Copy, PartialEq)]

View file

@ -1,7 +1,5 @@
//! Tests for fingerprinting (rebuild detection).
use filetime::FileTime;
use snapbox::IntoData;
use std::fs::{self, OpenOptions};
use std::io;
use std::io::prelude::*;
@ -11,13 +9,16 @@ use std::process::Stdio;
use std::thread;
use std::time::SystemTime;
use super::death;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::{
basic_lib_manifest, basic_manifest, is_coarse_mtime, project, rustc_host, rustc_host_env,
sleep_ms, str,
};
use filetime::FileTime;
use super::death;
#[cargo_test]
fn modifying_and_moving() {

View file

@ -7,10 +7,12 @@
//! So we pick some random lint that will likely always be the same
//! over time.
use super::config::write_config_toml;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, project, str, Project};
use super::config::write_config_toml;
// An arbitrary lint (unused_variables) that triggers a lint.
// We use a special flag to force it to generate a report.
const FUTURE_EXAMPLE: &'static str = "fn main() { let x = 1; }";

View file

@ -1,9 +1,10 @@
//! Tests for the `cargo generate-lockfile` command.
use std::fs;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::{Package, RegistryBuilder};
use cargo_test_support::{basic_manifest, paths, project, str, ProjectBuilder};
use snapbox::IntoData;
use std::fs;
#[cargo_test]
fn adding_and_removing_packages() {

View file

@ -12,6 +12,7 @@ use std::thread;
use cargo_test_support::git::cargo_uses_gitoxide;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::prelude::IntoData;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project};
use cargo_test_support::{sleep_ms, str, t, Project};

View file

@ -11,6 +11,7 @@ use std::thread::{self, JoinHandle};
use cargo_test_support::basic_manifest;
use cargo_test_support::git::cargo_uses_gitoxide;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
fn setup_failed_auth_test() -> (SocketAddr, JoinHandle<()>, Arc<AtomicUsize>) {

View file

@ -7,9 +7,9 @@ use std::path::PathBuf;
use cargo_test_support::git;
use cargo_test_support::git::cargo_uses_gitoxide;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::registry::Package;
use url::Url;
pub fn find_index() -> PathBuf {

View file

@ -1,7 +1,9 @@
use crate::git_gc::find_index;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, git, paths, project};
use crate::git_gc::find_index;
enum RepoMode {
Shallow,
Complete,

View file

@ -8,18 +8,6 @@
#![allow(deprecated)]
use super::config::GlobalContextBuilder;
use cargo::core::global_cache_tracker::{self, DeferredGlobalLastUse, GlobalCacheTracker};
use cargo::util::cache_lock::CacheLockMode;
use cargo::util::interning::InternedString;
use cargo::GlobalContext;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::registry::{Package, RegistryBuilder};
use cargo_test_support::{
basic_manifest, cargo_process, execs, git, process, project, retry, sleep_ms,
thread_wait_timeout, Execs, Project,
};
use itertools::Itertools;
use std::env;
use std::fmt::Write;
use std::path::Path;
@ -28,6 +16,21 @@ use std::process::Stdio;
use std::sync::OnceLock;
use std::time::{Duration, SystemTime};
use cargo::core::global_cache_tracker::{self, DeferredGlobalLastUse, GlobalCacheTracker};
use cargo::util::cache_lock::CacheLockMode;
use cargo::util::interning::InternedString;
use cargo::GlobalContext;
use cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::prelude::*;
use cargo_test_support::registry::{Package, RegistryBuilder};
use cargo_test_support::{
basic_manifest, cargo_process, execs, git, process, project, retry, sleep_ms,
thread_wait_timeout, Execs, Project,
};
use itertools::Itertools;
use super::config::GlobalContextBuilder;
/// Helper to create a simple `foo` project which depends on a registry
/// dependency called `bar`.
fn basic_foo_bar_project() -> Project {

View file

@ -1,12 +1,14 @@
//! Tests for cargo's help output.
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, cargo_exe, cargo_process, paths, process, project};
use std::fs;
use std::path::Path;
use std::str::from_utf8;
use cargo_test_support::prelude::*;
use cargo_test_support::registry::Package;
use cargo_test_support::str;
use cargo_test_support::{basic_manifest, cargo_exe, cargo_process, paths, process, project};
#[cargo_test]
fn help() {
cargo_process("").run();

View file

@ -4,6 +4,7 @@
//! or CARGO_PUBLIC_NETWORK_TESTS.
use cargo_test_support::containers::Container;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;

Some files were not shown because too many files have changed in this diff Show more