ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / runner / workerHost.js
Source Blame History 104 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __create = Object.create;
f7eb47b… lmata 3 var __defProp = Object.defineProperty;
f7eb47b… lmata 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 5 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 6 var __getProtoOf = Object.getPrototypeOf;
f7eb47b… lmata 7 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 8 var __export = (target, all) => {
f7eb47b… lmata 9 for (var name in all)
f7eb47b… lmata 10 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 11 };
f7eb47b… lmata 12 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 13 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 14 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 15 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 17 }
f7eb47b… lmata 18 return to;
f7eb47b… lmata 19 };
f7eb47b… lmata 20 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
f7eb47b… lmata 21 // If the importer is in node compatibility mode or this is not an ESM
f7eb47b… lmata 22 // file that has been converted to a CommonJS file using a Babel-
f7eb47b… lmata 23 // compatible transform (i.e. "__esModule" has not been set), then set
f7eb47b… lmata 24 // "default" to the CommonJS "module.exports" for node compatibility.
f7eb47b… lmata 25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
f7eb47b… lmata 26 mod
f7eb47b… lmata 27 ));
f7eb47b… lmata 28 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 29 var workerHost_exports = {};
f7eb47b… lmata 30 __export(workerHost_exports, {
f7eb47b… lmata 31 WorkerHost: () => WorkerHost
f7eb47b… lmata 32 });
f7eb47b… lmata 33 module.exports = __toCommonJS(workerHost_exports);
f7eb47b… lmata 34 var import_fs = __toESM(require("fs"));
f7eb47b… lmata 35 var import_path = __toESM(require("path"));
f7eb47b… lmata 36 var import_utils = require("playwright-core/lib/utils");
f7eb47b… lmata 37 var import_processHost = require("./processHost");
f7eb47b… lmata 38 var import_ipc = require("../common/ipc");
f7eb47b… lmata 39 var import_folders = require("../isomorphic/folders");
f7eb47b… lmata 40 let lastWorkerIndex = 0;
f7eb47b… lmata 41 class WorkerHost extends import_processHost.ProcessHost {
f7eb47b… lmata 42 constructor(testGroup, options) {
f7eb47b… lmata 43 const workerIndex = lastWorkerIndex++;
f7eb47b… lmata 44 super(require.resolve("../worker/workerMain.js"), `worker-${workerIndex}`, {
f7eb47b… lmata 45 ...options.extraEnv,
f7eb47b… lmata 46 FORCE_COLOR: "1",
f7eb47b… lmata 47 DEBUG_COLORS: process.env.DEBUG_COLORS === void 0 ? "1" : process.env.DEBUG_COLORS
f7eb47b… lmata 48 });
f7eb47b… lmata 49 this._didFail = false;
f7eb47b… lmata 50 this.workerIndex = workerIndex;
f7eb47b… lmata 51 this.parallelIndex = options.parallelIndex;
f7eb47b… lmata 52 this._hash = testGroup.workerHash;
f7eb47b… lmata 53 this._params = {
f7eb47b… lmata 54 workerIndex: this.workerIndex,
f7eb47b… lmata 55 parallelIndex: options.parallelIndex,
f7eb47b… lmata 56 repeatEachIndex: testGroup.repeatEachIndex,
f7eb47b… lmata 57 projectId: testGroup.projectId,
f7eb47b… lmata 58 config: options.config,
f7eb47b… lmata 59 artifactsDir: import_path.default.join(options.outputDir, (0, import_folders.artifactsFolderName)(workerIndex)),
f7eb47b… lmata 60 pauseOnError: options.pauseOnError,
f7eb47b… lmata 61 pauseAtEnd: options.pauseAtEnd
f7eb47b… lmata 62 };
f7eb47b… lmata 63 }
f7eb47b… lmata 64 artifactsDir() {
f7eb47b… lmata 65 return this._params.artifactsDir;
f7eb47b… lmata 66 }
f7eb47b… lmata 67 async start() {
f7eb47b… lmata 68 await import_fs.default.promises.mkdir(this._params.artifactsDir, { recursive: true });
f7eb47b… lmata 69 return await this.startRunner(this._params, {
f7eb47b… lmata 70 onStdOut: (chunk) => this.emit("stdOut", (0, import_ipc.stdioChunkToParams)(chunk)),
f7eb47b… lmata 71 onStdErr: (chunk) => this.emit("stdErr", (0, import_ipc.stdioChunkToParams)(chunk))
f7eb47b… lmata 72 });
f7eb47b… lmata 73 }
f7eb47b… lmata 74 async onExit() {
f7eb47b… lmata 75 await (0, import_utils.removeFolders)([this._params.artifactsDir]);
f7eb47b… lmata 76 }
f7eb47b… lmata 77 async stop(didFail) {
f7eb47b… lmata 78 if (didFail)
f7eb47b… lmata 79 this._didFail = true;
f7eb47b… lmata 80 await super.stop();
f7eb47b… lmata 81 }
f7eb47b… lmata 82 runTestGroup(runPayload) {
f7eb47b… lmata 83 this.sendMessageNoReply({ method: "runTestGroup", params: runPayload });
f7eb47b… lmata 84 }
f7eb47b… lmata 85 async sendCustomMessage(payload) {
f7eb47b… lmata 86 return await this.sendMessage({ method: "customMessage", params: payload });
f7eb47b… lmata 87 }
f7eb47b… lmata 88 sendResume(payload) {
f7eb47b… lmata 89 this.sendMessageNoReply({ method: "resume", params: payload });
f7eb47b… lmata 90 }
f7eb47b… lmata 91 hash() {
f7eb47b… lmata 92 return this._hash;
f7eb47b… lmata 93 }
f7eb47b… lmata 94 projectId() {
f7eb47b… lmata 95 return this._params.projectId;
f7eb47b… lmata 96 }
f7eb47b… lmata 97 didFail() {
f7eb47b… lmata 98 return this._didFail;
f7eb47b… lmata 99 }
f7eb47b… lmata 100 }
f7eb47b… lmata 101 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 102 0 && (module.exports = {
f7eb47b… lmata 103 WorkerHost
f7eb47b… lmata 104 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button