Skip to content

Commit b94e9a0

Browse files
committed
difftest: move lib into tests workspace, move mod config to new crate types, massive difftest speedup 36s -> 6s
1 parent 537222d commit b94e9a0

File tree

26 files changed

+699
-73
lines changed

26 files changed

+699
-73
lines changed

.config/nextest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ fail-fast = false
66
default-filter = 'package(difftests)'
77

88
[profile.difftest-runner]
9-
default-filter = 'package(difftest-runner) | package(difftest)'
9+
default-filter = 'package(difftest-runner) | package(difftest-types)'

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
- name: cargo fetch --locked difftests
191191
run: cargo fetch --locked --manifest-path=tests/difftests/tests/Cargo.toml --target $TARGET
192192
- name: test difftest-runner
193-
run: cargo nextest run -P difftest-runner -p difftest-runner -p difftest --release --no-default-features --features "use-installed-tools"
193+
run: cargo nextest run -P difftest-runner -p difftest-runner -p difftest-types --release --no-default-features --features "use-installed-tools"
194194
- name: difftests
195195
run: cargo nextest run -P difftests -p difftests --release --no-default-features --features "use-installed-tools"
196196

.github/workflows/lint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ clippy_no_features examples/shaders/reduce
4949

5050
# tests
5151
clippy tests/compiletests
52+
clippy_no_features tests/difftests/types
53+
clippy tests/difftests/runner
5254
clippy tests/difftests/bin
53-
clippy tests/difftests/lib
55+
clippy tests/difftests/tests/lib
5456

5557
# Custom lints
5658

Cargo.lock

Lines changed: 10 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ members = [
2929
"tests/compiletests/deps-helper",
3030
"tests/difftests/bin",
3131
"tests/difftests/runner",
32-
"tests/difftests/lib",
32+
"tests/difftests/types",
3333
]
3434

3535
[workspace.package]

tests/difftests/runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ thiserror = "1.0"
2323
toml = { version = "0.8.20", default-features = false, features = ["parse"] }
2424
bytesize = "2.0.1"
2525
bytemuck = "1.21.0"
26-
difftest = { path = "../lib" }
26+
difftest-types = { path = "../types" }
2727
tabled = { version = "0.15", default-features = false, features = ["std"] }
2828

2929
[dev-dependencies]

tests/difftests/runner/src/differ.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::unimplemented)]
22

3-
use difftest::config::OutputType;
3+
use difftest_types::config::OutputType;
44
use std::marker::PhantomData;
55

66
/// Represents the magnitude of a difference between two values

tests/difftests/runner/src/runner.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use bytesize::ByteSize;
2-
use difftest::config::{OutputType, TestMetadata};
2+
use difftest_types::config::{OutputType, TestMetadata};
33
use serde::{Deserialize, Serialize};
4+
use std::process::Stdio;
45
use std::{
56
collections::{HashMap, HashSet},
67
fs,
@@ -288,6 +289,8 @@ impl Runner {
288289

289290
let output = cmd
290291
.current_dir(&package.absolute_path)
292+
.stdout(Stdio::inherit())
293+
.stderr(Stdio::inherit())
291294
.output()
292295
.map_err(|e| RunnerError::Io { source: e })?;
293296
let exit_code = output.status.code().unwrap_or(-1);
@@ -651,7 +654,7 @@ pub fn forward_features(cmd: &mut Command) {
651654
#[cfg(test)]
652655
mod tests {
653656
use super::*;
654-
use difftest::config::OutputType;
657+
use difftest_types::config::OutputType;
655658
use std::{fs, io::Write, path::Path, path::PathBuf};
656659
use tempfile::{NamedTempFile, tempdir};
657660

@@ -862,8 +865,7 @@ mod tests {
862865
fn test_invalid_metadata_json() {
863866
// Test that invalid JSON in metadata file causes proper error
864867
let metadata_content = "{ invalid json }";
865-
let result: Result<difftest::config::TestMetadata, _> =
866-
serde_json::from_str(metadata_content);
868+
let result: Result<TestMetadata, _> = serde_json::from_str(metadata_content);
867869
assert!(result.is_err());
868870
// Just check that it's an error, don't check the specific message
869871
}

tests/difftests/runner/src/testcase.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::runner::RunnerResult;
2+
use std::ffi::OsStr;
23
use std::fmt::{Display, Formatter};
34
use std::fs;
45
use std::path::{Path, PathBuf};
@@ -47,6 +48,14 @@ impl TestCase {
4748
for entry in fs::read_dir(&self.absolute_path)? {
4849
let entry = entry?;
4950
let path = entry.path();
51+
let relative_path = self.relative_path.join(entry.file_name());
52+
if IGNORE_DIR_LIST
53+
.iter()
54+
.any(|dir| relative_path.as_os_str() == OsStr::new(dir))
55+
{
56+
debug!("Ignoring test binary: {}", path.display());
57+
return Ok(());
58+
}
5059
if path.is_dir() && path.join("Cargo.toml").exists() {
5160
debug!("Found binary package candidate: {}", path.display());
5261
self.test_binaries
@@ -93,11 +102,17 @@ impl Display for TestBinary {
93102
}
94103
}
95104

105+
/// List of paths relative to `./tests/difftests/tests/` to ignore
106+
pub const IGNORE_DIR_LIST: &[&str] = &["target", "lib"];
107+
96108
pub fn collect_test_dirs(root: &Path) -> RunnerResult<Vec<TestCase>> {
97109
fn recurse(root: &Path, traverse: &Path, test_cases: &mut Vec<TestCase>) -> RunnerResult<()> {
98110
let absolute_path = root.join(traverse);
99-
// skip target dir
100-
if absolute_path.file_name() == Some(std::ffi::OsStr::new("target")) {
111+
if IGNORE_DIR_LIST
112+
.iter()
113+
.any(|dir| traverse.as_os_str() == OsStr::new(dir))
114+
{
115+
debug!("Ignoring path: {}", absolute_path.display());
101116
return Ok(());
102117
}
103118

0 commit comments

Comments
 (0)