This directory contains utility scripts for managing the SWCanvas test system.
concat-tests.js
Purpose: Concatenates individual modular test files into unified test suites for optimal performance.
What it does:
/tests/core/
into tests/dist/core-functionality-tests.js
/tests/visual/
into tests/dist/visual-rendering-tests.js
npm run build
Usage: Called automatically by the build system, not typically run directly.
update-test-counts.js
Purpose: Automatically updates test count references throughout all documentation files to match actual filesystem counts.
What it does:
/tests/core/
and /tests/visual/
directoriesUsage:
# Update test count references to match current file counts
node tests/build/update-test-counts.js
# Or use as npm script (if configured)
npm run update-test-counts
When to use:
Output: The script provides detailed logging of changes made and suggests appropriate commit messages.
renumber-tests.js
Purpose: Renumbers test files to make space for inserting new tests at specific positions.
What it does:
git mv
Usage:
# Make space for a new visual test at position 25
node tests/build/renumber-tests.js --type visual --position 25 --shift forward
# Close a gap after removing core test 15
node tests/build/renumber-tests.js --type core --position 15 --shift backward
# Preview changes without executing
node tests/build/renumber-tests.js --type visual --position 30 --shift forward --dry-run
Arguments:
--type
: Test type (‘core’ or ‘visual’)--position
: Position to insert/remove at (1-999)--shift
: Direction (‘forward’ to make space, ‘backward’ to close gap)--dry-run
: Preview changes without executing--git
: Use git mv (auto-detected)--help
: Show detailed helpWhen you want to add a new test at a specific position (e.g., position 25) instead of at the end:
# Shift all tests from position 25 onwards forward by 1
node tests/build/renumber-tests.js --type visual --position 25 --shift forward
This renames:
025-existing-test.js
→ 026-existing-test.js
026-another-test.js
→ 027-another-test.js
# Now position 025 is free
echo "// Test: My New Test" > tests/visual/025-my-new-test.js
# Add your test implementation...
npm run build # Regenerate built test files
npm test # Run all tests including your new one
The renumbering script generates an undo-renumber.sh
script:
./undo-renumber.sh # Revert the renumbering operation
All test files follow this naming pattern:
{3-digit-number}-{descriptive-name}.js
001-simple-rectangle-test.js
025-enhanced-clipping-intersection-test.js
056-stroke-pixel-analysis-test.js
Internal Structure:
// Test {number}: {description}
// This file will be concatenated into the main test suite
// Test {number}
registerVisualTest('test-id', {
name: 'Human-readable test name',
width: 200, height: 150,
draw: function(canvas) {
// Test implementation
}
});
tests/build/
├── README.md # This documentation
├── concat-tests.js # Test concatenation utility
├── update-test-counts.js # Automated test count updater
└── renumber-tests.js # Test renumbering utility
git mv
when available--dry-run
to preview, resolve conflicts manuallymv
The build utilities integrate seamlessly with the main SWCanvas build process:
# Full development cycle
npm run build # Runs concat-tests.js automatically
npm test # Uses built test files from /tests/dist/
# Test development cycle
node tests/build/renumber-tests.js --type visual --position 30 --shift forward
# Create your new test at position 030
npm run build # Rebuild with new test
npm test # Verify all tests pass
--dry-run
to see the impactgit mv
to maintain file historyThis comprehensive utility system ensures that test organization remains maintainable as the SWCanvas test suite continues to grow and evolve.