Skip to content

Commit

Permalink
Auto merge of #7628 - ehuss:testsuite-comments, r=Eh2406
Browse files Browse the repository at this point in the history
Minor testsuite organization.

I sometimes get a little lost when looking for the right module for tests.  This adds a brief comment to each one explaining what it is.  This also includes a few renamed modules, and a few tests have been placed in a location that makes a little more sense to me. There shouldn't be any functional changes here.

- Move `build_lib` into `build`.  It seemed a little strange to have these tests floating in a separate file.
- Rename `build_auth` to `git_auth`.
- Rename `small_fd_limits` to `git_gc`.
- Rename `resolve` to `minimal_versions`.
- Rename `overrides` to `replace`.
- Pull out `paths` overrides tests into a separate file.
  • Loading branch information
bors committed Nov 25, 2019
2 parents 9eb1f0e + 83571ae commit 79d845b
Show file tree
Hide file tree
Showing 93 changed files with 525 additions and 323 deletions.
11 changes: 11 additions & 0 deletions crates/cargo-test-support/src/cross_compile.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//! Support for cross-compile tests with the `--target` flag.
//!
//! Note that cross-testing is very limited. You need to install the
//! "alternate" target to the host (32-bit for 64-bit hosts or vice-versa).
//!
//! Set CFG_DISABLE_CROSS_TESTS=1 environment variable to disable these tests
//! if you are unable to use the alternate target. Unfortunately 32-bit
//! support on macOS is going away, so macOS users are out of luck.
//!
//! These tests are all disabled on rust-lang/rust's CI, but run in Cargo's CI.
use crate::{basic_bin_manifest, main_file, project};
use std::env;
use std::process::Command;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for alternative registries.
use cargo::util::IntoUrl;
use cargo_test_support::publish::validate_alt_upload;
use cargo_test_support::registry::{self, Package};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for some invalid .cargo/config files.
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, project};

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/bad_manifest_path.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for invalid --manifest-path arguments.
use cargo_test_support::{basic_bin_manifest, main_file, project};

fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo bench` command.
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};
Expand Down
64 changes: 64 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo build` command.
use cargo::util::paths::dylib_path_envvar;
use cargo_test_support::paths::{root, CargoPathExt};
use cargo_test_support::registry::Package;
Expand Down Expand Up @@ -4607,3 +4609,65 @@ d
)
.run();
}

#[cargo_test]
fn build_lib_only() {
let p = project()
.file("src/main.rs", "fn main() {}")
.file("src/lib.rs", r#" "#)
.build();

p.cargo("build --lib -v")
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
)
.run();
}

#[cargo_test]
fn build_with_no_lib() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("build --lib")
.with_status(101)
.with_stderr("[ERROR] no library targets found in package `foo`")
.run();
}

#[cargo_test]
fn build_with_relative_cargo_home_path() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = ["wycats@example.com"]
[dependencies]
"test-dependency" = { path = "src/test_dependency" }
"#,
)
.file("src/main.rs", "fn main() {}")
.file("src/test_dependency/src/lib.rs", r#" "#)
.file(
"src/test_dependency/Cargo.toml",
&basic_manifest("test-dependency", "0.0.1"),
)
.build();

p.cargo("build").env("CARGO_HOME", "./cargo_home/").run();
}
63 changes: 0 additions & 63 deletions tests/testsuite/build_lib.rs

This file was deleted.

2 changes: 2 additions & 0 deletions tests/testsuite/build_plan.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for --build-plan feature.
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project};

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for build.rs scripts.
use std::env;
use std::fs::{self, File};
use std::io;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/build_script_env.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for build.rs rerun-if-env-changed.
use std::fs::File;

use cargo_test_support::project;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cache_messages.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for caching compiler diagnostics.
use cargo_test_support::{
clippy_is_available, is_coarse_mtime, process, project, registry::Package, sleep_ms,
};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_alias_config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for `[alias]` config command aliases.
use cargo_test_support::{basic_bin_manifest, project};

#[cargo_test]
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for custom cargo commands and other global command features.
use std::env;
use std::fs::{self, File};
use std::io::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_features.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for `cargo-features` definitions.
use cargo_test_support::{project, registry};

