Extract resolver tests to their own crate

These tests take a good amount of time to run locally and they're also
causing a lot of dependencies to get pulled into rust-lang/rust, so
let's have a separate crate that we just test on our own CI
This commit is contained in:
Alex Crichton 2019-06-05 12:54:56 -07:00
parent e449cb23e3
commit 290a727ad0
10 changed files with 1496 additions and 1479 deletions

3
.gitignore vendored
View File

@ -1,5 +1,4 @@
/target target
/tests/testsuite/support/cargo-test-macro/target
Cargo.lock Cargo.lock
.cargo .cargo
/config.stamp /config.stamp

View File

@ -42,6 +42,13 @@ matrix:
- (cd src/doc && mdbook build --dest-dir ../../target/doc) || travis_terminate 1 - (cd src/doc && mdbook build --dest-dir ../../target/doc) || travis_terminate 1
if: branch != master OR type = pull_request if: branch != master OR type = pull_request
- name: resolver tests
rust: stable
before_script: true
script:
- cargo test --manifest-path crates/resolver-tests/Cargo.toml
if: branch != master OR type = pull_request
exclude: exclude:
- rust: stable - rust: stable

View File

@ -102,9 +102,7 @@ features = [
[dev-dependencies] [dev-dependencies]
bufstream = "0.1" bufstream = "0.1"
proptest = "0.9.1" cargo-test-macro = { path = "crates/cargo-test-macro", version = "0.1.0" }
varisat = "0.2.1"
cargo-test-macro = { "path" = "tests/testsuite/support/cargo-test-macro", version = "0.1.0" }
[[bin]] [[bin]]
name = "cargo" name = "cargo"

View File

@ -0,0 +1,12 @@
[package]
name = "resolver-tests"
version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2018"
[dependencies]
cargo = { path = "../.." }
proptest = "0.9.1"
lazy_static = "1.3.0"
varisat = "0.2.1"
atty = "0.2.11"

View File

@ -4,8 +4,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt; use std::fmt;
use std::time::Instant; use std::time::Instant;
use crate::support::slow_cpu_multiplier;
use cargo::core::dependency::Kind; use cargo::core::dependency::Kind;
use cargo::core::resolver::{self, Method}; use cargo::core::resolver::{self, Method};
use cargo::core::source::{GitReference, SourceId}; use cargo::core::source::{GitReference, SourceId};
@ -16,9 +14,7 @@ use cargo::util::{CargoResult, Config, Graph, ToUrl};
use proptest::collection::{btree_map, vec}; use proptest::collection::{btree_map, vec};
use proptest::prelude::*; use proptest::prelude::*;
use proptest::sample::Index; use proptest::sample::Index;
use proptest::strategy::ValueTree;
use proptest::string::string_regex; use proptest::string::string_regex;
use proptest::test_runner::TestRunner;
use varisat::{self, ExtendFormula}; use varisat::{self, ExtendFormula};
pub fn resolve( pub fn resolve(
@ -182,7 +178,7 @@ pub fn resolve_with_config_raw(
// The largest test in our suite takes less then 30 sec. // The largest test in our suite takes less then 30 sec.
// So lets fail the test if we have ben running for two long. // So lets fail the test if we have ben running for two long.
assert!(start.elapsed() < slow_cpu_multiplier(60)); assert!(start.elapsed().as_secs() < 60);
resolve resolve
} }
@ -493,14 +489,15 @@ impl<T: AsRef<str>, U: AsRef<str>> ToPkgId for (T, U) {
} }
} }
#[macro_export]
macro_rules! pkg { macro_rules! pkg {
($pkgid:expr => [$($deps:expr),+ $(,)* ]) => ({ ($pkgid:expr => [$($deps:expr),+ $(,)* ]) => ({
let d: Vec<Dependency> = vec![$($deps.to_dep()),+]; let d: Vec<Dependency> = vec![$($deps.to_dep()),+];
pkg_dep($pkgid, d) $crate::pkg_dep($pkgid, d)
}); });
($pkgid:expr) => ({ ($pkgid:expr) => ({
pkg($pkgid) $crate::pkg($pkgid)
}) })
} }
@ -663,7 +660,7 @@ impl fmt::Debug for PrettyPrintRegistry {
} }
} }
#[cargo_test] #[test]
fn meta_test_deep_pretty_print_registry() { fn meta_test_deep_pretty_print_registry() {
assert_eq!( assert_eq!(
&format!( &format!(
@ -839,8 +836,11 @@ pub fn registry_strategy(
/// This test is to test the generator to ensure /// This test is to test the generator to ensure
/// that it makes registries with large dependency trees /// that it makes registries with large dependency trees
#[cargo_test] #[test]
fn meta_test_deep_trees_from_strategy() { fn meta_test_deep_trees_from_strategy() {
use proptest::strategy::ValueTree;
use proptest::test_runner::TestRunner;
let mut dis = [0; 21]; let mut dis = [0; 21];
let strategy = registry_strategy(50, 20, 60); let strategy = registry_strategy(50, 20, 60);
@ -878,8 +878,11 @@ fn meta_test_deep_trees_from_strategy() {
/// This test is to test the generator to ensure /// This test is to test the generator to ensure
/// that it makes registries that include multiple versions of the same library /// that it makes registries that include multiple versions of the same library
#[cargo_test] #[test]
fn meta_test_multiple_versions_strategy() { fn meta_test_multiple_versions_strategy() {
use proptest::strategy::ValueTree;
use proptest::test_runner::TestRunner;
let mut dis = [0; 10]; let mut dis = [0; 10];
let strategy = registry_strategy(50, 20, 60); let strategy = registry_strategy(50, 20, 60);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -139,8 +139,6 @@ pub mod git;
pub mod paths; pub mod paths;
pub mod publish; pub mod publish;
pub mod registry; pub mod registry;
#[macro_use]
pub mod resolver;
/* /*
* *