Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract resolver tests to their own crate #7011

Merged
merged 2 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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 <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"
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove slow_cpu_multiplier? Do we think that the other people (#6491) running Cargos CI will not run these tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a big chunk of code to migrate that didn't really seem worth it. The workaround can always be re-added if still necessary.

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