Skip to content

Commit

Permalink
docs(scm-bisect): add doc-comments to scm_bisect::testing
Browse files Browse the repository at this point in the history
`cargo clippy` was failing in this CI run: https://github.com/arxanas/git-branchless/actions/runs/12127041277?pr=1460

Actually, I have no idea how it even resulted in this. If I understand correctly, `cfg(test)` shouldn't even be enabled here, so the `testing` module shouldn't even be checked. I was unable to reproduce the issue locally on `1.74.1` and `nightly`. Possibly it's something non-deterministic that depends on the order that crates were compiled, or some other caching issue.

Regardless, it seems fine to add the doc-comments, so I've added them and now hope that CI will pass.
  • Loading branch information
arxanas committed Dec 2, 2024
1 parent b3303a3 commit a321abc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scm-bisect/src/testing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Testing utilities.
use std::collections::{HashMap, HashSet};
use std::convert::Infallible;

Expand All @@ -7,8 +9,12 @@ use proptest::prelude::*;

use crate::basic::{BasicSourceControlGraph, BasicStrategyKind};

/// Graph that represents a "stick" of nodes, represented as increasing
/// integers. The node `n` is the immediate parent of `n + 1`.
#[derive(Clone, Debug)]
pub struct UsizeGraph {
/// The maximum node value for this graph. Valid nodes are in `0..max` (a
/// half-open [`std::ops::Range`]).
pub max: usize,
}

Expand All @@ -27,8 +33,10 @@ impl BasicSourceControlGraph for UsizeGraph {
}
}

/// Directed acyclic graph with nodes `char` and edges `char -> char`.
#[derive(Clone, Debug)]
pub struct TestGraph {
/// Mapping from parent to children.
pub nodes: HashMap<char, HashSet<char>>,
}

Expand Down Expand Up @@ -57,6 +65,7 @@ impl BasicSourceControlGraph for TestGraph {
}
}

/// Select an arbitrary [`BasicStrategyKind`].
pub fn arb_strategy() -> impl ProptestStrategy<Value = BasicStrategyKind> {
prop_oneof![
Just(BasicStrategyKind::Linear),
Expand All @@ -65,6 +74,7 @@ pub fn arb_strategy() -> impl ProptestStrategy<Value = BasicStrategyKind> {
]
}

/// Create an arbitrary [`TestGraph`] and an arbitrary set of failing nodes.
pub fn arb_test_graph_and_nodes() -> impl ProptestStrategy<Value = (TestGraph, Vec<char>)> {
let nodes = prop::collection::hash_set(
prop::sample::select(vec!['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']),
Expand Down

0 comments on commit a321abc

Please sign in to comment.