Jeff Bailey
|
3dfb724997
|
Add test documentation and expand CLI test coverage (#46)
* 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>
|
2026-03-08 21:36:45 +01:00 |
|