Skip to content

Commit 01c6ef6

Browse files
committed
chore: reorganize tests to get rid of feature toggles that are for internal testing only
1 parent 93feea2 commit 01c6ef6

File tree

12 files changed

+94
-60
lines changed

12 files changed

+94
-60
lines changed

Cargo.lock

Lines changed: 17 additions & 6 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ members = [
281281

282282
"gix-diff/tests",
283283
"gix-pack/tests",
284+
"gix-odb/tests",
284285
"gix-worktree-state/tests",
285286
"gix-status/tests",
286287
"gix-worktree/tests",

gix-odb/Cargo.toml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,15 @@ description = "Implements various git object databases"
88
edition = "2021"
99
include = ["src/**/*", "LICENSE-*", "CHANGELOG.md"]
1010
rust-version = "1.65"
11+
autotests = false
1112

1213
[lib]
1314
doctest = false
1415

1516
[features]
16-
internal-testing-gix-features-parallel = ["gix-features/parallel"]
1717
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
1818
serde= ["dep:serde", "gix-hash/serde", "gix-object/serde", "gix-pack/serde"]
1919

20-
[[test]]
21-
name = "multi-threaded"
22-
path = "tests/odb-multi-threaded.rs"
23-
required-features = ["internal-testing-gix-features-parallel"]
24-
25-
[[test]]
26-
name = "single-threaded"
27-
path = "tests/odb-single-threaded.rs"
28-
required-features = []
29-
3020
[dependencies]
3121
gix-features = { version = "^0.32.1", path = "../gix-features", features = ["rustsha1", "walkdir", "zlib", "crc32" ] }
3222
gix-hash = { version = "^0.11.4", path = "../gix-hash" }
@@ -44,13 +34,13 @@ arc-swap = "1.5.0"
4434

4535
document-features = { version = "0.2.0", optional = true }
4636

47-
[dev-dependencies]
48-
gix-testtools = { path = "../tests/tools"}
49-
gix-actor = { path = "../gix-actor" }
50-
pretty_assertions = "1.0.0"
51-
filetime = "0.2.15"
52-
maplit = "1.0.2"
53-
crossbeam-channel = "0.5.6"
37+
#[dev-dependencies]
38+
#gix-testtools = { path = "../tests/tools"}
39+
#gix-actor = { path = "../gix-actor" }
40+
#pretty_assertions = "1.0.0"
41+
#filetime = "0.2.15"
42+
#maplit = "1.0.2"
43+
#crossbeam-channel = "0.5.6"
5444

5545
[package.metadata.docs.rs]
5646
features = ["document-features", "serde"]

gix-odb/tests/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "gix-odb-tests"
3+
version = "0.0.0"
4+
repository = "https://github.com/Byron/gitoxide"
5+
authors = ["Sebastian Thiel <[email protected]>"]
6+
license = "MIT OR Apache-2.0"
7+
description = "Tests for gix-odb with feature-toggle support"
8+
edition = "2021"
9+
rust-version = "1.65"
10+
publish = false
11+
12+
[features]
13+
gix-features-parallel = ["gix-features/parallel"]
14+
15+
[[test]]
16+
name = "integrate"
17+
path = "integrate.rs"
18+
19+
[dev-dependencies]
20+
gix-odb = { path = ".." }
21+
gix-features = { path = "../../gix-features" }
22+
gix-hash = { version = "^0.11.4", path = "../../gix-hash" }
23+
gix-date = { version = "^0.7.2", path = "../../gix-date" }
24+
gix-object = { version = "^0.34.0", path = "../../gix-object" }
25+
gix-pack = { version = "^0.41.0", path = "../../gix-pack" }
26+
27+
gix-testtools = { path = "../../tests/tools"}
28+
gix-actor = { path = "../../gix-actor" }
29+
pretty_assertions = "1.0.0"
30+
filetime = "0.2.15"
31+
maplit = "1.0.2"
32+

gix-odb/tests/integrate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mod odb;
2+
use odb::*;

gix-odb/tests/odb-multi-threaded.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

gix-odb/tests/odb-single-threaded.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

gix-odb/tests/odb/find/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::fixture_path;
1+
use gix_testtools::fixture_path_standalone;
22

33
fn db() -> gix_odb::Handle {
4-
gix_odb::at(fixture_path("objects")).expect("valid object path")
4+
gix_odb::at(fixture_path_standalone("objects")).expect("valid object path")
55
}
66

77
use crate::hex_to_id;

gix-odb/tests/odb/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use gix_hash::ObjectId;
2+
use gix_testtools::fixture_path_standalone;
23
pub use gix_testtools::{fixture_path, scripted_fixture_read_only};
34

45
pub fn hex_to_id(hex: &str) -> ObjectId {
@@ -8,11 +9,11 @@ pub fn hex_to_id(hex: &str) -> ObjectId {
89
pub type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;
910

1011
fn db() -> gix_odb::Handle {
11-
gix_odb::at(fixture_path("objects")).expect("valid object path")
12+
gix_odb::at(fixture_path_standalone("objects")).expect("valid object path")
1213
}
1314

1415
fn db_small_packs() -> gix_odb::Handle {
15-
gix_odb::at(fixture_path("repos/small-packs.git/objects")).unwrap()
16+
gix_odb::at(fixture_path_standalone("repos/small-packs.git/objects")).unwrap()
1617
}
1718

1819
pub mod alternate;

gix-odb/tests/odb/store/dynamic.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::process::Command;
22

33
use gix_hash::ObjectId;
44
use gix_odb::{store, store::iter::Ordering, Find, FindExt, Header, Write};
5-
use gix_testtools::fixture_path;
5+
use gix_testtools::fixture_path_standalone;
66

77
use crate::{hex_to_id, odb::db};
88

@@ -14,18 +14,18 @@ fn all_orderings() -> [Ordering; 2] {
1414
}
1515

1616
/// indices, multi-pack-index, loose odb
17-
fn db_with_all_object_sources() -> crate::Result<(gix_odb::Handle, tempfile::TempDir)> {
17+
fn db_with_all_object_sources() -> crate::Result<(gix_odb::Handle, gix_testtools::tempfile::TempDir)> {
1818
let objects_dir = gix_testtools::tempfile::tempdir()?;
19-
gix_testtools::copy_recursively_into_existing_dir(fixture_path("objects"), &objects_dir)?;
19+
gix_testtools::copy_recursively_into_existing_dir(fixture_path_standalone("objects"), &objects_dir)?;
2020

2121
let multi_pack_index = std::fs::OpenOptions::new()
2222
.write(true)
2323
.create_new(true)
2424
.open(objects_dir.path().join("pack/multi-pack-index"))?;
2525
gix_odb::pack::multi_index::File::write_from_index_paths(
2626
vec![
27-
fixture_path("objects/pack/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx"),
28-
fixture_path("objects/pack/pack-c0438c19fb16422b6bbcce24387b3264416d485b.idx"),
27+
fixture_path_standalone("objects/pack/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx"),
28+
fixture_path_standalone("objects/pack/pack-c0438c19fb16422b6bbcce24387b3264416d485b.idx"),
2929
],
3030
multi_pack_index,
3131
gix_features::progress::Discard,
@@ -39,7 +39,7 @@ fn db_with_all_object_sources() -> crate::Result<(gix_odb::Handle, tempfile::Tem
3939

4040
#[test]
4141
fn multi_index_access() -> crate::Result {
42-
let dir = gix_testtools::scripted_fixture_writable("make_repo_multi_index.sh")?;
42+
let dir = gix_testtools::scripted_fixture_writable_standalone("make_repo_multi_index.sh")?;
4343
let handle = gix_odb::at(dir.path().join(".git/objects"))?;
4444

4545
assert_eq!(
@@ -145,7 +145,7 @@ fn multi_index_access() -> crate::Result {
145145

146146
#[test]
147147
fn multi_index_keep_open() -> crate::Result {
148-
let dir = gix_testtools::scripted_fixture_writable("make_repo_multi_index.sh")?;
148+
let dir = gix_testtools::scripted_fixture_writable_standalone("make_repo_multi_index.sh")?;
149149
let (stable_handle, handle) = {
150150
let mut stable_handle = gix_odb::at(dir.path().join(".git/objects"))?;
151151
let handle = stable_handle.clone();
@@ -210,7 +210,7 @@ fn multi_index_keep_open() -> crate::Result {
210210

211211
#[test]
212212
fn write() -> crate::Result {
213-
let dir = tempfile::tempdir()?;
213+
let dir = gix_testtools::tempfile::tempdir()?;
214214
let mut handle = gix_odb::at(dir.path())?;
215215
// It should refresh once even if the refresh mode is never, just to initialize the index
216216
handle.refresh_never();
@@ -222,7 +222,7 @@ fn write() -> crate::Result {
222222

223223
#[test]
224224
fn alternate_dbs_query() -> crate::Result {
225-
let dir = gix_testtools::scripted_fixture_read_only("make_alternates_odb.sh")?;
225+
let dir = gix_testtools::scripted_fixture_read_only_standalone("make_alternates_odb.sh")?;
226226
let handle = gix_odb::at(dir.join(".git/objects"))?;
227227

228228
let alternates = handle.store_ref().alternate_db_paths()?;
@@ -242,7 +242,7 @@ fn alternate_dbs_query() -> crate::Result {
242242

243243
#[test]
244244
fn object_replacement() -> crate::Result {
245-
let dir = gix_testtools::scripted_fixture_read_only("make_replaced_history.sh")?;
245+
let dir = gix_testtools::scripted_fixture_read_only_standalone("make_replaced_history.sh")?;
246246
let handle = gix_odb::at(dir.join(".git/objects"))?;
247247
let mut buf = Vec::new();
248248
let short_history_link = hex_to_id("434e5a872d6738d1fffd1e11e52a1840b73668c6");
@@ -797,7 +797,10 @@ fn auto_refresh_with_and_without_id_stability() -> crate::Result {
797797
.success(),
798798
"git should work"
799799
);
800-
gix_testtools::copy_recursively_into_existing_dir(fixture_path("objects/pack"), tmp.path().join("objects/pack"))?;
800+
gix_testtools::copy_recursively_into_existing_dir(
801+
fixture_path_standalone("objects/pack"),
802+
tmp.path().join("objects/pack"),
803+
)?;
801804
let hide_pack = |name: &str| {
802805
let stem = tmp.path().join("objects/pack").join(name);
803806
std::fs::rename(stem.with_extension("idx"), stem.with_extension("idx.bak")).unwrap();
@@ -940,7 +943,7 @@ mod verify {
940943
use std::sync::atomic::AtomicBool;
941944

942945
use gix_features::progress;
943-
use gix_testtools::fixture_path;
946+
use gix_testtools::fixture_path_standalone;
944947

945948
use crate::store::dynamic::db;
946949

@@ -954,20 +957,20 @@ mod verify {
954957
assert_eq!(outcome.index_statistics.len(), 3, "there are only three packs to check");
955958
assert_eq!(
956959
outcome.index_statistics[0].path,
957-
fixture_path("objects/pack/pack-c0438c19fb16422b6bbcce24387b3264416d485b.idx")
960+
fixture_path_standalone("objects/pack/pack-c0438c19fb16422b6bbcce24387b3264416d485b.idx")
958961
);
959962
assert_eq!(
960963
outcome.index_statistics[1].path,
961-
fixture_path("objects/pack/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx")
964+
fixture_path_standalone("objects/pack/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx")
962965
);
963966
assert_eq!(
964967
outcome.index_statistics[2].path,
965-
fixture_path("objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.idx")
968+
fixture_path_standalone("objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.idx")
966969
);
967970
assert_eq!(
968971
outcome.loose_object_stores,
969972
vec![gix_odb::store::verify::integrity::LooseObjectStatistics {
970-
path: fixture_path("objects"),
973+
path: fixture_path_standalone("objects"),
971974
statistics: gix_odb::loose::verify::integrity::Statistics { num_objects: 7 }
972975
}]
973976
);

0 commit comments

Comments
 (0)