MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / runMainBuild

Function runMainBuild

tools/test-examples/index.js:257–494  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

255 } catch {}
256
257 const runMainBuild = () => {
258 const child = spawn('mcconfig', mcArgs, {
259 cwd: examplePath,
260 env: process.env,
261 shell: process.platform === 'win32'
262 });
263
264 let outputBuf = '';
265 let isSetup = false;
266
267 let exceptionOccurred = false;
268 // Tracking instrumentation state
269 let ipDetected = !isNet || !isEmbedded;
270 let instrumentPoller;
271 let instrumentationDataCount = 0;
272 let previousHistoryCount = -1;
273
274 let jsonBuffer = '';
275 let openBraces = 0;
276 let inJson = false;
277 let inString = false;
278 let escapeNext = false;
279
280 let pendingAbortText = null;
281
282 function handleEvent(obj) {
283 if (obj.event === 'stopped') {
284 if (pendingAbortText) {
285 exceptionOccurred = true;
286 finish(false, 'XS Abort detected: ' + pendingAbortText);
287 return;
288 }
289 if (obj.data && typeof obj.data.reason === 'string') {
290 const reason = obj.data.reason;
291 if (reason === '# Break: breakpoint!' || reason === '# Break: step!' || reason === '# Break: debugger!') {
292 // Resumes from deliberate programmatic breakpoints
293 child.stdin.write("c\n");
294 } else if (reason.startsWith('# Break:')) {
295 // Any other break is an unhandled exception or error (SyntaxError, TypeError, etc)
296 exceptionOccurred = true;
297 finish(false, 'Exception detected: ' + reason.replace('# Break: ', '').trim());
298 } else {
299 child.stdin.write("c\n");
300 }
301 } else {
302 child.stdin.write("c\n");
303 }
304 } else if (obj.event === 'log') {
305 if (obj.data && typeof obj.data.text === 'string' && obj.data.text.includes('XS abort')) {
306 exceptionOccurred = true;
307 finish(false, 'XS Abort detected');
308 }
309 } else if (obj.event === 'info_instruments') {
310 if (ipDetected && obj.data && typeof obj.data.historyCount === 'number') {
311 if (obj.data.historyCount > previousHistoryCount) {
312 previousHistoryCount = obj.data.historyCount;
313 instrumentationDataCount++;
314 if (instrumentationDataCount >= 3 && !exceptionOccurred) {

Callers 1

runTestFunction · 0.85

Calls 8

handleEventFunction · 0.85
testMethod · 0.80
finishFunction · 0.70
writeMethod · 0.65
logMethod · 0.65
parseMethod · 0.65
onMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected