ScuttleBot

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

Keyboard Shortcuts

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