mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-06 12:51:54 +00:00
Merge pull request #431 from PR0M3TH3AN/playwright-integration-testing-4582400102750741081
Add Playwright integration testing with code coverage
This commit is contained in:
8 files changed
+1187
-1
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ export function parseArgs(argv) {
|
||||
dryRun: false,
|
||||
force: false,
|
||||
port: DEFAULT_DASHBOARD_PORT,
|
||||
host: null,
|
||||
host: undefined,
|
||||
logDir: 'task-logs',
|
||||
ignoreLogs: false,
|
||||
id: null,
|
||||
|
||||
@@ -37,6 +37,8 @@ export async function cmdDashboard(port = DEFAULT_DASHBOARD_PORT, host = '127.0.
|
||||
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const auth = await getDashboardAuth();
|
||||
|
||||
let gracefulShutdown;
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
try {
|
||||
// Basic Auth check
|
||||
@@ -71,6 +73,14 @@ export async function cmdDashboard(port = DEFAULT_DASHBOARD_PORT, host = '127.0.
|
||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
||||
let pathname = url.pathname;
|
||||
|
||||
// Special case: /shutdown (only if coverage is enabled)
|
||||
if (pathname === '/shutdown' && process.env.NODE_V8_COVERAGE) {
|
||||
res.writeHead(200, SECURITY_HEADERS);
|
||||
res.end('Shutting down');
|
||||
gracefulShutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect / to /dashboard/
|
||||
if (pathname === '/' || pathname === '/dashboard') {
|
||||
res.writeHead(302, { ...SECURITY_HEADERS, 'Location': '/dashboard/' });
|
||||
@@ -230,6 +240,26 @@ export async function cmdDashboard(port = DEFAULT_DASHBOARD_PORT, host = '127.0.
|
||||
}
|
||||
console.log(`Serving files from ${packageRoot}`);
|
||||
console.log(`Using configuration from ${process.cwd()}`);
|
||||
console.log(`NODE_V8_COVERAGE: ${process.env.NODE_V8_COVERAGE}`);
|
||||
|
||||
gracefulShutdown = () => {
|
||||
console.error('Shutting down dashboard server...');
|
||||
fsp.writeFile('shutdown.log', `SIGTERM received. Coverage dir: ${process.env.NODE_V8_COVERAGE}\n`).catch(() => {});
|
||||
server.closeAllConnections(); // Close existing connections (including /shutdown request)
|
||||
server.close(() => {
|
||||
console.error('Dashboard server closed.');
|
||||
process.exit(0);
|
||||
});
|
||||
// Force close after timeout if connections linger
|
||||
setTimeout(() => {
|
||||
console.error('Forcing shutdown after timeout');
|
||||
process.exit(1);
|
||||
}, 5000).unref();
|
||||
};
|
||||
|
||||
process.on('SIGTERM', gracefulShutdown);
|
||||
process.on('SIGINT', gracefulShutdown);
|
||||
|
||||
resolve(server);
|
||||
});
|
||||
server.on('error', reject);
|
||||
|
||||
Reference in new issue
Block a user