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:
The main CI pipeline (.github/workflows/main.yml) includes a matrix strategy that tests across:
A separate workflow (.github/workflows/cross-platform-tests.yml) performs comprehensive cross-platform testing:
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.md and FILE.md are different filesmacOS/Windows: Case-insensitive
file.md and FILE.md refer to the same fileWindows: Backslash (``)
folder\subfolder\file.mdfolder/subfolder/file.mdUnix-like (Linux/macOS): Forward slash (/)
folder/subfolder/file.mdLinux/macOS: Full support
Windows: Limited support
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 filesystems
The 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 supportCross-platform tests run automatically on all pushes and pull requests:
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 test
To manually test cross-platform behavior:
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
Case sensitivity conflicts
CI failures
Enable debug output in tests:
# Enable verbose test output
npx vitest run --reporter=verbose
# Run specific test file
npx vitest run src/utils/test-helpers.test.ts
# Check filesystem capabilities
node scripts/test-cross-platform.js --test-data-only
Potential improvements to cross-platform testing:
When adding new features:
For more information about the testing setup, see the workflow files in .github/workflows/ and the test utilities in src/utils/test-helpers.ts.