#[cargo_test]
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for cfg() expressions.
use cargo_test_support::registry::Package;
use cargo_test_support::rustc_host;
use cargo_test_support::{basic_manifest, project};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo check` command.
use std::fmt::{self, Write};

use cargo_test_support::install::exe;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo clean` command.
use std::env;

use cargo_test_support::registry::Package;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/clippy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo clippy` command.
use cargo_test_support::{clippy_is_available, project, registry::Package};

#[cargo_test]
Expand Down
5 changes: 5 additions & 0 deletions tests/testsuite/collisions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Tests for when multiple artifacts have the same output filename.
//! See https://github.com/rust-lang/cargo/issues/6313 for more details.
//! Ideally these should never happen, but I don't think we'll ever be able to
//! prevent all collisions.
use cargo_test_support::basic_manifest;
use cargo_test_support::project;
use std::env;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/concurrent.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for running multiple `cargo` processes at the same time.
use std::fs::{self, File};
use std::io::Write;
use std::net::TcpListener;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for config settings.
use std::borrow::Borrow;
use std::collections;
use std::fs;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/corrupt_git.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for corrupt git repos.
use std::fs;
use std::path::{Path, PathBuf};

Expand Down
4 changes: 4 additions & 0 deletions tests/testsuite/cross_compile.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Tests for cross compiling with --target.
//!
//! See `cargo_test_support::cross_compile` for more detail.
use cargo_test_support::{basic_bin_manifest, basic_manifest, cross_compile, project};
use cargo_test_support::{is_nightly, rustc_host};

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/cross_publish.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for publishing using the `--target` flag.
use std::fs::File;

use cargo_test_support::{cross_compile, project, publish, registry};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/custom_target.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for custom json target specifications.
use cargo_test_support::is_nightly;
use cargo_test_support::{basic_manifest, project};

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/death.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for ctrl-C handling.
use std::fs;
use std::io::{self, Read};
use std::net::TcpListener;
Expand Down
3 changes: 3 additions & 0 deletions tests/testsuite/dep_info.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! 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 cargo_test_support::paths::{self, CargoPathExt};
use cargo_test_support::registry::Package;
use cargo_test_support::{
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/directory.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for directory sources.
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo doc` command.
use std::fs::{self, File};
use std::io::Read;
use std::str;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/edition.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for edition setting.
use cargo_test_support::{basic_lib_manifest, project};

#[cargo_test]
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for `[features]` table.
use std::fs::File;
use std::io::prelude::*;

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/fetch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo fetch` command.
use cargo_test_support::registry::Package;
use cargo_test_support::rustc_host;
use cargo_test_support::{basic_manifest, cross_compile, project};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo fix` command.
use std::fs::File;

use cargo_test_support::git;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for fingerprinting (rebuild detection).
use filetime::FileTime;
use std::fs::{self, File, OpenOptions};
use std::io;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/generate_lockfile.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo generate-lockfile` command.
use std::fs::{self, File};
use std::io::prelude::*;

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for git support.
use git2;
use std::env;
use std::fs::{self, File};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/build_auth.rs → tests/testsuite/git_auth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for git authentication.
use std::collections::HashSet;
use std::io::prelude::*;
use std::io::BufReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for git garbage collection.
use std::env;
use std::ffi::OsStr;
use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/init.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo init` command.
use cargo_test_support;
use std::env;
use std::fs::{self, File};
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the `cargo install` command.
use std::fs::{self, File, OpenOptions};
use std::io::prelude::*;

Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/install_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for `cargo install` where it upgrades a package if it is out-of-date.
use cargo::core::PackageId;
use std::collections::BTreeSet;
use std::env;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/jobserver.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for the jobserver protocol.
use std::net::TcpListener;
use std::process::Command;
use std::thread;
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/list_targets.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for target filter flags giving suggestions on which targets are available.
use cargo_test_support::project;

const EXAMPLE: u8 = 0x1;
Expand Down
Loading

0 comments on commit 79d845b

Please sign in to comment.