testfile

Crates.iotestfile
lib.rstestfile
version0.2.0-alpha.7
created_at2020-06-11 16:48:27.37446+00
updated_at2025-05-11 10:11:55.772796+00
descriptionTemporary test file/dir management for unit tests
homepagehttps://gitlab.com/hsn10/testfile
repositoryhttps://gitlab.com/hsn10/testfile.git
max_upload_size
id252849
size51,878
Radim Kolar (hsn10)

documentation

README

testfile/dir management for Rust unit tests

License: MIT Crates.io Crates.io MSRV dependency status Documentation Lines of code Gitlab pipeline Downloads

Library for creating automaticaly deleted test files or directories for use in your Rust unit tests. Do not worry about manual temporary file/dir cleanups anymore.

Managed temporary files/directories are created in system temporary directory with unique file names. They can be dereferenced as ordinary File and are automatically deleted during Drop.

Functions do not return Result <T,E> but panic! allowing you to focus on your tests and not on error handling.

Because of panic! style error handling its not recommended to use this library outside of unit/integration tests.

Implemented traits for TestFile

  1. Testfile can be dereferenced as File making it drop in replacement.
  2. implements AsRef / AsMut for Read, Write, File, PathBuf, Path.
  3. implements From String, &str, &Path and PathBuf.
  4. self-referential for flexible usage.

Implemented traits for TestDir

  1. TestDir can be dereferenced as Path and PathBuf.
  2. self-referential for flexible usage.
  3. implements From PathBuf, &Path.

Rust 2021 Edition fully compatible

Runs on MSRV 1.56 including its own unit tests. It can be used on any version of Rust 2021 edition. Compiles and runs on Rust edition 2024 without warnings.

Lightweight dependencies

Depends only on small stdrandom crate which is MSRV 1.56 compatible.

License

Licensed under permissive MIT License.

Commit count: 200

cargo fmt