stash/tests/README.md

66 lines
1.9 KiB
Markdown

# Stash Test Suite
This directory contains the comprehensive test suite for the Stash project. The tests are written using SRFI-64, Scheme's standard testing framework.
## Test Structure
- `run-tests.scm` - Main test runner that executes all test files
- `test-helpers.scm` - Common testing utilities and fixtures
- Module-specific test files:
- `paths-test.scm` - Tests for path handling functionality
- `package-test.scm` - Tests for package management
- `tree-test.scm` - Tests for directory tree operations
- `file-ops-test.scm` - Tests for file system operations
- `conflict-test.scm` - Tests for conflict detection and resolution
## Running Tests
You can run the entire test suite using the script in the project root:
```bash
./run-tests.sh
```
Or run individual test files directly with Guile:
```bash
GUILE_LOAD_PATH="$PWD:$GUILE_LOAD_PATH" guile tests/paths-test.scm
```
## Writing New Tests
1. Create a new test file following the naming convention `*-test.scm`
2. Use the SRFI-64 test framework
3. Import required modules and test helpers:
```scheme
(use-modules (srfi srfi-64)
(stash your-module)
(test-helpers))
```
4. Organize tests into logical groups using `test-group`
5. Use the test helper functions for common operations
Example:
```scheme
(test-begin "your-module")
(test-group "feature-name"
(test-assert "description"
(your-function-call)))
(test-end "your-module")
```
## Test Helpers
The `test-helpers.scm` module provides several utilities:
- `with-temporary-directory`: Creates and manages temporary test directories
- `create-test-file`: Creates test files with optional content
- `create-test-symlink`: Creates test symlinks
- `delete-directory-recursive`: Safely removes test directories
## Adding New Test Helpers
If you find yourself repeating test setup code, consider adding new helper functions to `test-helpers.scm`.