Skip to content

Commit

Permalink
tests: split lib/tests to separate create
Browse files Browse the repository at this point in the history
This breaks dev-dependency cycle: jj-lib -> testutils -> jj-lib.

I put Cargo.toml in lib/tests so the directory structure looks familiar. I'm
not sure if this layout is common, but I found this pattern in gix.
  • Loading branch information
yuja committed Dec 4, 2024
1 parent 68abf3c commit d9c251e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 10 deletions.
26 changes: 25 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ cargo-features = []

[workspace]
resolver = "2"
members = ["cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"]
members = [
"cli",
"lib",
"lib/gen-protos",
"lib/proc-macros",
"lib/tests",
"lib/testutils",
]

[workspace.package]
version = "0.24.0"
Expand Down
5 changes: 0 additions & 5 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ include = [
"/LICENSE",
"/benches/",
"/src/",
"/tests/",
"!*.pending-snap",
"!*.snap*",
]


[[test]]
name = "runner"

[[bench]]
name = "diff_bench"
harness = false
Expand Down Expand Up @@ -92,7 +88,6 @@ num_cpus = { workspace = true }
pretty_assertions = { workspace = true }
sapling-renderdag = { workspace = true }
test-case = { workspace = true }
testutils = { workspace = true }
tokio = { workspace = true, features = ["full"] }

[features]
Expand Down
42 changes: 42 additions & 0 deletions lib/tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "jj-lib-tests"
description = "Integration tests for the jj-lib crate"
autotests = false
publish = false

version = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
license = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
documentation = { workspace = true }
readme = { workspace = true }

[[test]]
name = "runner"
path = "runner.rs"

[dev-dependencies]
assert_matches = { workspace = true }
chrono = { workspace = true }
config = { workspace = true }
futures = { workspace = true }
git2 = { workspace = true }
gix = { workspace = true }
hex = { workspace = true }
indoc = { workspace = true }
insta = { workspace = true }
itertools = { workspace = true }
jj-lib = { workspace = true, features = ["testing"] }
maplit = { workspace = true }
num_cpus = { workspace = true }
pollster = { workspace = true }
pretty_assertions = { workspace = true }
rand = { workspace = true }
tempfile = { workspace = true }
test-case = { workspace = true }
testutils = { workspace = true }

[lints]
workspace = true
6 changes: 3 additions & 3 deletions lib/tests/runner.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::path::PathBuf;
use std::path::Path;

#[test]
fn test_no_forgotten_test_files() {
let test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests");
testutils::assert_no_forgotten_test_files(&test_dir);
let test_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
testutils::assert_no_forgotten_test_files(test_dir);
}

mod test_annotate;
Expand Down

0 comments on commit d9c251e

Please sign in to comment.