Skip to content

Commit 54d5bab

Browse files
committed
Add missing hash_kind
1 parent ea0d591 commit 54d5bab

2 files changed

Lines changed: 86 additions & 47 deletions

File tree

tests/tools/src/tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ fn configure_command_clears_external_config() {
4444
let mut cmd = std::process::Command::new(GIT_PROGRAM);
4545
cmd.env("GIT_CONFIG_SYSTEM", SCOPE_ENV_VALUE);
4646
cmd.env("GIT_CONFIG_GLOBAL", SCOPE_ENV_VALUE);
47-
configure_command(&mut cmd, ["config", "-l", "--show-origin"], temp.path());
47+
configure_command(
48+
&mut cmd,
49+
gix_hash::Kind::default(),
50+
["config", "-l", "--show-origin"],
51+
temp.path(),
52+
);
4853

4954
let output = cmd.output().expect("can run git");
5055
let lines: Vec<_> = output

tests/tools/tests/tools/rust_fixture.rs

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ use gix_testtools::{Creation, FixtureState, Result};
33
#[test]
44
fn rust_fixture_read_only_creates_and_caches_fixture() -> Result {
55
// First call should create the fixture
6-
let (dir, (a, b, c)) = gix_testtools::rust_fixture_read_only("test_fixture_read_only", 1, |fixture| {
7-
let dir = fixture.path();
8-
let a = dir.join("test_file.txt");
9-
let b = dir.join("subdir");
10-
let c = dir.join("subdir/nested.txt");
11-
if fixture.is_uninitialized() {
12-
std::fs::write(&a, "test content")?;
13-
std::fs::create_dir(&b)?;
14-
std::fs::write(&c, "nested content")?;
15-
}
16-
Ok((a, b, c))
17-
})?;
6+
let (dir, (a, b, c)) = gix_testtools::rust_fixture_read_only(
7+
"test_fixture_read_only",
8+
1,
9+
|fixture| {
10+
let dir = fixture.path();
11+
let a = dir.join("test_file.txt");
12+
let b = dir.join("subdir");
13+
let c = dir.join("subdir/nested.txt");
14+
if fixture.is_uninitialized() {
15+
std::fs::write(&a, "test content")?;
16+
std::fs::create_dir(&b)?;
17+
std::fs::write(&c, "nested content")?;
18+
}
19+
Ok((a, b, c))
20+
},
21+
gix_hash::Kind::default(),
22+
)?;
1823

1924
// Verify the fixture was created correctly
2025
assert!(dir.is_dir());
@@ -26,13 +31,18 @@ fn rust_fixture_read_only_creates_and_caches_fixture() -> Result {
2631

2732
// Second call with same version should return cached result
2833
// The closure is still called but knows that it's fresh.
29-
let (dir2, _) = gix_testtools::rust_fixture_read_only("test_fixture_read_only", 1, |fixture| {
30-
assert!(
31-
matches!(fixture, gix_testtools::FixtureState::Fresh(_)),
32-
"Expected cached fixture on second call"
33-
);
34-
Ok(())
35-
})?;
34+
let (dir2, _) = gix_testtools::rust_fixture_read_only(
35+
"test_fixture_read_only",
36+
1,
37+
|fixture| {
38+
assert!(
39+
matches!(fixture, gix_testtools::FixtureState::Fresh(_)),
40+
"Expected cached fixture on second call"
41+
);
42+
Ok(())
43+
},
44+
gix_hash::Kind::default(),
45+
)?;
3646

3747
// Both should point to the same directory
3848
assert_eq!(dir, dir2);
@@ -43,20 +53,30 @@ fn rust_fixture_read_only_creates_and_caches_fixture() -> Result {
4353
#[test]
4454
fn rust_fixture_read_only_version_change_invalidates_cache() -> Result {
4555
// Create fixture with version 1
46-
let (dir1, _) = gix_testtools::rust_fixture_read_only("test_fixture_version", 1, |fixture| {
47-
if let FixtureState::Uninitialized(dir) = fixture {
48-
std::fs::write(dir.join("version.txt"), "v1")?;
49-
}
50-
Ok(())
51-
})?;
56+
let (dir1, _) = gix_testtools::rust_fixture_read_only(
57+
"test_fixture_version",
58+
1,
59+
|fixture| {
60+
if let FixtureState::Uninitialized(dir) = fixture {
61+
std::fs::write(dir.join("version.txt"), "v1")?;
62+
}
63+
Ok(())
64+
},
65+
gix_hash::Kind::default(),
66+
)?;
5267

5368
// Version 2 should create a new fixture in a different directory
54-
let (dir2, _) = gix_testtools::rust_fixture_read_only("test_fixture_version", 2, |fixture| {
55-
if let FixtureState::Uninitialized(dir) = fixture {
56-
std::fs::write(dir.join("version.txt"), "v2")?;
57-
}
58-
Ok(())
59-
})?;
69+
let (dir2, _) = gix_testtools::rust_fixture_read_only(
70+
"test_fixture_version",
71+
2,
72+
|fixture| {
73+
if let FixtureState::Uninitialized(dir) = fixture {
74+
std::fs::write(dir.join("version.txt"), "v2")?;
75+
}
76+
Ok(())
77+
},
78+
gix_hash::Kind::default(),
79+
)?;
6080

6181
assert_ne!(
6282
dir1, dir2,
@@ -73,12 +93,18 @@ fn rust_fixture_read_only_version_change_invalidates_cache() -> Result {
7393
#[test]
7494
fn rust_fixture_writable() -> Result {
7595
for creation in [Creation::CopyFromReadOnly, Creation::Execute] {
76-
let (tmp, _) = gix_testtools::rust_fixture_writable("test_fixture_writable_copy", 1, creation, |fixture| {
77-
if let FixtureState::Uninitialized(dir) = fixture {
78-
std::fs::write(dir.join("original.txt"), "original content")?;
79-
}
80-
Ok(())
81-
})?;
96+
let (tmp, _) = gix_testtools::rust_fixture_writable(
97+
"test_fixture_writable_copy",
98+
1,
99+
creation,
100+
|fixture| {
101+
if let FixtureState::Uninitialized(dir) = fixture {
102+
std::fs::write(dir.join("original.txt"), "original content")?;
103+
}
104+
Ok(())
105+
},
106+
gix_hash::Kind::default(),
107+
)?;
82108

83109
// Verify the fixture was created
84110
let original_path = tmp.path().join("original.txt");
@@ -97,9 +123,12 @@ fn rust_fixture_writable() -> Result {
97123
#[test]
98124
fn rust_fixture_closure_error_propagates() {
99125
// Test that errors from the closure are properly propagated
100-
let res = gix_testtools::rust_fixture_read_only("test_fixture_error", 1, |_fixture| {
101-
Err::<(), _>("intentional error".into())
102-
});
126+
let res = gix_testtools::rust_fixture_read_only(
127+
"test_fixture_error",
128+
1,
129+
|_fixture| Err::<(), _>("intentional error".into()),
130+
gix_hash::Kind::default(),
131+
);
103132

104133
let err_msg = res.unwrap_err().to_string();
105134
assert!(
@@ -110,12 +139,17 @@ fn rust_fixture_closure_error_propagates() {
110139

111140
#[test]
112141
fn rust_fixture_standalone_uses_fixtures_directory() -> Result {
113-
let (dir, _) = gix_testtools::rust_fixture_read_only_standalone("test_fixture_standalone", 1, |fixture| {
114-
if let FixtureState::Uninitialized(dir) = fixture {
115-
std::fs::write(dir.join("standalone.txt"), "standalone")?;
116-
}
117-
Ok(())
118-
})?;
142+
let (dir, _) = gix_testtools::rust_fixture_read_only_standalone(
143+
"test_fixture_standalone",
144+
1,
145+
|fixture| {
146+
if let FixtureState::Uninitialized(dir) = fixture {
147+
std::fs::write(dir.join("standalone.txt"), "standalone")?;
148+
}
149+
Ok(())
150+
},
151+
gix_hash::Kind::default(),
152+
)?;
119153

120154
// Standalone fixtures are stored in fixtures/generated-do-not-edit, not tests/fixtures/...
121155
let dir_str = dir.to_string_lossy();

0 commit comments

Comments
 (0)