mirror of
https://github.com/uutils/tar.git
synced 2026-06-10 16:14:35 -07:00
3dfb724997
* Add test documentation and expand CLI test coverage
Document testing philosophy and expand test suite with better CLI-focused
tests and improved error verification.
Changes:
- Add tests/README.md documenting testing philosophy separating application
(CLI interface) from library (archive format) testing concerns
- Update README.md with Testing section linking to test documentation
- Add 23 new CLI-focused tests covering:
* Basic CLI: conflicting operations, missing operation specification
* Create operations: directory archiving, verbose output, empty archive
handling, nonexistent file errors
* Extract operations: verbose output, directory structure preservation
* Round-trip tests: single/multiple files, directories, empty files,
special characters in filenames
* Error handling: permission denied, corrupted archives, dash-prefixed
filenames with -- separator
* Verbose output: format verification for create/extract operations
* CLI parsing: mixed short/long options, option order variations,
default overwrite behavior
* Edge cases: filenames with spaces, large file counts (100 files)
- Improve all 8 existing tests with better error verification:
* Add exit code checks and stderr pattern matching
* Add no_stderr() assertions for successful operations
* Add sanity checks for archive file sizes
* Add TODO comments noting exit code mismatches (usage errors currently
return 1 instead of documented 64)
- Reorganize tests with clear section headers:
1. Basic CLI Tests
2. Create Operation Tests
3. Extract Operation Tests
4. Round-trip Tests
5. Error Handling and Exit Code Tests
6. Verbose Output Format Tests
7. CLI Argument Handling Tests
8. Edge Case Tests
All 31 tests pass. Test suite now has clear documentation explaining what
should be tested at the application level vs library level.
* Align exit codes with GNU tar and modernize tests
- Refactor `uumain` to manually handle `clap` errors, ensuring exit code 64 for command-line syntax errors and exit code 2 for semantic/fatal errors.
- Add mutual exclusion between `--create` and `--extract` operations.
- Update `README.md` and `tests/README.md` with corrected exit code documentation and clarified testing philosophy.
- Modernize `tests/by-util/test_tar.rs`:
- Define `TAR_BLOCK_SIZE` constant (512 bytes).
- Use `uutests` convenience methods (`at.touch()`, `at.rmdir()`, etc.).
- Improve `test_verbose` to use `PathBuf`.
- Replace `.no_stderr()` with `.no_output()`.
- Implement a root-user check in `test_create_permission_denied`.
- Remove redundant or outdated roundtrip and verbose format tests.
* Add missing [test] annotation.
---------
Co-authored-by: Sylvestre Ledru <sylvestre.ledru@gmail.com>
1.4 KiB
1.4 KiB
tar
Rust reimplementation of the tar utility.
Installation
Ensure you have Rust installed on your system. You can install Rust through rustup.
Clone the repository and build the project using Cargo:
git clone https://github.com/uutils/tar.git
cd tar
cargo build --release
cargo run --release
Testing
The tar application has a focused testing philosophy that separates concerns between the application (CLI interface, error handling, user experience) and the underlying tar-rs library (archive format correctness, encoding, permissions).
See tests/README.md for comprehensive documentation.
# Run all tests
cargo test --all
# Run specific test
cargo test test_create_single_file
License
tar is licensed under the MIT License - see the LICENSE file for details