Skip to content

Commit 79d845b

Browse files
committed
Auto merge of #7628 - ehuss:testsuite-comments, r=Eh2406
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.
2 parents 9eb1f0e + 83571ae commit 79d845b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+525
-323
lines changed

crates/cargo-test-support/src/cross_compile.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
//! Support for cross-compile tests with the `--target` flag.
2+
//!
3+
//! Note that cross-testing is very limited. You need to install the
4+
//! "alternate" target to the host (32-bit for 64-bit hosts or vice-versa).
5+
//!
6+
//! Set CFG_DISABLE_CROSS_TESTS=1 environment variable to disable these tests
7+
//! if you are unable to use the alternate target. Unfortunately 32-bit
8+
//! support on macOS is going away, so macOS users are out of luck.
9+
//!
10+
//! These tests are all disabled on rust-lang/rust's CI, but run in Cargo's CI.
11+
112
use crate::{basic_bin_manifest, main_file, project};
213
use std::env;
314
use std::process::Command;

tests/testsuite/alt_registry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for alternative registries.
2+
13
use cargo::util::IntoUrl;
24
use cargo_test_support::publish::validate_alt_upload;
35
use cargo_test_support::registry::{self, Package};

tests/testsuite/bad_config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for some invalid .cargo/config files.
2+
13
use cargo_test_support::registry::Package;
24
use cargo_test_support::{basic_manifest, project};
35

tests/testsuite/bad_manifest_path.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for invalid --manifest-path arguments.
2+
13
use cargo_test_support::{basic_bin_manifest, main_file, project};
24

35
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {

tests/testsuite/bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for the `cargo bench` command.
2+
13
use cargo_test_support::is_nightly;
24
use cargo_test_support::paths::CargoPathExt;
35
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project};

tests/testsuite/build.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for the `cargo build` command.
2+
13
use cargo::util::paths::dylib_path_envvar;
24
use cargo_test_support::paths::{root, CargoPathExt};
35
use cargo_test_support::registry::Package;
@@ -4607,3 +4609,65 @@ d
46074609
)
46084610
.run();
46094611
}
4612+
4613+
#[cargo_test]
4614+
fn build_lib_only() {
4615+
let p = project()
4616+
.file("src/main.rs", "fn main() {}")
4617+
.file("src/lib.rs", r#" "#)
4618+
.build();
4619+
4620+
p.cargo("build --lib -v")
4621+
.with_stderr(
4622+
"\
4623+
[COMPILING] foo v0.0.1 ([CWD])
4624+
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
4625+
--emit=[..]link -C debuginfo=2 \
4626+
-C metadata=[..] \
4627+
--out-dir [..] \
4628+
-L dependency=[CWD]/target/debug/deps`
4629+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
4630+
)
4631+
.run();
4632+
}
4633+
4634+
#[cargo_test]
4635+
fn build_with_no_lib() {
4636+
let p = project()
4637+
.file("Cargo.toml", &basic_bin_manifest("foo"))
4638+
.file("src/main.rs", "fn main() {}")
4639+
.build();
4640+
4641+
p.cargo("build --lib")
4642+
.with_status(101)
4643+
.with_stderr("[ERROR] no library targets found in package `foo`")
4644+
.run();
4645+
}
4646+
4647+
#[cargo_test]
4648+
fn build_with_relative_cargo_home_path() {
4649+
let p = project()
4650+
.file(
4651+
"Cargo.toml",
4652+
r#"
4653+
[package]
4654+
4655+
name = "foo"
4656+
version = "0.0.1"
4657+
authors = ["wycats@example.com"]
4658+
4659+
[dependencies]
4660+
4661+
"test-dependency" = { path = "src/test_dependency" }
4662+
"#,
4663+
)
4664+
.file("src/main.rs", "fn main() {}")
4665+
.file("src/test_dependency/src/lib.rs", r#" "#)
4666+
.file(
4667+
"src/test_dependency/Cargo.toml",
4668+
&basic_manifest("test-dependency", "0.0.1"),
4669+
)
4670+
.build();
4671+
4672+
p.cargo("build").env("CARGO_HOME", "./cargo_home/").run();
4673+
}

tests/testsuite/build_lib.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

tests/testsuite/build_plan.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for --build-plan feature.
2+
13
use cargo_test_support::registry::Package;
24
use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project};
35

tests/testsuite/build_script.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for build.rs scripts.
2+
13
use std::env;
24
use std::fs::{self, File};
35
use std::io;

tests/testsuite/build_script_env.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests for build.rs rerun-if-env-changed.
2+
13
use std::fs::File;
24

35
use cargo_test_support::project;

0 commit comments

Comments
 (0)