Skip to content

Commit 93e088a

Browse files
committed
fix gix-archive tests for when symlinks are allowed
1 parent 0899c2e commit 93e088a

File tree

2 files changed

+10
-41
lines changed

2 files changed

+10
-41
lines changed

gix-archive/tests/archive.rs

+10-40
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod from_tree {
1717
#[test]
1818
fn basic_usage_internal() -> gix_testtools::Result {
1919
basic_usage(gix_archive::Format::InternalTransientNonPersistable, |buf| {
20-
assert_eq!(buf.len(), if cfg!(windows) { 565 } else { 551 });
20+
assert_eq!(buf.len(), 551);
2121

2222
let mut stream = gix_worktree_stream::Stream::from_read(std::io::Cursor::new(buf));
2323
let mut paths_and_modes = Vec::new();
@@ -27,11 +27,7 @@ mod from_tree {
2727
entry.read_to_end(&mut buf).expect("stream can always be read");
2828
}
2929

30-
let expected_link_mode = if cfg!(windows) {
31-
EntryKind::Blob
32-
} else {
33-
EntryKind::Link
34-
};
30+
let expected_link_mode = EntryKind::Link;
3531
let expected_exe_mode = if cfg!(windows) {
3632
EntryKind::Blob
3733
} else {
@@ -53,11 +49,7 @@ mod from_tree {
5349
(
5450
"symlink-to-a".into(),
5551
expected_link_mode,
56-
hex_to_id(if cfg!(windows) {
57-
"45b983be36b73c0788dc9cbcb76cbb80fc7bb057"
58-
} else {
59-
"2e65efe2a145dda7ee51d1741299f848e5bf752e"
60-
})
52+
hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e")
6153
),
6254
(
6355
"dir/b".into(),
@@ -119,34 +111,20 @@ mod from_tree {
119111
header.mode()?,
120112
));
121113
}
122-
let expected_symlink_type = if cfg!(windows) {
123-
EntryType::Regular
124-
} else {
125-
EntryType::Symlink
126-
};
114+
let expected_symlink_type = EntryType::Symlink;
127115
let expected_exe_mode = if cfg!(windows) { 420 } else { 493 };
128116
assert_eq!(
129117
out,
130118
[
131119
("prefix/.gitattributes", EntryType::Regular, 56, 420),
132120
("prefix/a", EntryType::Regular, 3, 420),
133-
(
134-
"prefix/symlink-to-a",
135-
expected_symlink_type,
136-
if cfg!(windows) { 3 } else { 0 },
137-
420
138-
),
121+
("prefix/symlink-to-a", expected_symlink_type, 0, 420),
139122
("prefix/dir/b", EntryType::Regular, 3, 420),
140123
("prefix/dir/subdir/exe", EntryType::Regular, 0, expected_exe_mode),
141124
("prefix/extra-file", EntryType::Regular, 21, 420),
142125
("prefix/extra-exe", EntryType::Regular, 0, expected_exe_mode),
143126
("prefix/extra-dir-empty", EntryType::Directory, 0, 420),
144-
(
145-
"prefix/extra-dir/symlink-to-extra",
146-
expected_symlink_type,
147-
if cfg!(windows) { 21 } else { 0 },
148-
420
149-
)
127+
("prefix/extra-dir/symlink-to-extra", expected_symlink_type, 0, 420)
150128
]
151129
.into_iter()
152130
.map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d))
@@ -183,7 +161,7 @@ mod from_tree {
183161
},
184162
|buf| {
185163
assert!(
186-
buf.len() < 1270,
164+
buf.len() < 1280,
187165
"much bigger than uncompressed for some reason (565): {} < 1270",
188166
buf.len()
189167
);
@@ -208,19 +186,11 @@ mod from_tree {
208186
);
209187
let mut link = ar.by_name("prefix/symlink-to-a")?;
210188
assert!(!link.is_dir());
211-
assert_eq!(
212-
link.is_symlink(),
213-
cfg!(not(windows)),
214-
"symlinks are supported as well, but only on Unix"
215-
);
216-
assert_eq!(
217-
link.unix_mode(),
218-
Some(if cfg!(windows) { 0o100644 } else { 0o120644 }),
219-
"the mode specifies what it should be"
220-
);
189+
assert!(link.is_symlink(), "symlinks are supported as well, but only on Unix");
190+
assert_eq!(link.unix_mode(), Some(0o120644), "the mode specifies what it should be");
221191
let mut buf = Vec::new();
222192
link.read_to_end(&mut buf)?;
223-
assert_eq!(buf.as_bstr(), if cfg!(windows) { "hi\n" } else { "a" });
193+
assert_eq!(buf.as_bstr(), "a");
224194
Ok(())
225195
},
226196
)

tests/tools/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ fn extract_archive(
754754
}
755755
#[cfg(not(feature = "xz"))]
756756
{
757-
use std::io::Read;
758757
input_archive.read_to_end(&mut buf)?;
759758
}
760759
buf

0 commit comments

Comments
 (0)