Skip to content

Commit

Permalink
Include compile errors in snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jul 29, 2023
1 parent 791189b commit 2bd4d42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// TW Snapshot
// Input SHA-256: 19e0b3f9dcac763041039a8ffe87b6732eb744f9ebb136e8d61a53ccf19118e3

// Errors:
// Sprite1: Error: Not compiling an edge-activated hat: event_whengreaterthan

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["PsY$$vp$IVH;dDAr[q2h"];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// TW Snapshot
// Input SHA-256: 19e0b3f9dcac763041039a8ffe87b6732eb744f9ebb136e8d61a53ccf19118e3

// Errors:
// Sprite1: Error: Not compiling an edge-activated hat: event_whengreaterthan

// Sprite1 script
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
const b0 = stage.variables["PsY$$vp$IVH;dDAr[q2h"];
Expand Down
17 changes: 16 additions & 1 deletion test/snapshot/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,24 @@ const generateActualSnapshot = async testCase => {
}
};

const errors = [];
vm.on('COMPILE_ERROR', (target, error) => {
errors.push({target, error});
});

vm.runtime.precompile();

return `// TW Snapshot\n// Input SHA-256: ${inputSHA256}\n\n${generatedJS.join('\n\n')}\n`;
let result = '// TW Snapshot\n';
result += `// Input SHA-256: ${inputSHA256}\n`;
result += '\n';
if (errors.length) {
result += '// Errors:\n';
result += errors.map(i => `// ${i.target.getName()}: ${i.error}\n`);
result += '\n';
}
result += generatedJS.join('\n\n');
result += '\n';
return result;
};

/**
Expand Down

0 comments on commit 2bd4d42

Please sign in to comment.