Skip to content

Commit

Permalink
[guppy] prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers committed Jun 26, 2023
1 parent 149c6e3 commit a34a713
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 43 deletions.
4 changes: 2 additions & 2 deletions guppy-cmdlib/src/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ impl PackagesAndFeatures {
let workspace = graph.workspace();
(
// The lower bound of 0 is important because 0 means the whole workspace.
hash_set(workspace.prop010_name_strategy(), 0..8),
hash_set(workspace.proptest1_name_strategy(), 0..8),
any::<bool>(),
any::<bool>(),
// The lower bound of 0 is important here as well, because 0 means none.
// (This is at the end to avoid perturbing previously-generated values of all_features
// and no_default_features.)
hash_set(workspace.prop010_name_strategy(), 0..4),
hash_set(workspace.proptest1_name_strategy(), 0..4),
)
.prop_map(
move |(packages, all_features, no_default_features, features_only)| {
Expand Down
11 changes: 11 additions & 0 deletions guppy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.17.0] - 2023-06-25

### Changed

- `target-spec` updated to version 3.

### Fixed

- Proptest strategy creator names updated from `prop010_` to `proptest1_`.

## [0.16.0] - 2023-06-19

### Changed
Expand Down Expand Up @@ -556,6 +566,7 @@ lazy_static = "0.2"
### Added
- Initial release.

[0.17.0]: https://github.com/guppy-rs/guppy/releases/tag/guppy-0.17.0
[0.16.0]: https://github.com/guppy-rs/guppy/releases/tag/guppy-0.16.0
[0.15.2]: https://github.com/guppy-rs/guppy/releases/tag/guppy-0.15.2
[0.15.1]: https://github.com/guppy-rs/guppy/releases/tag/guppy-0.15.1
Expand Down
4 changes: 2 additions & 2 deletions guppy/src/graph/feature/proptest_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'g> FeatureGraph<'g> {
///
/// Panics if there are no packages in the `PackageGraph` from which this `FeatureGraph` was
/// derived.
pub fn prop010_id_strategy(&self) -> impl Strategy<Value = FeatureId<'g>> + 'g {
pub fn proptest1_id_strategy(&self) -> impl Strategy<Value = FeatureId<'g>> + 'g {
let dep_graph = self.dep_graph();
let package_graph = self.package_graph;
any::<prop::sample::Index>().prop_map(move |index| {
Expand All @@ -37,7 +37,7 @@ impl<'g> FeatureGraph<'g> {
}

/// Returns a `Strategy` that generates random feature sets from this graph.
pub fn prop010_set_strategy(&self) -> impl Strategy<Value = FeatureSet<'g>> + 'g {
pub fn proptest1_set_strategy(&self) -> impl Strategy<Value = FeatureSet<'g>> + 'g {
let this = *self;
fixedbitset_strategy(self.feature_count())
.prop_map(move |included| FeatureSet::from_included(this, included))
Expand Down
18 changes: 9 additions & 9 deletions guppy/src/graph/proptest_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl PackageGraph {
/// ## Panics
///
/// Panics if there are no packages in this `PackageGraph`.
pub fn prop010_id_strategy(&self) -> impl Strategy<Value = &PackageId> {
pub fn proptest1_id_strategy(&self) -> impl Strategy<Value = &PackageId> {
let dep_graph = &self.dep_graph;
any::<prop::sample::Index>().prop_map(move |index| {
let package_ix = NodeIndex::new(index.index(dep_graph.node_count()));
Expand All @@ -46,7 +46,7 @@ impl PackageGraph {
/// ## Panics
///
/// Panics if there are no dependency edges in this `PackageGraph`.
pub fn prop010_link_strategy(&self) -> impl Strategy<Value = PackageLink<'_>> {
pub fn proptest1_link_strategy(&self) -> impl Strategy<Value = PackageLink<'_>> {
any::<prop::sample::Index>().prop_map(move |index| {
// Note that this works because PackageGraph uses petgraph::Graph, not StableGraph. If
// PackageGraph used StableGraph, a retain_edges call would create holes -- invalid
Expand All @@ -60,16 +60,16 @@ impl PackageGraph {
/// Returns a `Strategy` that generates a random `PackageResolver` instance from this graph.
///
/// Requires the `proptest1` feature to be enabled.
pub fn prop010_resolver_strategy(&self) -> impl Strategy<Value = Prop010Resolver> {
pub fn proptest1_resolver_strategy(&self) -> impl Strategy<Value = Prop010Resolver> {
// Generate a FixedBitSet to filter based off of.
fixedbitset_strategy(self.dep_graph.edge_count()).prop_map(Prop010Resolver::new)
}

/// Returns a `Strategy` that generates a random `CargoOptions` from this graph.
///
/// Requires the `proptest1` feature to be enabled.
pub fn prop010_cargo_options_strategy(&self) -> impl Strategy<Value = CargoOptions<'_>> {
let omitted_packages = hash_set(self.prop010_id_strategy(), 0..4);
pub fn proptest1_cargo_options_strategy(&self) -> impl Strategy<Value = CargoOptions<'_>> {
let omitted_packages = hash_set(self.proptest1_id_strategy(), 0..4);
(
any::<CargoResolverVersion>(),
any::<bool>(),
Expand Down Expand Up @@ -116,7 +116,7 @@ impl<'g> Workspace<'g> {
/// ## Panics
///
/// Panics if there are no packages in this `Workspace`.
pub fn prop010_name_strategy(&self) -> impl Strategy<Value = &'g str> + 'g {
pub fn proptest1_name_strategy(&self) -> impl Strategy<Value = &'g str> + 'g {
let name_list = self.name_list();
(0..name_list.len()).prop_map(move |idx| name_list[idx].as_ref())
}
Expand All @@ -128,9 +128,9 @@ impl<'g> Workspace<'g> {
/// ## Panics
///
/// Panics if there are no packages in this `Workspace`.
pub fn prop010_id_strategy(&self) -> impl Strategy<Value = &'g PackageId> + 'g {
pub fn proptest1_id_strategy(&self) -> impl Strategy<Value = &'g PackageId> + 'g {
let members_by_name = &self.inner.members_by_name;
self.prop010_name_strategy()
self.proptest1_name_strategy()
.prop_map(move |name| &members_by_name[name])
}

Expand All @@ -143,7 +143,7 @@ impl<'g> Workspace<'g> {

/// A randomly generated package resolver.
///
/// Created by `PackageGraph::prop010_resolver_strategy`. Requires the `proptest1` feature to be
/// Created by `PackageGraph::proptest1_resolver_strategy`. Requires the `proptest1` feature to be
/// enabled.
#[derive(Clone, Debug)]
pub struct Prop010Resolver {
Expand Down
44 changes: 22 additions & 22 deletions guppy/tests/graph-tests/proptest_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! proptest_suite {
let fixture = JsonFixture::$name();
let graph = fixture.graph();

proptest!(|(package_id in graph.prop010_id_strategy())| {
proptest!(|(package_id in graph.proptest1_id_strategy())| {
let package = graph.metadata(package_id).expect("valid package ID");
let summary_id = package.to_summary_id();
let package2 = graph.metadata_by_summary_id(&summary_id).expect("summary ID is valid");
Expand All @@ -42,7 +42,7 @@ macro_rules! proptest_suite {
let graph = fixture.graph();

proptest!(|(
ids in vec(graph.prop010_id_strategy(), 1..16),
ids in vec(graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
iter_direction in any::<DependencyDirection>(),
query_indexes in vec(any::<Index>(), 0..16),
Expand All @@ -58,7 +58,7 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
ids in vec(feature_graph.prop010_id_strategy(), 1..16),
ids in vec(feature_graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
iter_direction in any::<DependencyDirection>(),
query_indexes in vec(any::<Index>(), 0..16),
Expand All @@ -72,7 +72,7 @@ macro_rules! proptest_suite {
let fixture = JsonFixture::$name();
let package_graph = fixture.graph();

proptest!(|(query_id in package_graph.prop010_id_strategy())| {
proptest!(|(query_id in package_graph.proptest1_id_strategy())| {
depends_on_same_id(package_graph, query_id);
});
}
Expand All @@ -83,7 +83,7 @@ macro_rules! proptest_suite {
let package_graph = fixture.graph();
let feature_graph = package_graph.feature_graph();

proptest!(|(query_id in feature_graph.prop010_id_strategy())| {
proptest!(|(query_id in feature_graph.proptest1_id_strategy())| {
depends_on_same_id(feature_graph, query_id);
});
}
Expand All @@ -94,7 +94,7 @@ macro_rules! proptest_suite {
let graph = fixture.graph();

proptest!(|(
ids in vec(graph.prop010_id_strategy(), 1..16),
ids in vec(graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
iter_direction in any::<DependencyDirection>(),
)| {
Expand All @@ -108,7 +108,7 @@ macro_rules! proptest_suite {
let graph = fixture.graph();

proptest!(|(
ids in vec(graph.prop010_id_strategy(), 1..16),
ids in vec(graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
iter_direction in any::<DependencyDirection>(),
query_indexes in vec((any::<Index>(), any::<Index>()), 0..128),
Expand All @@ -131,7 +131,7 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
ids in vec(feature_graph.prop010_id_strategy(), 1..16),
ids in vec(feature_graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
iter_direction in any::<DependencyDirection>(),
query_indexes in vec((any::<Index>(), any::<Index>()), 0..128),
Expand All @@ -153,9 +153,9 @@ macro_rules! proptest_suite {
let package_graph = fixture.graph();

proptest!(|(
query_ids in vec(package_graph.prop010_id_strategy(), 1..16),
query_ids in vec(package_graph.proptest1_id_strategy(), 1..16),
direction in any::<DependencyDirection>(),
test_ids in vec(package_graph.prop010_id_strategy(), 0..64),
test_ids in vec(package_graph.proptest1_id_strategy(), 0..64),
)| {
resolve_contains(package_graph, &query_ids, direction, &test_ids);
});
Expand All @@ -168,9 +168,9 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
query_ids in vec(feature_graph.prop010_id_strategy(), 1..16),
query_ids in vec(feature_graph.proptest1_id_strategy(), 1..16),
direction in any::<DependencyDirection>(),
test_ids in vec(feature_graph.prop010_id_strategy(), 0..64),
test_ids in vec(feature_graph.proptest1_id_strategy(), 0..64),
)| {
resolve_contains(feature_graph, &query_ids, direction, &test_ids);
});
Expand All @@ -182,7 +182,7 @@ macro_rules! proptest_suite {
let package_graph = fixture.graph();

proptest!(|(
resolve_tree in ResolveTree::strategy(package_graph.prop010_id_strategy())
resolve_tree in ResolveTree::strategy(package_graph.proptest1_id_strategy())
)| {
resolve_ops(package_graph, resolve_tree);
});
Expand All @@ -195,7 +195,7 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
resolve_tree in ResolveTree::strategy(feature_graph.prop010_id_strategy())
resolve_tree in ResolveTree::strategy(feature_graph.proptest1_id_strategy())
)| {
resolve_ops(feature_graph, resolve_tree);
});
Expand All @@ -208,10 +208,10 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
query_ids in vec(package_graph.prop010_id_strategy(), 1..16),
query_ids in vec(package_graph.proptest1_id_strategy(), 1..16),
query_direction in any::<DependencyDirection>(),
mut resolver in package_graph.prop010_resolver_strategy(),
test_ids in vec(feature_graph.prop010_id_strategy(), 1..16),
mut resolver in package_graph.proptest1_resolver_strategy(),
test_ids in vec(feature_graph.proptest1_id_strategy(), 1..16),
test_direction in any::<DependencyDirection>(),
)| {
resolver.check_depends_on(true);
Expand All @@ -226,7 +226,7 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
feature_set in feature_graph.prop010_set_strategy(),
feature_set in feature_graph.proptest1_set_strategy(),
direction in any::<DependencyDirection>(),
)| {
feature_set_props(feature_set, direction);
Expand All @@ -239,9 +239,9 @@ macro_rules! proptest_suite {
let package_graph = fixture.graph();

proptest!(|(
query_ids in hash_set(package_graph.prop010_id_strategy(), 0..16),
query_ids in hash_set(package_graph.proptest1_id_strategy(), 0..16),
direction in any::<DependencyDirection>(),
test_ids in vec(package_graph.prop010_id_strategy(), 0..16)
test_ids in vec(package_graph.proptest1_id_strategy(), 0..16)
)| {
query_starts_from(package_graph, query_ids, direction, test_ids);
});
Expand All @@ -254,9 +254,9 @@ macro_rules! proptest_suite {
let feature_graph = package_graph.feature_graph();

proptest!(|(
query_ids in hash_set(feature_graph.prop010_id_strategy(), 0..16),
query_ids in hash_set(feature_graph.proptest1_id_strategy(), 0..16),
direction in any::<DependencyDirection>(),
test_ids in vec(feature_graph.prop010_id_strategy(), 0..16)
test_ids in vec(feature_graph.proptest1_id_strategy(), 0..16)
)| {
query_starts_from(feature_graph, query_ids, direction, test_ids);
});
Expand Down
4 changes: 2 additions & 2 deletions internal-tools/benchmarks/benches/package_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn make_package_name_hashmap<'g>(
/// Generate pairs of IDs for benchmarks.
fn id_pairs_strategy(graph: &PackageGraph) -> impl Strategy<Value = Vec<(&PackageId, &PackageId)>> {
vec(
(graph.prop010_id_strategy(), graph.prop010_id_strategy()),
(graph.proptest1_id_strategy(), graph.proptest1_id_strategy()),
256,
)
}
Expand All @@ -124,7 +124,7 @@ fn ids_directions_strategy(
) -> impl Strategy<Value = Vec<(Vec<&PackageId>, DependencyDirection, DependencyDirection)>> {
vec(
(
vec(graph.prop010_id_strategy(), 32),
vec(graph.proptest1_id_strategy(), 32),
any::<DependencyDirection>(),
any::<DependencyDirection>(),
),
Expand Down
2 changes: 1 addition & 1 deletion internal-tools/fixture-manager/src/summaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'g> ContextImpl<'g> for SummaryContext {
let graph = fixture.graph();

let packages_features_strategy = PackagesAndFeatures::strategy(graph);
let cargo_opts_strategy = graph.prop010_cargo_options_strategy();
let cargo_opts_strategy = graph.proptest1_cargo_options_strategy();

let iter = (0..count).map(move |idx| {
// The partial clones mean that e.g. a change to the algorithm in
Expand Down
10 changes: 5 additions & 5 deletions tools/hakari/src/proptest_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl<'g> HakariBuilder<'g> {
hakari_id_strategy,
vec(Platform::strategy(any::<TargetFeatures>()), 0..4),
any::<CargoResolverVersion>(),
hash_set(graph.prop010_id_strategy(), 0..8),
hash_set(graph.prop010_id_strategy(), 0..8),
hash_set(graph.proptest1_id_strategy(), 0..8),
hash_set(graph.proptest1_id_strategy(), 0..8),
any::<UnifyTargetHost>(),
any::<bool>(),
any::<DepFormatVersion>(),
Expand Down Expand Up @@ -91,7 +91,7 @@ mod test {
let workspace = graph.workspace();
let strategy = HakariBuilder::proptest1_strategy(
graph,
option::of(workspace.prop010_id_strategy()),
option::of(workspace.proptest1_id_strategy()),
);
proptest!(|(builder in strategy)| {
let summary = builder.to_summary().unwrap_or_else(|err| {
Expand All @@ -116,9 +116,9 @@ mod test {
let workspace = graph.workspace();
let strategy = HakariBuilder::proptest1_strategy(
graph,
option::of(workspace.prop010_id_strategy()),
option::of(workspace.proptest1_id_strategy()),
);
proptest!(|(builder in strategy, queries in vec(graph.prop010_id_strategy(), 0..64))| {
proptest!(|(builder in strategy, queries in vec(graph.proptest1_id_strategy(), 0..64))| {
// Ensure that the hakari package is omitted.
if let Some(package) = builder.hakari_package() {
assert!(
Expand Down

0 comments on commit a34a713

Please sign in to comment.