fix(security): stop refused uploads accumulating on the volume, and record the hotspot review (#180) #183
@@ -12,8 +12,24 @@ if (!fs.existsSync(resultsPath)) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const raw = fs.readFileSync(resultsPath, 'utf-8');
|
// Existing but unreadable is a separate case from absent, and it was the one
|
||||||
const data = JSON.parse(raw);
|
// that could still fail the job. `--forceExit` can end the process around the
|
||||||
|
// write and leave a partial file, and a suite that fails to *run* rather than
|
||||||
|
// to assert produces a shape the renderer below did not expect. Either crashed
|
||||||
|
// the script, which failed a step named for summarising and buried the real
|
||||||
|
// failure — the exact misdirection #142 fixed once already. See #178.
|
||||||
|
//
|
||||||
|
// The reason is reported rather than swallowed: "could not read the results
|
||||||
|
// file" plus the parse error is diagnostic, where a silent empty summary is not.
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(fs.readFileSync(resultsPath, 'utf-8'));
|
||||||
|
} catch (err) {
|
||||||
|
const why = `Could not read \`${resultsPath}\` — ${err.message}`;
|
||||||
|
report([`## ${label || 'Test'} Results`, '', why, '']);
|
||||||
|
console.log(`${label || 'Test'}: ${why}`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
const lines = [];
|
const lines = [];
|
||||||
lines.push(`## ${label || 'Test'} Results`);
|
lines.push(`## ${label || 'Test'} Results`);
|
||||||
@@ -29,8 +45,10 @@ lines.push('');
|
|||||||
if (data.numFailedTests > 0) {
|
if (data.numFailedTests > 0) {
|
||||||
lines.push('### Failures');
|
lines.push('### Failures');
|
||||||
lines.push('');
|
lines.push('');
|
||||||
for (const suite of data.testResults) {
|
// Defensive at every level, like summarize-playwright.js's traversal: a suite
|
||||||
for (const t of suite.testResults) {
|
// that failed to run can arrive without the array this walks.
|
||||||
|
for (const suite of data.testResults || []) {
|
||||||
|
for (const t of suite.testResults || []) {
|
||||||
if (t.status === 'failed') {
|
if (t.status === 'failed') {
|
||||||
lines.push(`- **${t.fullName}**`);
|
lines.push(`- **${t.fullName}**`);
|
||||||
const msg = t.failureMessages && t.failureMessages[0]
|
const msg = t.failureMessages && t.failureMessages[0]
|
||||||
|
|||||||
@@ -12,8 +12,20 @@ if (!fs.existsSync(resultsPath)) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const raw = fs.readFileSync(resultsPath, 'utf-8');
|
// The traversal below is defensive at every level; reading was not. A run
|
||||||
const data = JSON.parse(raw);
|
// killed part way through leaves a file that exists and does not parse, and
|
||||||
|
// crashing on it fails a step named for summarising rather than for testing.
|
||||||
|
// See #178.
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(fs.readFileSync(resultsPath, 'utf-8'));
|
||||||
|
} catch (err) {
|
||||||
|
const why = `Could not read \`${resultsPath}\` — ${err.message}`;
|
||||||
|
report(['## Playwright E2E Results', '', why, '']);
|
||||||
|
console.log(`Playwright: ${why}`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
const stats = data.stats || {};
|
const stats = data.stats || {};
|
||||||
|
|
||||||
const lines = [];
|
const lines = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user