Skip to content

Commit 624ad2e

Browse files
committed
Add support for disabling archive usage (#393)
That way fixture scripts can forcefully be executed which adds some safety if the feature is actually used.
1 parent 56d7ad7 commit 624ad2e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

DEVELOPMENT.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ by humans.
168168
Utilities to aid in keeping the project fresh and in sync can be found in the `Maintenance` section of the `makefile`. Run `make` to
169169
get an overview.
170170

171+
## Reviewing PRs
172+
173+
- be sure to clone locally and run tests with `GITOXIDE_TEST_IGNORE_ARCHIVES=1` to assure new fixture scripts (if there are any) are validated
174+
on _MacOS_ and _Windows_. Note that linux doesn't need to be tested that way as CI on linux ignores them by merit of not checking them out
175+
via `git-lfs`.
176+
171177
## Creating a release
172178

173179
Run `make publish-all` to publish all crates in leaf-first order using `cargo release` based on the currently set version.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:e7fe369e2c7a87e2688c6d0bf3bcdbe3e31754266f39f53a390f85551ba8258e
2+
oid sha256:75458d7d4cc29c1cab7a97e47578339dff84baf164fc3a9bcddc6f844482bab2
33
size 10848

tests/tools/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,22 @@ fn extract_archive(
237237
destination_dir: &Path,
238238
required_script_identity: u32,
239239
) -> std::io::Result<(u32, Option<String>)> {
240-
let mut archive_buf = Vec::<u8>::new();
241-
let mut decoder = xz2::bufread::XzDecoder::new(std::io::BufReader::new(std::fs::File::open(archive)?));
242-
std::io::copy(&mut decoder, &mut archive_buf)?;
240+
let archive_buf: Vec<u8> = {
241+
let mut buf = Vec::new();
242+
let input_archive = std::fs::File::open(archive)?;
243+
if std::env::var_os("GITOXIDE_TEST_IGNORE_ARCHIVES").is_some() {
244+
return Err(std::io::Error::new(
245+
std::io::ErrorKind::Other,
246+
format!(
247+
"Ignoring archive at '{}' as GITOXIDE_TEST_IGNORE_ARCHIVES is set.",
248+
archive.display()
249+
),
250+
));
251+
}
252+
let mut decoder = xz2::bufread::XzDecoder::new(std::io::BufReader::new(input_archive));
253+
std::io::copy(&mut decoder, &mut buf)?;
254+
buf
255+
};
243256

244257
let mut entry_buf = Vec::<u8>::new();
245258
let (archive_identity, platform): (u32, _) = tar::Archive::new(std::io::Cursor::new(&mut &*archive_buf))

0 commit comments

Comments
 (0)