This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cargo-compare] add some comparison testing to CI
This works by: * setting up a real, fairly complex fixture * generating random queries using proptest * running them through cargo and guppy * ensuring that they produce the same results Not only does this give us high confidence that cargo and guppy produce the same results, it also gets us most of the way to #82. Most of the work in this commit is simply setting up all the necessary test infrastructure. We piggy-back on existing proptest infrastructure as much as possible.
- Loading branch information
1 parent
679f41e
commit 5c44f20
Showing
36 changed files
with
538 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "external" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
transitive = { path = "../transitive" } | ||
bytes = { version = "0.5", optional = true } | ||
|
||
[dev-dependencies] | ||
transitive = { path = "../transitive", features = ["dev-feature"] } | ||
|
||
[build-dependencies] | ||
transitive = { path = "../transitive", features = ["build-feature"] } | ||
|
||
[features] | ||
internal-dev-feature = [] | ||
internal-build-feature = [] | ||
main-dev-feature = [] | ||
main-build-feature = [] | ||
side-feature = ["bytes"] | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "inactive" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
transitive = { path = "../transitive", features = ["inactive-normal"] } | ||
|
||
[build-dependencies] | ||
transitive = { path = "../transitive", features = ["inactive-build"] } | ||
|
||
[dev-dependencies] | ||
transitive = { path = "../transitive", features = ["inactive-dev"] } | ||
|
||
[features] | ||
extra = ["transitive/extra"] | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "transitive" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
build-feature = [] | ||
dev-feature = [] | ||
inactive-normal = [] | ||
inactive-build = [] | ||
inactive-dev = [] | ||
extra = [] | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[workspace] | ||
members = ["main", "internal", "side"] |
23 changes: 23 additions & 0 deletions
23
fixtures/workspace/inside-outside/workspace/internal/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "internal" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
lazy_static = "1" | ||
external = { path = "../../external" } | ||
|
||
[dev-dependencies] | ||
lazy_static = {version = "1", features = ["spin"] } | ||
bytes = "0.5" | ||
external = { path = "../../external", features = ["internal-dev-feature"] } | ||
|
||
[build-dependencies] | ||
external = { path = "../../external", features = ["internal-build-feature"] } | ||
|
||
[features] | ||
dev-feature = [] | ||
build-feature = [] |
7 changes: 7 additions & 0 deletions
7
fixtures/workspace/inside-outside/workspace/internal/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
fixtures/workspace/inside-outside/workspace/main/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "main" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
build = "build.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
external = { path = "../../external" } | ||
internal = { path = "../internal" } | ||
|
||
[build-dependencies] | ||
external = { path = "../../external", features = ["main-build-feature"] } | ||
internal = { path = "../internal", features = ["build-feature"] } | ||
|
||
[dev-dependencies] | ||
external = { path = "../../external", features = ["main-dev-feature"] } | ||
internal = { path = "../internal", features = ["dev-feature"] } | ||
|
||
[target.'cfg(all(unix, not(unix)))'.build-dependencies] | ||
inactive = { path = "../../inactive" } | ||
|
||
[features] | ||
inactive-extra = ["inactive/extra"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
fixtures/workspace/inside-outside/workspace/side/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "side" | ||
version = "0.1.0" | ||
authors = ["Fake Author <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
external = { path = "../../external", features = ["side-feature"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) The cargo-guppy Contributors | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
//! Proptest support. | ||
use crate::PackagesAndFeatures; | ||
use guppy::graph::PackageGraph; | ||
use proptest::collection::hash_set; | ||
use proptest::prelude::*; | ||
|
||
impl PackagesAndFeatures { | ||
pub fn strategy<'g>(graph: &'g PackageGraph) -> impl Strategy<Value = Self> + 'g { | ||
let workspace = graph.workspace(); | ||
( | ||
// The lower bound of 0 is important because 0 means the whole workspace. | ||
hash_set(workspace.prop09_name_strategy(), 0..8), | ||
any::<bool>(), | ||
any::<bool>(), | ||
) | ||
.prop_map(move |(packages, all_features, no_default_features)| { | ||
// TODO: select features from these packages (probably requires flat_map :/ ) | ||
Self { | ||
packages: packages | ||
.into_iter() | ||
.map(|package| package.to_string()) | ||
.collect(), | ||
features: vec![], | ||
all_features, | ||
no_default_features, | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.