Crate gix_testtools

Source
Expand description

Utilities for testing gitoxide crates, many of which might be useful for testing programs that use git in general.

§Feature Flags

  • xz — Use instead of plain tar files, compress these to produce tar.xz files instead. This is useful if archives are uploaded into git-lfs, which doesn’t have built-in compression and metering counts towards uncompressed bytes transferred.

Re-exports§

pub use bstr;
pub use is_ci;
pub use once_cell;
pub use tempfile;

Structs§

AutoRevertToPreviousCWD
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 process which is killed automatically on drop.

Enums§

Creation
Define how scripted_fixture_writable_with_args() uses produces the writable copy.

Statics§

GIT_VERSION
The major, minor and patch level of the git version on the system.

Functions§

bash_program
Get the path attempted as a bash interpreter, for fixture scripts having no #! we can use.
copy_recursively_into_existing_dir
A utility to copy the entire contents of src_dir into dst_dir.
fixture_bytes
Load the fixture from <crate-root>/tests/fixtures/<path> and return its data, or panic.
fixture_bytes_standalone
Like scripted_fixture_writable, but does not prefix the fixture directory with tests
fixture_path
Return the path to the <crate-root>/tests/fixtures/<path> directory.
fixture_path_standalone
Return the path to the <crate-root>/fixtures/<path> directory.
run_git
Run git in working_dir with all provided args.
scripted_fixture_read_only
Run the executable at script_name, like make_repo.sh or my_setup.py to produce a read-only directory to which the path is returned.
scripted_fixture_read_only_standalone
Like scripted_fixture_read_only, but does not prefix the fixture directory with tests
scripted_fixture_read_only_with_args
Like scripted_fixture_read_only()], but passes args to script_name.
scripted_fixture_read_only_with_args_single_archive
Like scripted_fixture_read_only()], but passes args to script_name.
scripted_fixture_read_only_with_args_standalone
Like scripted_fixture_read_only_with_args(), but does not prefix the fixture directory with tests
scripted_fixture_read_only_with_args_standalone_single_archive
Like scripted_fixture_read_only_with_args_standalone(), only has a single archive.
scripted_fixture_writable
Run the executable at script_name, like make_repo.sh to produce a writable directory to which the tempdir is returned. It will be removed automatically, courtesy of tempfile::TempDir.
scripted_fixture_writable_standalone
Like scripted_fixture_writable, but does not prefix the fixture directory with tests
scripted_fixture_writable_with_args
Like scripted_fixture_writable(), but passes args to script_name while providing control over the way files are created with mode.
scripted_fixture_writable_with_args_single_archive
Like scripted_fixture_writable(), but passes args to script_name while providing control over the way files are created with mode.
scripted_fixture_writable_with_args_standalone
Like scripted_fixture_writable_with_args, but does not prefix the fixture directory with tests
scripted_fixture_writable_with_args_standalone_single_archive
Like scripted_fixture_writable_with_args, but does not prefix the fixture directory with tests
set_current_dir
Set the current working dir to new_cwd and 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, minor and patch is 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 process to host all repository at or below working_dir.
to_bstr_err
Transform a verbose parser errors from raw bytes into a BStr to make printing/debugging human-readable.
umaskUnix
Get the umask in a way that is safe, but may be too slow for use outside of tests.

Type Aliases§

Result
A result type to allow using the try operator ? in unit tests.