Organize test logs into separate directories by test suite and file

- wxWidgets logs: tests/logs/wxwidgets/<test-file>/
- KiCad logs: tests/logs/kicad/<test-file>/
- Global setup now cleans all log subdirectories recursively
- Added globalSetup to KiCad playwright config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-12-27 16:35:40 +01:00
commit eedfe22654
6 changed files with 88 additions and 31 deletions

View file

@ -1,22 +1,34 @@
import * as fs from 'fs';
import * as path from 'path';
/**
* Recursively clean all files in a directory (keeps directory structure).
*/
function cleanDirectory(dir: string): number {
let count = 0;
if (!fs.existsSync(dir)) return count;
for (const entry of fs.readdirSync(dir)) {
const fullPath = path.join(dir, entry);
const stat = fs.statSync(fullPath);
if (stat.isFile()) {
fs.unlinkSync(fullPath);
count++;
} else if (stat.isDirectory()) {
count += cleanDirectory(fullPath);
}
}
return count;
}
/**
* Global setup for Playwright tests.
* Cleans the logs directory before each test run to prevent stale logs.
* Cleans the logs directory (and subdirectories) before each test run.
*/
export default async function globalSetup() {
const logsDir = path.join(__dirname, 'logs');
if (fs.existsSync(logsDir)) {
// Remove all files in logs directory
for (const file of fs.readdirSync(logsDir)) {
const filePath = path.join(logsDir, file);
// Only remove files, not subdirectories
if (fs.statSync(filePath).isFile()) {
fs.unlinkSync(filePath);
}
}
console.log(`[global-setup] Cleaned ${logsDir}`);
const count = cleanDirectory(logsDir);
if (count > 0) {
console.log(`[global-setup] Removed ${count} log files from ${logsDir}`);
}
}