Skip to content

Commit 22a8715

Browse files
committed
Auto merge of #7011 - alexcrichton:resolver-extract, r=Eh2406
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
2 parents 0a9d3ae + 290a727 commit 22a8715

File tree

14 files changed

+1497
-1480
lines changed

14 files changed

+1497
-1480
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/target
2-
/tests/testsuite/support/cargo-test-macro/target
1+
target
32
Cargo.lock
43
.cargo
54
/config.stamp

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ matrix:
4242
- (cd src/doc && mdbook build --dest-dir ../../target/doc) || travis_terminate 1
4343
if: branch != master OR type = pull_request
4444

45+
- name: resolver tests
46+
rust: stable
47+
before_script: true
48+
script:
49+
- cargo test --manifest-path crates/resolver-tests/Cargo.toml
50+
if: branch != master OR type = pull_request
51+
4552
exclude:
4653
- rust: stable
4754

Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ path = "src/cargo/lib.rs"
2121
atty = "0.2"
2222
byteorder = "1.2"
2323
bytesize = "1.0"
24-
crates-io = { path = "src/crates-io", version = "0.26" }
24+
crates-io = { path = "crates/crates-io", version = "0.26" }
2525
crossbeam-utils = "0.6"
2626
crypto-hash = "0.3.1"
2727
curl = { version = "0.4.21", features = ['http2'] }
@@ -102,9 +102,7 @@ features = [
102102

103103
[dev-dependencies]
104104
bufstream = "0.1"
105-
proptest = "0.9.1"
106-
varisat = "0.2.1"
107-
cargo-test-macro = { "path" = "tests/testsuite/support/cargo-test-macro", version = "0.1.0" }
105+
cargo-test-macro = { path = "crates/cargo-test-macro", version = "0.1.0" }
108106

109107
[[bin]]
110108
name = "cargo"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crates/resolver-tests/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "resolver-tests"
3+
version = "0.1.0"
4+
authors = ["Alex Crichton <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
cargo = { path = "../.." }
9+
proptest = "0.9.1"
10+
lazy_static = "1.3.0"
11+
varisat = "0.2.1"
12+
atty = "0.2.11"

tests/testsuite/support/resolver.rs renamed to crates/resolver-tests/src/lib.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
44
use std::fmt;
55
use std::time::Instant;
66

7-
use crate::support::slow_cpu_multiplier;
8-
97
use cargo::core::dependency::Kind;
108
use cargo::core::resolver::{self, Method};
119
use cargo::core::source::{GitReference, SourceId};
@@ -16,9 +14,7 @@ use cargo::util::{CargoResult, Config, Graph, ToUrl};
1614
use proptest::collection::{btree_map, vec};
1715
use proptest::prelude::*;
1816
use proptest::sample::Index;
19-
use proptest::strategy::ValueTree;
2017
use proptest::string::string_regex;
21-
use proptest::test_runner::TestRunner;
2218
use varisat::{self, ExtendFormula};
2319

2420
pub fn resolve(
@@ -182,7 +178,7 @@ pub fn resolve_with_config_raw(
182178

183179
// The largest test in our suite takes less then 30 sec.
184180
// So lets fail the test if we have ben running for two long.
185-
assert!(start.elapsed() < slow_cpu_multiplier(60));
181+
assert!(start.elapsed().as_secs() < 60);
186182
resolve
187183
}
188184

@@ -493,14 +489,15 @@ impl<T: AsRef<str>, U: AsRef<str>> ToPkgId for (T, U) {
493489
}
494490
}
495491

492+
#[macro_export]
496493
macro_rules! pkg {
497494
($pkgid:expr => [$($deps:expr),+ $(,)* ]) => ({
498495
let d: Vec<Dependency> = vec![$($deps.to_dep()),+];
499-
pkg_dep($pkgid, d)
496+
$crate::pkg_dep($pkgid, d)
500497
});
501498

502499
($pkgid:expr) => ({
503-
pkg($pkgid)
500+
$crate::pkg($pkgid)
504501
})
505502
}
506503

@@ -663,7 +660,7 @@ impl fmt::Debug for PrettyPrintRegistry {
663660
}
664661
}
665662

666-
#[cargo_test]
663+
#[test]
667664
fn meta_test_deep_pretty_print_registry() {
668665
assert_eq!(
669666
&format!(
@@ -839,8 +836,11 @@ pub fn registry_strategy(
839836

840837
/// This test is to test the generator to ensure
841838
/// that it makes registries with large dependency trees
842-
#[cargo_test]
839+
#[test]
843840
fn meta_test_deep_trees_from_strategy() {
841+
use proptest::strategy::ValueTree;
842+
use proptest::test_runner::TestRunner;
843+
844844
let mut dis = [0; 21];
845845

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

879879
/// This test is to test the generator to ensure
880880
/// that it makes registries that include multiple versions of the same library
881-
#[cargo_test]
881+
#[test]
882882
fn meta_test_multiple_versions_strategy() {
883+
use proptest::strategy::ValueTree;
884+
use proptest::test_runner::TestRunner;
885+
883886
let mut dis = [0; 10];
884887

885888
let strategy = registry_strategy(50, 20, 60);

0 commit comments

Comments
 (0)