Skip to content

Commit

Permalink
Build test indexes in parallel using rayon.
Browse files Browse the repository at this point in the history
`rayon` is already a transitive dependency for us. Add it as a dev-dependency and use it when deserializing rustdoc and building indexes.

This saves a few more seconds per `cargo test` run.
  • Loading branch information
obi1kenobi committed Dec 1, 2024
1 parent 02ad2c8 commit 8c26bd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ predicates = "3.1.2"
insta = { version = "1.40.0", features = ["ron", "filters", "toml"] }
regex = "1.10.6"
insta-cmd = "0.6.0"
rayon = "1.10.0"

# In dev and test profiles, compile all dependencies with optimizations enabled,
# but still checking debug assertions and overflows.
Expand Down
5 changes: 3 additions & 2 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ mod tests {
use trustfall_rustdoc::{
load_rustdoc, VersionedIndex, VersionedRustdocAdapter, VersionedStorage,

Check warning on line 339 in src/query.rs

View workflow job for this annotation

GitHub Actions / Check lint and rustfmt

Diff in /home/runner/work/cargo-semver-checks/cargo-semver-checks/semver/src/query.rs
};
use rayon::prelude::*;

use crate::query::{
InheritedValue, LintLevel, OverrideMap, OverrideStack, QueryOverride, RequiredSemverUpdate,
Expand Down Expand Up @@ -418,7 +419,7 @@ mod tests {

fn initialize_test_crate_rustdocs() -> BTreeMap<String, (VersionedStorage, VersionedStorage)> {
get_test_crate_names()
.iter()
.par_iter()
.map(|crate_pair| {
let old_rustdoc = load_pregenerated_rustdoc(crate_pair.as_str(), "old");
let new_rustdoc = load_pregenerated_rustdoc(crate_pair, "new");
Expand All @@ -431,7 +432,7 @@ mod tests {
fn initialize_test_crate_indexes(
) -> BTreeMap<String, (VersionedIndex<'static>, VersionedIndex<'static>)> {
get_all_test_crates()
.iter()
.par_iter()
.map(|(key, (old_crate, new_crate))| {
let old_index = VersionedIndex::from_storage(old_crate);
let new_index = VersionedIndex::from_storage(new_crate);
Expand Down

0 comments on commit 8c26bd9

Please sign in to comment.