mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
Merge origin/main into refactor/lock-ops-decomposition-2507393976208881863 (resolve conflicts)
This commit is contained in:
commit
55208c2e45
308 files changed
+43053
-3934
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { WebSocketServer } from 'ws';
|
||||
import http from 'http';
|
||||
|
||||
const server = http.createServer();
|
||||
const wss = new WebSocketServer({ server });
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
ws.on('message', (message) => {
|
||||
try {
|
||||
const data = JSON.parse(message);
|
||||
const type = data[0];
|
||||
if (type === 'REQ') {
|
||||
const subId = data[1];
|
||||
ws.send(JSON.stringify(['EOSE', subId]));
|
||||
} else if (type === 'EVENT') {
|
||||
const event = data[1];
|
||||
ws.send(JSON.stringify(['OK', event.id, true, '']));
|
||||
}
|
||||
} catch (_err) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
const address = server.address();
|
||||
console.log(`ws://127.0.0.1:${address.port}`);
|
||||
});
|
||||
@@ -1,9 +1,10 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import { writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { writeFileSync, mkdirSync, readFileSync, existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const RUNS = 5;
|
||||
const results = {};
|
||||
const runDiagnostics = [];
|
||||
|
||||
// Parse arguments to separate our flags from test runner args
|
||||
const args = process.argv.slice(2);
|
||||
@@ -19,47 +20,73 @@ for (let i = 0; i < args.length; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
// Default to npm test patterns if no args provided
|
||||
if (testArgs.length === 0) {
|
||||
testArgs.push('test/*.test.mjs', 'test/*.test.js');
|
||||
}
|
||||
|
||||
async function runTests(i) {
|
||||
console.log(`Run ${i + 1}/${RUNS}...`);
|
||||
return new Promise((resolve) => {
|
||||
// Pass strictly the test args to the child process
|
||||
const child = spawn('node', ['--test', ...testArgs], {
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
const tapOutputPath = join(outputDir, `flaky-run-${String(i + 1).padStart(2, '0')}.tap`);
|
||||
const child = spawn(process.execPath, [
|
||||
'--test',
|
||||
'--test-reporter=tap',
|
||||
`--test-reporter-destination=${tapOutputPath}`,
|
||||
...testArgs
|
||||
], {
|
||||
stdio: ['ignore', 'ignore', 'ignore']
|
||||
});
|
||||
|
||||
let stdout = '';
|
||||
|
||||
child.stdout.on('data', (d) => stdout += d.toString());
|
||||
|
||||
child.on('close', (_code) => {
|
||||
const lines = stdout.split('\n');
|
||||
child.on('close', (code) => {
|
||||
let observed = 0;
|
||||
const tapOutput = existsSync(tapOutputPath) ? readFileSync(tapOutputPath, 'utf8') : '';
|
||||
const lines = tapOutput.split('\n');
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('not ok ') && !line.includes('# skip') && !line.includes('# todo')) {
|
||||
const name = line.substring(line.indexOf('-') + 1).trim();
|
||||
if (!results[name]) results[name] = { pass: 0, fail: 0 };
|
||||
results[name].fail++;
|
||||
observed++;
|
||||
} else if (line.startsWith('ok ') && !line.includes('# skip') && !line.includes('# todo')) {
|
||||
const name = line.substring(line.indexOf('-') + 1).trim();
|
||||
if (!results[name]) results[name] = { pass: 0, fail: 0 };
|
||||
results[name].pass++;
|
||||
observed++;
|
||||
}
|
||||
}
|
||||
runDiagnostics.push({
|
||||
run: i + 1,
|
||||
code: code ?? 1,
|
||||
tapOutputPath,
|
||||
observed
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Ensure output directory exists before creating per-run TAP files
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
for (let i = 0; i < RUNS; i++) {
|
||||
await runTests(i);
|
||||
}
|
||||
|
||||
// Ensure output directory exists
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
const outputPath = join(outputDir, 'flakiness-matrix.json');
|
||||
writeFileSync(outputPath, JSON.stringify(results, null, 2));
|
||||
console.log(`Flakiness matrix written to ${outputPath}.`);
|
||||
|
||||
const diagnosticsPath = join(outputDir, 'flakiness-runs.json');
|
||||
writeFileSync(diagnosticsPath, JSON.stringify(runDiagnostics, null, 2));
|
||||
|
||||
// Fail closed: an empty matrix means the signal is missing, not "no flakiness".
|
||||
const totalObserved = runDiagnostics.reduce((sum, run) => sum + run.observed, 0);
|
||||
if (totalObserved === 0) {
|
||||
console.error('No TAP test outcomes were observed across runs; flakiness report is not trustworthy.');
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in new issue
Block a user