mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
chore: add detailed logs to evaluateInEngine262.runner.mjs
- Insert console.error statements to trace loading, initialization, execution, and mark collection. - Log creation of agent and realm, trace start/stop, and code execution progress. - Output captured mark count. - Simplify fatal error handling with a single error message variable and console.error output.
This commit is contained in:
@@ -12,7 +12,9 @@ process.stdin.on("data", (chunk) => {
|
|||||||
process.stdin.on("end", async () => {
|
process.stdin.on("end", async () => {
|
||||||
try {
|
try {
|
||||||
// Load engine262
|
// Load engine262
|
||||||
|
console.error("[RUNNER] Loading engine262...");
|
||||||
const engine = await import("../../engine262/lib/engine262.mjs");
|
const engine = await import("../../engine262/lib/engine262.mjs");
|
||||||
|
console.error("[RUNNER] Engine loaded successfully");
|
||||||
|
|
||||||
const Agent = engine.Agent;
|
const Agent = engine.Agent;
|
||||||
const ManagedRealm = engine.ManagedRealm;
|
const ManagedRealm = engine.ManagedRealm;
|
||||||
@@ -31,9 +33,11 @@ process.stdin.on("end", async () => {
|
|||||||
const consoleOutput = [];
|
const consoleOutput = [];
|
||||||
|
|
||||||
// Set up agent and realm
|
// Set up agent and realm
|
||||||
|
console.error("[RUNNER] Creating agent and realm");
|
||||||
const agent = new Agent();
|
const agent = new Agent();
|
||||||
setSurroundingAgent(agent);
|
setSurroundingAgent(agent);
|
||||||
const realm = new ManagedRealm();
|
const realm = new ManagedRealm();
|
||||||
|
console.error("[RUNNER] Realm created");
|
||||||
|
|
||||||
// Expose ask262Debug and console to the evaluated code
|
// Expose ask262Debug and console to the evaluated code
|
||||||
realm.scope(() => {
|
realm.scope(() => {
|
||||||
@@ -108,10 +112,13 @@ process.stdin.on("end", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Start tracing
|
// Start tracing
|
||||||
|
console.error("[RUNNER] Starting trace");
|
||||||
ask262Debug.startTrace();
|
ask262Debug.startTrace();
|
||||||
|
|
||||||
// Execute the code
|
// Execute the code
|
||||||
|
console.error("[RUNNER] Executing code...");
|
||||||
const completion = realm.evaluateScript(code);
|
const completion = realm.evaluateScript(code);
|
||||||
|
console.error("[RUNNER] Code execution complete");
|
||||||
|
|
||||||
// Stop tracing
|
// Stop tracing
|
||||||
ask262Debug.stopTrace();
|
ask262Debug.stopTrace();
|
||||||
@@ -123,12 +130,14 @@ process.stdin.on("end", async () => {
|
|||||||
errorValue?.ErrorData?.stringValue?.() ||
|
errorValue?.ErrorData?.stringValue?.() ||
|
||||||
errorValue?.ErrorData?.value ||
|
errorValue?.ErrorData?.value ||
|
||||||
"Unknown error";
|
"Unknown error";
|
||||||
|
console.error(`[RUNNER] Script threw error: ${errorMessage}`);
|
||||||
console.log(JSON.stringify({ error: errorMessage }));
|
console.log(JSON.stringify({ error: errorMessage }));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get captured marks
|
// Get captured marks
|
||||||
const marks = ask262Debug.marks;
|
const marks = ask262Debug.marks;
|
||||||
|
console.error(`[RUNNER] Captured ${marks.length} marks`);
|
||||||
|
|
||||||
// Filter and group marks by important flag
|
// Filter and group marks by important flag
|
||||||
const importantMarks = marks.filter((m) => m.important);
|
const importantMarks = marks.filter((m) => m.important);
|
||||||
@@ -144,11 +153,8 @@ process.stdin.on("end", async () => {
|
|||||||
console.log(JSON.stringify(result));
|
console.log(JSON.stringify(result));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
||||||
JSON.stringify({
|
console.error(`[RUNNER] Fatal error: ${errorMsg}`);
|
||||||
error: error instanceof Error ? error.message : String(error),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user