MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / startHarness

Function startHarness

scripts/run-javascript-lifecycle-tests.mjs:177–198  ·  view source on GitHub ↗

* Spawn ``javascript_browser_harness.py`` to serve the bundle on a * loopback port. Returns once the harness has written its URL to the * url-file; that's our handshake that the listener is up.

(serveDir, logFile, urlFile)

Source from the content-addressed store, hash-verified

175 * url-file; that's our handshake that the listener is up.
176 */
177async function startHarness(serveDir, logFile, urlFile) {
178 fs.writeFileSync(urlFile, '');
179 const child = spawn('python3', [
180 HARNESS_PY,
181 '--serve-dir', serveDir,
182 '--log-file', logFile,
183 '--url-file', urlFile
184 ], { stdio: ['ignore', 'pipe', 'pipe'] });
185 child.stdout.on('data', () => {});
186 child.stderr.on('data', () => {});
187 for (let i = 0; i < 100; i++) {
188 if (fs.statSync(urlFile).size > 0) {
189 const url = fs.readFileSync(urlFile, 'utf8').trim();
190 if (url) {
191 return { child, url };
192 }
193 }
194 await new Promise(r => setTimeout(r, 50));
195 }
196 child.kill('SIGTERM');
197 throw new Error('Harness did not announce a URL within 5 seconds');
198}
199
200/**
201 * Append parparDiag=1 and cn1DisableEventForwarding=1 (mirrors the

Callers 1

runBundleFunction · 0.85

Calls 4

spawnFunction · 0.85
onMethod · 0.65
trimMethod · 0.65
killMethod · 0.45

Tested by

no test coverage detected