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 complete ignore rules to decide if generated fixture archives should be written. Without this feature, only the.gitignorenext to the archive is consulted using a fallback matcher that supports literal patterns and*, but not the full.gitignoresyntax.repo-snapshot(enabled by default) — Capture repository snapshots usinggix-*plumbing crates instead of invoking Git. Without this feature, repository snapshots use the Git executable selected bygix-path.sha1— Enable support for SHA-1 fixture repositories and object IDs.sha256— Enable support for SHA-256 fixture repositories and object IDs.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§
Modules§
- repository
- Capture complete, stable repository state for integration-test assertions. Stable snapshots of the Git and filesystem state of a test repository.
- signature
- Shared setup for tests involving Git-compatible signatures. Test support for Git signing without using the user’s identities or configuration.
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(),scripted_fixture_writable_with_args_with_git_version(), andrust_fixture_writable()produce the writable fixture. - 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_ git_ version - Like
scripted_fixture_read_only_with_args_with_git_version(), but uses a single archive for all argument sets. - 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_ single_ archive_ with_ post_ with_ git_ version - Like
scripted_fixture_read_only_with_args_single_archive_with_git_version(), but runs a Rust closure after the script completes. - scripted_
fixture_ read_ only_ with_ args_ with_ git_ version - Like
scripted_fixture_read_only_with_git_version(), but passesargstoscript_name. - 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_ args_ with_ post_ with_ git_ version - Like
scripted_fixture_read_only_with_args_with_git_version(), but runs a Rust closure after the script completes. - scripted_
fixture_ read_ only_ with_ git_ version - Produce a read-only scripted fixture when the installed Git version is compatible, or extract it from a matching archive otherwise.
- scripted_
fixture_ read_ only_ with_ post - Like
scripted_fixture_read_only, but runs a Rust closure after the script completes. - scripted_
fixture_ read_ only_ with_ post_ with_ git_ version - Like
scripted_fixture_read_only_with_git_version(), 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_ git_ version - Like
scripted_fixture_writable_with_args_with_git_version(), but uses a single archive for all argument sets. - 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_ single_ archive_ with_ post_ with_ git_ version - Like
scripted_fixture_writable_with_args_single_archive_with_git_version(), but runs a Rust closure after the script completes. - scripted_
fixture_ writable_ with_ args_ with_ git_ version - Like
scripted_fixture_writable_with_git_version(), but passesargstoscript_namewhile providing control over the way files are created withmode. - 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_ args_ with_ post_ with_ git_ version - Like
scripted_fixture_writable_with_args_with_git_version(), but runs a Rust closure after the script completes. - scripted_
fixture_ writable_ with_ git_ version - Produce a writable scripted fixture when the installed Git version is compatible, or extract it from a matching archive otherwise.
- scripted_
fixture_ writable_ with_ post - Like
scripted_fixture_writable, but runs a Rust closure after the script completes. - scripted_
fixture_ writable_ with_ post_ with_ git_ version - Like
scripted_fixture_writable_with_git_version(), 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.