This document describes the cross-platform testing setup for markmv, which ensures the tool works correctly across different operating systems and filesystem types.
markmv is tested on three major platforms:
- Linux (Ubuntu) - Case-sensitive filesystem, symbolic link support
- macOS - Case-insensitive filesystem (default), symbolic link support
- Windows - Case-insensitive filesystem, limited symbolic link support
The main CI pipeline (.github/workflows/main.yml) includes a matrix strategy that tests across:
- Operating Systems: Ubuntu, Windows, macOS
- Node.js versions: 20.x, 22.x
- Filesystem behaviors: Case-sensitive vs case-insensitive
A separate workflow (.github/workflows/cross-platform-tests.yml) performs comprehensive cross-platform testing:
- Automatic filesystem capability detection
- Platform-specific test scenarios
- CLI testing with different path formats
- Symlink behavior validation
A local testing script (scripts/test-cross-platform.js) allows developers to simulate cross-platform testing on their local machine.
Linux (default): Case-sensitive
file.mdandFILE.mdare different files- Link updates must preserve case exactly
macOS/Windows: Case-insensitive
file.mdandFILE.mdrefer to the same file- Link updates are case-insensitive
Windows: Backslash (\)
- Native:
folder\subfolder\file.md - Mixed support:
folder/subfolder/file.md
Unix-like (Linux/macOS): Forward slash (/)
- Native:
folder/subfolder/file.md - Limited backslash support
Linux/macOS: Full support
- File and directory symbolic links
- Link target resolution
Windows: Limited support
- Requires elevated permissions
- May not work in all environments
The src/utils/test-helpers.ts module provides utilities for writing cross-platform tests:
import {
getPlatformInfo,
conditionalTest,
getTestPaths,
wouldFilenamesConflict
} from './test-helpers.js';
// Get current platform information
const platformInfo = getPlatformInfo();
console.log(`Case sensitive: ${platformInfo.caseSensitive}`);
// Run tests conditionally based on platform capabilities
conditionalTest('symlink test', 'symlinks', () => {
// This test only runs if symlinks are supported
});
// Test filename conflicts based on case sensitivity
const conflict = wouldFilenamesConflict('file.md', 'FILE.md');
// Returns true on case-insensitive filesystemsThe testing system uses environment variables to communicate filesystem capabilities:
MARKMV_TEST_OS: Current operating systemMARKMV_TEST_CASE_SENSITIVE: Whether filesystem is case-sensitiveMARKMV_TEST_SUPPORTS_SYMLINKS: Whether symbolic links are supportedMARKMV_TEST_FILESYSTEM_CASE_SENSITIVE: Detected case sensitivityMARKMV_TEST_SUPPORTS_SYMLINKS: Detected symlink support
Cross-platform tests run automatically on all pushes and pull requests:
- Main workflow: Basic cross-platform compatibility
- Cross-platform workflow: Comprehensive filesystem testing
Run cross-platform tests on your local machine:
# Full cross-platform test suite
npm run test:cross-platform
# Create test data only
npm run test:cross-platform:data
# Test CLI only
npm run test:cross-platform:cli
# Run with specific environment
MARKMV_TEST_CASE_SENSITIVE=false npm run test:runTo manually test cross-platform behavior:
- Create test markdown files with links
- Test on different operating systems
- Verify link updates work correctly
- Check case sensitivity handling
- Use test helpers: Always use the cross-platform test utilities
- Conditional testing: Skip tests that require unsupported features
- Path normalization: Use the provided path utilities
- Environment awareness: Check platform capabilities before testing
import { conditionalTest, getPlatformInfo } from '../utils/test-helpers.js';
describe('My Feature', () => {
const platformInfo = getPlatformInfo();
// Standard test that runs on all platforms
test('should work on all platforms', () => {
// Test implementation
});
// Conditional test for case-sensitive filesystems
conditionalTest('case sensitivity test', 'case-sensitivity', () => {
// This only runs on case-sensitive filesystems
});
// Platform-specific test
if (platformInfo.isWindows) {
test('Windows-specific behavior', () => {
// Windows-only test
});
}
});-
Test failures on Windows
- Check path separator usage
- Verify symlink permissions
- Ensure proper escaping
-
Case sensitivity conflicts
- Use conditional tests
- Check filename collision detection
- Verify case-insensitive link updates
-
CI failures
- Review filesystem detection logs
- Check environment variable setup
- Verify test data creation
Enable debug output in tests:
# Enable verbose test output
npm run test:run -- --reporter=verbose
# Run specific test file
npm run test:run -- src/utils/test-helpers.test.ts
# Check filesystem capabilities
node scripts/test-cross-platform.js --test-data-only- Platform Detection: Automatically detect OS and filesystem capabilities
- Environment Setup: Set environment variables for test configuration
- Test Execution: Run tests with platform-aware assertions
- Result Reporting: Generate platform-specific test reports
- Vitest Configuration: Environment variable setup
- CI Workflows: Matrix strategy and capability detection
- Test Utilities: Cross-platform abstractions
- CLI Testing: Path format validation
Potential improvements to cross-platform testing:
- Additional Platforms: Test on more OS variants
- Filesystem Types: Test different filesystem types (NTFS, ext4, APFS)
- Docker Testing: Containerized cross-platform testing
- Performance Testing: Platform-specific performance validation
- Unicode Support: Extended character set testing
When adding new features:
- Consider cross-platform implications
- Add appropriate conditional tests
- Update test utilities if needed
- Document platform-specific behaviors
- Test on multiple operating systems
For more information about the testing setup, see the workflow files in .github/workflows/ and the test utilities in src/utils/test-helpers.ts.