Expand description
Utilities for testing gitoxide crates, many of which might be useful for testing programs that use git in general.
§Environment Variables
§GIX_TEST_FIXTURE_HASH
Set this variable to control which hash function is used when creating or loading test fixtures.
Valid values are the names of hash functions supported by gix_hash::Kind (e.g., sha1, sha256).
If not set, the default hash function via gix_hash::Kind::default() is used.
§Feature Flags
worktree-exclusions(enabled by default) — Use the current repository’s ignore rules to decide if generated fixture archives should be written.xz— Use instead of plaintarfiles, compress these to producetar.xzfiles instead. This is useful if archives are uploaded intogit-lfs, which doesn’t have built-in compression and metering counts towards uncompressed bytes transferred.
Re-exports§
Structs§
- Auto
Revert ToPreviousCWD - A utility to set the current working dir to the given value, on drop.
- Env
- A utility to set and unset environment variables, while restoring or removing them on drop.
- GitDaemon
- A wrapper for a running git-daemon which is stopped automatically on drop.
Enums§
- Creation
- Define how
scripted_fixture_writable_with_args()andrust_fixture_writable()produces the writable copy. - Fixture
State - Indicates the state of a fixture when a closure is called.
Statics§
- GIT_
VERSION - The major, minor and patch level of the git version on the system.
Functions§
- apply_
git_ config_ by_ environment - Apply command-scoped Git
configtocmd, and return it. - bash_
program - Get the path attempted as a
bashinterpreter, for fixture scripts having no#!we can use. - build_
example_ for_ test - Build
examplefrompackageand copy the executable to this test process’ temporary target directory. - copy_
recursively_ into_ existing_ dir - A utility to copy the entire contents of
src_dirintodst_dir. - fixture_
bytes - Load the fixture from
<crate-root>/tests/fixtures/<path>and return its data, or panic. - fixture_
path - Return the path to the
<crate-root>/tests/fixtures/<path>directory. - git
- Run
gitincurrent_dirwith shell-like whitespace-separatedarguments, returning stdout as UTF-8. - invoke_
bash - Run
scriptwithbash_program()incwd. - normalize_
debug_ snapshot - Normalize debug-formatted
valueso one snapshot can be reused for SHA-1 and SHA-256 fixtures. - normalize_
hashes - Normalize 40- and 64-character hexadecimal object IDs in
input. - object_
hash - Like
object_hash_from_env(), but returns the default hash ifGIX_TEST_FIXTURE_HASHis not set. - object_
hash_ from_ env - Returns the hash function that is used when creating or loading test fixtures.
- run_git
- Run
gitinworking_dirwith all providedargs. - rust_
fixture_ read_ only - Execute a Rust closure in a directory, returning a read-only fixture path.
- rust_
fixture_ writable - Execute a Rust closure in a directory, returning a writable temporary directory.
- scripted_
fixture_ read_ only - Run the executable at
script_name, likemake_repo.shormy_setup.pyto produce a read-only directory to which the path is returned. - scripted_
fixture_ read_ only_ needs_ archive - Like
scripted_fixture_read_only(), but uses a matching existing archive even ifGIX_TEST_IGNORE_ARCHIVESis set. - scripted_
fixture_ read_ only_ with_ args - Like
scripted_fixture_read_only(), but passesargstoscript_name. - scripted_
fixture_ read_ only_ with_ args_ single_ archive - Like
scripted_fixture_read_only()], but passesargstoscript_name. - scripted_
fixture_ read_ only_ with_ args_ single_ archive_ with_ post - Like
scripted_fixture_read_only_with_args_single_archive, but runs a Rust closure after the script completes. - scripted_
fixture_ read_ only_ with_ args_ with_ post - Like
scripted_fixture_read_only_with_args, but runs a Rust closure after the script completes. - scripted_
fixture_ read_ only_ with_ post - Like
scripted_fixture_read_only, but runs a Rust closure after the script completes. - scripted_
fixture_ writable - Run the executable at
script_name, likemake_repo.shto produce a writable directory to which the tempdir is returned. It will be removed automatically, courtesy oftempfile::TempDir. - scripted_
fixture_ writable_ with_ args - Like
scripted_fixture_writable(), but passesargstoscript_namewhile providing control over the way files are created withmode. - scripted_
fixture_ writable_ with_ args_ single_ archive - Like
scripted_fixture_writable(), but passesargstoscript_namewhile providing control over the way files are created withmode. - scripted_
fixture_ writable_ with_ args_ single_ archive_ with_ post - Like
scripted_fixture_writable_with_args_single_archive, but runs a Rust closure after the script completes. - scripted_
fixture_ writable_ with_ args_ with_ post - Like
scripted_fixture_writable_with_args, but runs a Rust closure after the script completes. - scripted_
fixture_ writable_ with_ post - Like
scripted_fixture_writable, but runs a Rust closure after the script completes. - set_
current_ dir - Set the current working dir to
new_cwdand return a type that returns to the previous working dir on drop. - should_
skip_ as_ git_ version_ is_ smaller_ than - Returns true if the given
major,minorandpatchis smaller than the actual git version on the system to facilitate skipping a test on the caller. Will never return true on CI which is expected to have a recent enough git version. - size_ok
- Check data structure size, comparing strictly on 64-bit targets.
- spawn_
git_ daemon - Spawn a git daemon to host all repositories at or below
working_dir. - umask
Unix - Get the umask in a way that is safe, but may be too slow for use outside of tests.
Type Aliases§
- Post
Result - A result type for post-processing closures in
*_with_postfixture functions. - Result
- A result type to allow using the try operator
?in unit tests.