Add a test for --exclude test::XXX
I didn't know that the `test::` syntax was valid before, and it doesn't seem to be documented anywhere. Add a test so it doesn't regress accidentally, and as executable documentation.
This commit is contained in:
parent
8b94fbea01
commit
7a4a66da3d
3 changed files with 65 additions and 29 deletions
|
@ -26,6 +26,49 @@ fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
|
|||
v.into_iter().map(|(a, _)| a).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn run_build(paths: &[PathBuf], config: Config) -> Cache {
|
||||
let kind = config.cmd.kind();
|
||||
let build = Build::new(config);
|
||||
let builder = Builder::new(&build);
|
||||
builder.run_step_descriptions(&Builder::get_step_descriptions(kind), paths);
|
||||
builder.cache
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exclude() {
|
||||
let mut config = configure("test", &["A"], &["A"]);
|
||||
config.exclude = vec![TaskPath::parse("src/tools/tidy")];
|
||||
|
||||
let build = Build::new(config);
|
||||
let builder = Builder::new(&build);
|
||||
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
|
||||
|
||||
// Ensure we have really excluded tidy
|
||||
assert!(!builder.cache.contains::<test::Tidy>());
|
||||
|
||||
// Ensure other tests are not affected.
|
||||
assert!(builder.cache.contains::<test::RustdocUi>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exclude_kind() {
|
||||
let path = PathBuf::from("src/tools/cargotest");
|
||||
let exclude = TaskPath::parse("test::src/tools/cargotest");
|
||||
assert_eq!(exclude, TaskPath { kind: Some(Kind::Test), path: path.clone() });
|
||||
|
||||
let mut config = configure("test", &["A"], &["A"]);
|
||||
// Ensure our test is valid, and `test::Cargotest` would be run without the exclude.
|
||||
assert!(run_build(&[path.clone()], config.clone()).contains::<test::Cargotest>());
|
||||
// Ensure tests for cargotest are skipped.
|
||||
config.exclude = vec![exclude.clone()];
|
||||
assert!(!run_build(&[path.clone()], config).contains::<test::Cargotest>());
|
||||
|
||||
// Ensure builds for cargotest are not skipped.
|
||||
let mut config = configure("build", &["A"], &["A"]);
|
||||
config.exclude = vec![exclude];
|
||||
assert!(run_build(&[path], config).contains::<tool::CargoTest>());
|
||||
}
|
||||
|
||||
mod defaults {
|
||||
use super::{configure, first};
|
||||
use crate::builder::*;
|
||||
|
@ -515,35 +558,6 @@ mod dist {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exclude() {
|
||||
let mut config = configure(&["A"], &["A"]);
|
||||
config.exclude = vec![TaskPath::parse("src/tools/tidy")];
|
||||
config.cmd = Subcommand::Test {
|
||||
paths: Vec::new(),
|
||||
test_args: Vec::new(),
|
||||
rustc_args: Vec::new(),
|
||||
fail_fast: true,
|
||||
doc_tests: DocTests::No,
|
||||
bless: false,
|
||||
force_rerun: false,
|
||||
compare_mode: None,
|
||||
rustfix_coverage: false,
|
||||
pass: None,
|
||||
run: None,
|
||||
};
|
||||
|
||||
let build = Build::new(config);
|
||||
let builder = Builder::new(&build);
|
||||
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
|
||||
|
||||
// Ensure we have really excluded tidy
|
||||
assert!(!builder.cache.contains::<test::Tidy>());
|
||||
|
||||
// Ensure other tests are not affected.
|
||||
assert!(builder.cache.contains::<test::RustdocUi>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_ci() {
|
||||
let mut config = configure(&["A"], &["A"]);
|
||||
|
|
|
@ -41,6 +41,7 @@ macro_rules! check_ci_llvm {
|
|||
/// each field, see the corresponding fields in
|
||||
/// `config.toml.example`.
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub struct Config {
|
||||
pub changelog_seen: Option<usize>,
|
||||
pub ccache: Option<String>,
|
||||
|
@ -330,6 +331,7 @@ impl PartialEq<&str> for TargetSelection {
|
|||
|
||||
/// Per-target configuration stored in the global configuration structure.
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub struct Target {
|
||||
/// Some(path to llvm-config) if using an external LLVM.
|
||||
pub llvm_config: Option<PathBuf>,
|
||||
|
|
|
@ -14,6 +14,7 @@ use crate::setup::Profile;
|
|||
use crate::util::t;
|
||||
use crate::{Build, DocTests};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum Color {
|
||||
Always,
|
||||
Never,
|
||||
|
@ -79,6 +80,7 @@ pub struct Flags {
|
|||
pub llvm_profile_generate: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub enum Subcommand {
|
||||
Build {
|
||||
paths: Vec<PathBuf>,
|
||||
|
@ -668,6 +670,24 @@ Arguments:
|
|||
}
|
||||
|
||||
impl Subcommand {
|
||||
pub fn kind(&self) -> Kind {
|
||||
match self {
|
||||
Subcommand::Bench { .. } => Kind::Bench,
|
||||
Subcommand::Build { .. } => Kind::Build,
|
||||
Subcommand::Check { .. } => Kind::Check,
|
||||
Subcommand::Clippy { .. } => Kind::Clippy,
|
||||
Subcommand::Doc { .. } => Kind::Doc,
|
||||
Subcommand::Fix { .. } => Kind::Fix,
|
||||
Subcommand::Format { .. } => Kind::Format,
|
||||
Subcommand::Test { .. } => Kind::Test,
|
||||
Subcommand::Clean { .. } => Kind::Clean,
|
||||
Subcommand::Dist { .. } => Kind::Dist,
|
||||
Subcommand::Install { .. } => Kind::Install,
|
||||
Subcommand::Run { .. } => Kind::Run,
|
||||
Subcommand::Setup { .. } => Kind::Setup,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test_args(&self) -> Vec<&str> {
|
||||
match *self {
|
||||
Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue