Skip to content

Commit

Permalink
Auto merge of #7011 - alexcrichton:resolver-extract, r=Eh2406
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 18, 2019
2 parents 0a9d3ae + 290a727 commit 22a8715
Show file tree
Hide file tree
Showing 14 changed files with 1,497 additions and 1,480 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/target
/tests/testsuite/support/cargo-test-macro/target
target
Cargo.lock
.cargo
/config.stamp
Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ matrix:
- (cd src/doc && mdbook build --dest-dir ../../target/doc) || travis_terminate 1
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:
- rust: stable

Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ path = "src/cargo/lib.rs"
atty = "0.2"
byteorder = "1.2"
bytesize = "1.0"
crates-io = { path = "src/crates-io", version = "0.26" }
crates-io = { path = "crates/crates-io", version = "0.26" }
crossbeam-utils = "0.6"
crypto-hash = "0.3.1"
curl = { version = "0.4.21", features = ['http2'] }
Expand Down Expand Up @@ -102,9 +102,7 @@ features = [

[dev-dependencies]
bufstream = "0.1"
proptest = "0.9.1"
varisat = "0.2.1"
cargo-test-macro = { "path" = "tests/testsuite/support/cargo-test-macro", version = "0.1.0" }
cargo-test-macro = { path = "crates/cargo-test-macro", version = "0.1.0" }

[[bin]]
name = "cargo"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions crates/resolver-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "resolver-tests"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2018"

[dependencies]
cargo = { path = "../.." }
proptest = "0.9.1"
lazy_static = "1.3.0"
varisat = "0.2.1"
atty = "0.2.11"
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt;
use std::time::Instant;

use crate::support::slow_cpu_multiplier;

use cargo::core::dependency::Kind;
use cargo::core::resolver::{self, Method};
use cargo::core::source::{GitReference, SourceId};
Expand All @@ -16,9 +14,7 @@ use cargo::util::{CargoResult, Config, Graph, ToUrl};
use proptest::collection::{btree_map, vec};
use proptest::prelude::*;
use proptest::sample::Index;
use proptest::strategy::ValueTree;
use proptest::string::string_regex;
use proptest::test_runner::TestRunner;
use varisat::{self, ExtendFormula};

pub fn resolve(
Expand Down Expand Up @@ -182,7 +178,7 @@ pub fn resolve_with_config_raw(

// The largest test in our suite takes less then 30 sec.
// 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
}

Expand Down Expand Up @@ -493,14 +489,15 @@ impl<T: AsRef<str>, U: AsRef<str>> ToPkgId for (T, U) {
}
}

#[macro_export]
macro_rules! pkg {
($pkgid:expr => [$($deps:expr),+ $(,)* ]) => ({
let d: Vec<Dependency> = vec![$($deps.to_dep()),+];
pkg_dep($pkgid, d)
$crate::pkg_dep($pkgid, d)
});

($pkgid:expr) => ({
pkg($pkgid)
$crate::pkg($pkgid)
})
}

Expand Down Expand Up @@ -663,7 +660,7 @@ impl fmt::Debug for PrettyPrintRegistry {
}
}

#[cargo_test]
#[test]
fn meta_test_deep_pretty_print_registry() {
assert_eq!(
&format!(
Expand Down Expand Up @@ -839,8 +836,11 @@ pub fn registry_strategy(

/// This test is to test the generator to ensure
/// that it makes registries with large dependency trees
#[cargo_test]
#[test]
fn meta_test_deep_trees_from_strategy() {
use proptest::strategy::ValueTree;
use proptest::test_runner::TestRunner;

let mut dis = [0; 21];

let strategy = registry_strategy(50, 20, 60);
Expand Down Expand Up @@ -878,8 +878,11 @@ fn meta_test_deep_trees_from_strategy() {

/// This test is to test the generator to ensure
/// that it makes registries that include multiple versions of the same library
#[cargo_test]
#[test]
fn meta_test_multiple_versions_strategy() {
use proptest::strategy::ValueTree;
use proptest::test_runner::TestRunner;

let mut dis = [0; 10];

let strategy = registry_strategy(50, 20, 60);
Expand Down
Loading

0 comments on commit 22a8715

Please sign in to comment.