Skip to content
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
6 changes: 5 additions & 1 deletion crates/karva/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub(crate) fn test(args: TestCommand) -> Result<ExitStatus> {
let sub_command = args.sub_command.clone();

let no_parallel = args.no_parallel.unwrap_or(false);
let no_cache = args.no_cache.unwrap_or(false);
let num_workers = args.num_workers;

let project_options_overrides = ProjectOptionsOverrides::new(config_file, args.into_options());
Expand All @@ -116,7 +117,10 @@ pub(crate) fn test(args: TestCommand) -> Result<ExitStatus> {
num_workers.unwrap_or_else(|| karva_system::max_parallelism().get())
};

let config = karva_runner::ParallelTestConfig { num_workers };
let config = karva_runner::ParallelTestConfig {
num_workers,
no_cache,
};

let (shutdown_tx, shutdown_rx) = crossbeam_channel::unbounded();

Expand Down
5 changes: 4 additions & 1 deletion crates/karva_benchmark/src/walltime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ impl<'a> ProjectBenchmark<'a> {
fn test_project(project: &ProjectDatabase) {
let num_workers = karva_system::max_parallelism().get();

let config = karva_runner::ParallelTestConfig { num_workers };
let config = karva_runner::ParallelTestConfig {
num_workers,
no_cache: false,
};

let args = SubTestCommand {
no_ignore: Some(true),
Expand Down
4 changes: 4 additions & 0 deletions crates/karva_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ pub struct TestCommand {
/// Disable parallel execution
#[clap(long, default_missing_value = "true", num_args=0..1)]
pub no_parallel: Option<bool>,

/// Disable reading the karva cache for test duration history
#[clap(long, default_missing_value = "true", num_args=0..1)]
pub no_cache: Option<bool>,
}

impl TestCommand {
Expand Down
7 changes: 6 additions & 1 deletion crates/karva_runner/src/orchestration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl WorkerManager {

pub struct ParallelTestConfig {
pub num_workers: usize,
pub no_cache: bool,
}

/// Spawn worker processes for each partition
Expand Down Expand Up @@ -216,7 +217,11 @@ pub fn run_parallel_tests(
let cache_dir = db.system().current_directory().join(CACHE_DIR);

// Read durations from the most recent run to optimize partitioning
let previous_durations = read_recent_durations(&cache_dir).unwrap_or_default();
let previous_durations = if config.no_cache {
std::collections::HashMap::new()
} else {
read_recent_durations(&cache_dir).unwrap_or_default()
};

if !previous_durations.is_empty() {
tracing::debug!(
Expand Down
1 change: 1 addition & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ karva test [OPTIONS] [PATH]...
<p>May also be set with the <code>KARVA_CONFIG_FILE</code> environment variable.</p></dd><dt id="karva-test--fail-fast"><a href="#karva-test--fail-fast"><code>--fail-fast</code></a></dt><dd><p>When set, the test will fail immediately if any test fails.</p>
<p>This only works when running tests in parallel.</p>
</dd><dt id="karva-test--help"><a href="#karva-test--help"><code>--help</code></a>, <code>-h</code></dt><dd><p>Print help (see a summary with '-h')</p>
</dd><dt id="karva-test--no-cache"><a href="#karva-test--no-cache"><code>--no-cache</code></a></dt><dd><p>Disable reading the karva cache for test duration history</p>
</dd><dt id="karva-test--no-ignore"><a href="#karva-test--no-ignore"><code>--no-ignore</code></a></dt><dd><p>When set, .gitignore files will not be respected</p>
</dd><dt id="karva-test--no-parallel"><a href="#karva-test--no-parallel"><code>--no-parallel</code></a></dt><dd><p>Disable parallel execution</p>
</dd><dt id="karva-test--no-progress"><a href="#karva-test--no-progress"><code>--no-progress</code></a></dt><dd><p>When set, we will not show individual test case results during execution</p>
Expand Down
Loading