@skyramp/testbot-core 0.13.0-v3.294 → 0.13.0-v3.296
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/skyramp-walk/walk.cjs +42 -11
- package/dist/VERSION.json +1 -1
- package/dist/main.js +307 -305
- package/dist/post.js +90 -90
- package/dist/runner-client.cjs +62 -62
- package/package.json +1 -1
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"use strict";
|
|
30
30
|
const path = require("path");
|
|
31
31
|
const fs = require("fs");
|
|
32
|
+
const { fork } = require("child_process");
|
|
32
33
|
|
|
33
34
|
const req = (name, dirs) => {
|
|
34
35
|
for (const d of dirs.filter(Boolean)) {
|
|
@@ -40,18 +41,21 @@ const roots = () => [process.env.SKYRAMP_WALK_SDK, ...(process.env.NODE_PATH ||
|
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* The fork's Playwright, launching the Chromium walk.ts installed for it (SKYRAMP_WALK_BROWSERS_PATH) rather than
|
|
43
|
-
* whatever a repo's PLAYWRIGHT_BROWSERS_PATH points at
|
|
44
|
+
* whatever a repo's PLAYWRIGHT_BROWSERS_PATH points at, under the host it was installed for
|
|
45
|
+
* (SKYRAMP_WALK_HOST_PLATFORM, on an Ubuntu newer than the fork). Playwright reads both once, as it loads, so a repo's
|
|
46
|
+
* own Playwright in the session is left as it is.
|
|
44
47
|
*/
|
|
45
48
|
function loadPlaywright(load = () => req("playwright", roots())) {
|
|
46
|
-
const want = process.env.SKYRAMP_WALK_BROWSERS_PATH;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const want = { PLAYWRIGHT_BROWSERS_PATH: process.env.SKYRAMP_WALK_BROWSERS_PATH, PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: process.env.SKYRAMP_WALK_HOST_PLATFORM };
|
|
50
|
+
const set = Object.keys(want).filter((k) => want[k]);
|
|
51
|
+
const prev = Object.fromEntries(set.map((k) => [k, process.env[k]]));
|
|
52
|
+
for (const k of set) process.env[k] = want[k];
|
|
49
53
|
try {
|
|
50
54
|
return load();
|
|
51
55
|
} finally {
|
|
52
|
-
|
|
53
|
-
if (prev === undefined) delete process.env
|
|
54
|
-
else process.env
|
|
56
|
+
for (const k of set) {
|
|
57
|
+
if (prev[k] === undefined) delete process.env[k];
|
|
58
|
+
else process.env[k] = prev[k];
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -194,10 +198,35 @@ function withCredential(fn) {
|
|
|
194
198
|
return next;
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Generate in a process of its own, started under the credential: the SDK's native library sees only the environment
|
|
203
|
+
* its process started with, so a licence set here, even before the SDK loads, gives "LICENSE_FILE required for CI
|
|
204
|
+
* environments".
|
|
205
|
+
*/
|
|
206
|
+
function generate(args, start = fork) {
|
|
207
|
+
return withCredential(
|
|
208
|
+
() =>
|
|
209
|
+
new Promise((resolve, reject) => {
|
|
210
|
+
const child = start(__filename, ["--generate", JSON.stringify(args)], { stdio: ["ignore", "inherit", "inherit", "ipc"] });
|
|
211
|
+
child.once("message", resolve);
|
|
212
|
+
child.once("error", reject);
|
|
213
|
+
child.once("exit", (code) => reject(new Error(`Skyramp generation exited with ${code} and no result`)));
|
|
214
|
+
}),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The other end of generate: this file run as its own process. */
|
|
219
|
+
function generateHere(args) {
|
|
220
|
+
const { SkyrampClient } = req("@skyramp/skyramp", roots());
|
|
221
|
+
new SkyrampClient()
|
|
222
|
+
.generateRestTest(args)
|
|
223
|
+
.then(String, (e) => `failed: ${e.message}`)
|
|
224
|
+
.then((result) => process.send(result, () => process.exit(0)));
|
|
225
|
+
}
|
|
226
|
+
|
|
197
227
|
async function walk(opts, body) {
|
|
198
228
|
const { chromium } = loadPlaywright();
|
|
199
229
|
const exp = req("playwright/lib/mcp/skyramp", roots());
|
|
200
|
-
const { SkyrampClient } = req("@skyramp/skyramp", roots());
|
|
201
230
|
const scratch = fs.mkdtempSync(path.join(require("os").tmpdir(), "skyramp-walk-"));
|
|
202
231
|
const zip = opts.zip || path.join(scratch, "walk.zip");
|
|
203
232
|
const har = path.join(scratch, "walk.har");
|
|
@@ -305,7 +334,7 @@ async function walk(opts, body) {
|
|
|
305
334
|
throw failure;
|
|
306
335
|
}
|
|
307
336
|
await record();
|
|
308
|
-
const result = await
|
|
337
|
+
const result = await generate({
|
|
309
338
|
testType: "ui",
|
|
310
339
|
language: opts.language || "typescript",
|
|
311
340
|
framework: "playwright",
|
|
@@ -314,9 +343,11 @@ async function walk(opts, body) {
|
|
|
314
343
|
playwrightInput: zip,
|
|
315
344
|
generateInclude: hosts,
|
|
316
345
|
force: true,
|
|
317
|
-
})
|
|
346
|
+
});
|
|
318
347
|
if (!/success/i.test(String(result))) throw new Error(`Skyramp generation failed: ${result}`);
|
|
319
348
|
return { zip, test: path.resolve(opts.outputDir || ".", opts.output), actions: actions.length, ...(leftOut.length ? { leftOut } : {}) };
|
|
320
349
|
}
|
|
321
350
|
|
|
322
|
-
|
|
351
|
+
if (require.main === module && process.argv[2] === "--generate") generateHere(JSON.parse(process.argv[3]));
|
|
352
|
+
|
|
353
|
+
module.exports = { walk, _internal: { generate, withCredential, retryUntil, apiRoute, stepFailure, forkLocator, exportable, patchAssertLocators, loadPlaywright } };
|
package/dist/VERSION.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.13.0-v3.
|
|
1
|
+
{"version":"0.13.0-v3.296","commit":"74640f02c12f630812f22b4a33d37919223f6857"}
|