testeranto 0.47.30 → 0.47.32
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/dist/common/Node.js +13 -21
- package/dist/common/Project.js +228 -208
- package/dist/common/Web.js +59 -13
- package/dist/common/core.js +6 -1
- package/dist/common/electron.js +14 -2
- package/dist/common/preload.js +20 -0
- package/dist/common/subPackages/react/jsx/index.js +26 -0
- package/dist/common/subPackages/react/jsx/node.js +2 -11
- package/dist/common/subPackages/react/jsx/web.js +2 -11
- package/dist/common/subPackages/react-dom/component/node.js +78 -34
- package/dist/common/subPackages/react-dom/component/web.js +50 -46
- package/dist/common/subPackages/react-dom/jsx/node.js +101 -0
- package/dist/common/subPackages/react-test-renderer/component/index.js +78 -0
- package/dist/common/subPackages/react-test-renderer/component/node.js +8 -0
- package/dist/common/subPackages/react-test-renderer/component/web.js +8 -0
- package/dist/common/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +3 -3
- package/dist/common/subPackages/react-test-renderer/jsx/node.js +10 -0
- package/dist/common/subPackages/react-test-renderer/jsx/web.js +10 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +13 -21
- package/dist/module/Project.js +228 -208
- package/dist/module/Web.js +59 -13
- package/dist/module/core.js +6 -1
- package/dist/module/electron.js +14 -2
- package/dist/module/preload.js +20 -0
- package/dist/module/subPackages/react/jsx/index.js +22 -0
- package/dist/module/subPackages/react/jsx/node.js +2 -11
- package/dist/module/subPackages/react/jsx/web.js +2 -11
- package/dist/module/subPackages/react-dom/component/node.js +75 -34
- package/dist/module/subPackages/react-dom/component/web.js +50 -46
- package/dist/module/subPackages/react-dom/jsx/node.js +93 -0
- package/dist/module/subPackages/react-test-renderer/component/index.js +52 -0
- package/dist/module/subPackages/react-test-renderer/component/node.js +3 -0
- package/dist/module/subPackages/react-test-renderer/component/web.js +3 -0
- package/dist/module/subPackages/react-test-renderer/fc/node.js +22 -0
- package/dist/module/subPackages/{react-test-render/component/web.js → react-test-renderer/jsx/index.js} +2 -3
- package/dist/module/subPackages/react-test-renderer/jsx/node.js +5 -0
- package/dist/module/subPackages/react-test-renderer/jsx/web.js +5 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Project.d.ts +2 -1
- package/dist/types/core.d.ts +1 -0
- package/dist/types/subPackages/react/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react/jsx/node.d.ts +3 -10
- package/dist/types/subPackages/react/jsx/web.d.ts +3 -11
- package/dist/types/subPackages/react-dom/component/node.d.ts +9 -14
- package/dist/types/subPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/subPackages/react-dom/jsx/node.d.ts +14 -0
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -1
- package/dist/types/subPackages/react-test-renderer/component/index.d.ts +20 -0
- package/dist/types/subPackages/react-test-renderer/component/node.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/component/web.d.ts +9 -0
- package/dist/types/subPackages/react-test-renderer/jsx/index.d.ts +15 -0
- package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +4 -0
- package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +71 -7
- package/src/Node.ts +18 -30
- package/src/Project.ts +292 -274
- package/src/Web.ts +78 -16
- package/src/core.ts +7 -1
- package/src/electron.ts +18 -2
- package/src/preload.ts +23 -0
- package/src/subPackages/react/jsx/index.ts +64 -0
- package/src/subPackages/react/jsx/node.ts +7 -36
- package/src/subPackages/react/jsx/web.ts +7 -38
- package/src/subPackages/react-dom/component/node.ts +85 -54
- package/src/subPackages/react-dom/component/web.ts +86 -76
- package/src/subPackages/react-dom/jsx/node.ts +150 -0
- package/src/subPackages/react-test-renderer/component/index.ts +101 -0
- package/src/subPackages/react-test-renderer/component/node.ts +30 -0
- package/src/subPackages/react-test-renderer/component/web.ts +30 -0
- package/src/subPackages/react-test-renderer/fc/node.tsx +77 -0
- package/src/subPackages/react-test-renderer/jsx/index.ts +51 -0
- package/src/subPackages/react-test-renderer/jsx/node.ts +31 -0
- package/src/subPackages/react-test-renderer/jsx/web.ts +31 -0
- package/dist/common/subPackages/react-test-render/component/node.js +0 -44
- package/dist/common/subPackages/react-test-render/jsx/node.js +0 -46
- package/dist/common/subPackages/react-test-render/jsx/web.js +0 -46
- package/dist/module/subPackages/react-test-render/component/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/node.js +0 -16
- package/dist/module/subPackages/react-test-render/jsx/web.js +0 -16
- package/dist/types/subPackages/react-test-render/component/node.d.ts +0 -19
- package/dist/types/subPackages/react-test-render/component/web.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/node.d.ts +0 -20
- package/dist/types/subPackages/react-test-render/jsx/web.d.ts +0 -20
- package/src/subPackages/react-test-render/component/node.ts +0 -80
- package/src/subPackages/react-test-render/component/web.ts +0 -78
- package/src/subPackages/react-test-render/jsx/node.ts +0 -75
- package/src/subPackages/react-test-render/jsx/web.ts +0 -75
package/dist/common/Node.js
CHANGED
|
@@ -6,7 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const core_js_1 = require("./core.js");
|
|
7
7
|
const core_js_2 = __importDefault(require("./core.js"));
|
|
8
8
|
const NodeWriter_js_1 = require("./NodeWriter.js");
|
|
9
|
-
const
|
|
9
|
+
const receiveTestResourceConfigUnscheduled = async (t, testresource) => {
|
|
10
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
|
|
11
|
+
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
12
|
+
process.exit(await failed ? 1 : 0);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
const receiveTestResourceConfigScheduled = async (t, testresource) => {
|
|
10
16
|
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
|
|
11
17
|
/* @ts-ignore:next-line */
|
|
12
18
|
process.send({
|
|
@@ -40,11 +46,8 @@ exports.default = async (input, testSpecification, testImplementation, testInter
|
|
|
40
46
|
const testResourceArg = process.argv[2] || `{}`;
|
|
41
47
|
try {
|
|
42
48
|
const partialTestResource = JSON.parse(testResourceArg);
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
console.log("test configuration is incomplete", partialTestResource);
|
|
49
|
+
if (partialTestResource.scheduled) {
|
|
50
|
+
console.log("test is scheduled", partialTestResource);
|
|
48
51
|
console.log("requesting test resources via IPC ...", testResourceRequirement);
|
|
49
52
|
/* @ts-ignore:next-line */
|
|
50
53
|
process.send({
|
|
@@ -55,28 +58,17 @@ exports.default = async (input, testSpecification, testImplementation, testInter
|
|
|
55
58
|
});
|
|
56
59
|
console.log("awaiting test resources via IPC...");
|
|
57
60
|
process.on("message", async function (packet) {
|
|
58
|
-
console.log("message: ", packet);
|
|
59
61
|
const resourcesFromPm2 = packet.data.testResourceConfiguration;
|
|
60
62
|
const secondTestResource = Object.assign(Object.assign({ fs: "." }, JSON.parse(JSON.stringify(partialTestResource))), JSON.parse(JSON.stringify(resourcesFromPm2)));
|
|
61
|
-
|
|
62
|
-
receiveTestResourceConfig(t, secondTestResource);
|
|
63
|
+
receiveTestResourceConfigScheduled(t, secondTestResource);
|
|
63
64
|
});
|
|
64
65
|
}
|
|
66
|
+
else {
|
|
67
|
+
receiveTestResourceConfigUnscheduled(t, partialTestResource);
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
70
|
catch (e) {
|
|
67
71
|
console.error(e);
|
|
68
72
|
process.exit(-1);
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
|
-
// else {
|
|
72
|
-
// console.log("Pass run-time test resources by STDIN", process.stdin);
|
|
73
|
-
// process.stdin.on("data", async (data) => {
|
|
74
|
-
// console.log("data: ", data);
|
|
75
|
-
// const resourcesFromStdin = JSON.parse(data.toString());
|
|
76
|
-
// const secondTestResource = {
|
|
77
|
-
// ...JSON.parse(JSON.stringify(resourcesFromStdin)),
|
|
78
|
-
// ...JSON.parse(JSON.stringify(partialTestResource)),
|
|
79
|
-
// } as ITTestResourceConfiguration;
|
|
80
|
-
// await t.receiveTestResourceConfig(secondTestResource);
|
|
81
|
-
// });
|
|
82
|
-
// }
|
package/dist/common/Project.js
CHANGED
|
@@ -82,19 +82,19 @@ class ITProject {
|
|
|
82
82
|
});
|
|
83
83
|
console.table(procsTable);
|
|
84
84
|
console.table(this.resourceQueue);
|
|
85
|
-
|
|
86
|
-
// console.log("resourceQueue", this.resourceQueue);
|
|
85
|
+
console.log("webSocketServer.clients", Object.keys(this.websockets));
|
|
87
86
|
const resourceRequest = this.resourceQueue.pop();
|
|
88
87
|
if (!resourceRequest) {
|
|
89
88
|
if (!this.devMode && this.mode === "up") {
|
|
90
89
|
this.initiateShutdown("resource request queue is empty");
|
|
91
90
|
}
|
|
92
|
-
if (this.mode === "down" &&
|
|
91
|
+
if (this.mode === "down" &&
|
|
92
|
+
(procsTable.every((p) => p.pid === 0 || p.pid === undefined) ||
|
|
93
|
+
procsTable.length === 0)) {
|
|
93
94
|
this.shutdown();
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
97
|
-
console.log("handling", resourceRequest);
|
|
98
98
|
if (resourceRequest.protocol === "ipc") {
|
|
99
99
|
this.allocateViaIpc(resourceRequest);
|
|
100
100
|
}
|
|
@@ -118,13 +118,6 @@ class ITProject {
|
|
|
118
118
|
console.log(this.spinner(), "Shutdown is in progress. Please wait.");
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
// console.log(this.spinner());
|
|
122
|
-
// console.log(
|
|
123
|
-
// this.spinner(),
|
|
124
|
-
// this.mode === `up`
|
|
125
|
-
// ? `press "q" to initiate graceful shutdown`
|
|
126
|
-
// : `please wait while testeranto shuts down gracefully...`
|
|
127
|
-
// );
|
|
128
121
|
});
|
|
129
122
|
};
|
|
130
123
|
this.clearScreen = config.clearScreen;
|
|
@@ -142,6 +135,12 @@ class ITProject {
|
|
|
142
135
|
this.initiateShutdown("'q' command");
|
|
143
136
|
}
|
|
144
137
|
});
|
|
138
|
+
process.stdin.on('keypress', (str, key) => {
|
|
139
|
+
if (key.name === 'x') {
|
|
140
|
+
console.log("Shutting down hard!");
|
|
141
|
+
process.exit(-1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
145
144
|
Promise.resolve().then(() => __importStar(require(testPath))).then((tests) => {
|
|
146
145
|
this.tests = tests.default;
|
|
147
146
|
Promise.resolve().then(() => __importStar(require(featurePath))).then((features) => {
|
|
@@ -210,6 +209,7 @@ class ITProject {
|
|
|
210
209
|
setup(build) {
|
|
211
210
|
build.onEnd(result => {
|
|
212
211
|
console.log(`node build ended with ${result.errors.length} errors`);
|
|
212
|
+
console.log(result);
|
|
213
213
|
result.errors.length !== 0 && process.exit(-1);
|
|
214
214
|
// HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
|
|
215
215
|
});
|
|
@@ -259,6 +259,7 @@ class ITProject {
|
|
|
259
259
|
setup(build) {
|
|
260
260
|
build.onEnd(result => {
|
|
261
261
|
console.log(`web build ended with ${result.errors.length} errors`);
|
|
262
|
+
console.log(result);
|
|
262
263
|
result.errors.length !== 0 && process.exit(-1);
|
|
263
264
|
// HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
|
|
264
265
|
});
|
|
@@ -315,141 +316,159 @@ class ITProject {
|
|
|
315
316
|
esbuild_1.default.context(esbuildConfigWeb).then(async (esbuildWeb) => {
|
|
316
317
|
await esbuildWeb.watch();
|
|
317
318
|
})
|
|
318
|
-
])
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
process.exit(-1);
|
|
319
|
+
]).then(() => {
|
|
320
|
+
if (config.devMode === false) {
|
|
321
|
+
console.log("Your tests were built but not run because devMode was false. Exiting gracefully");
|
|
322
|
+
process.exit(0);
|
|
323
323
|
}
|
|
324
324
|
else {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
port: 8080,
|
|
330
|
-
host: "localhost",
|
|
331
|
-
});
|
|
332
|
-
webSocketServer.on('open', () => {
|
|
333
|
-
console.log('open');
|
|
334
|
-
// process.exit()
|
|
335
|
-
});
|
|
336
|
-
webSocketServer.on('close', (data) => {
|
|
337
|
-
console.log('webSocketServer close: %s', data);
|
|
338
|
-
// process.exit()
|
|
339
|
-
});
|
|
340
|
-
webSocketServer.on('listening', () => {
|
|
341
|
-
console.log("webSocketServer listening", webSocketServer.address());
|
|
342
|
-
// process.exit()
|
|
343
|
-
});
|
|
344
|
-
webSocketServer.on('connection', (webSocket) => {
|
|
345
|
-
console.log('webSocketServer connection');
|
|
346
|
-
webSocket.on('message', (webSocketData) => {
|
|
347
|
-
console.log('webSocket message: %s', webSocketData);
|
|
348
|
-
const payload = webSocketData.valueOf();
|
|
349
|
-
const name = payload.data.name;
|
|
350
|
-
const messageType = payload.type;
|
|
351
|
-
const requestedResources = payload.data;
|
|
352
|
-
this.websockets[name] = webSocket;
|
|
353
|
-
console.log('connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets));
|
|
354
|
-
if (messageType === "testeranto:hola") {
|
|
355
|
-
console.log("hola WS", requestedResources);
|
|
356
|
-
this.requestResource(requestedResources, 'ws');
|
|
325
|
+
pm2_1.default.connect(async (err) => {
|
|
326
|
+
if (err) {
|
|
327
|
+
console.error(err);
|
|
328
|
+
process.exit(-1);
|
|
357
329
|
}
|
|
358
|
-
else
|
|
359
|
-
console.log(
|
|
360
|
-
this.releaseTestResources(payload);
|
|
330
|
+
else {
|
|
331
|
+
console.log(`pm2 is connected`);
|
|
361
332
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
};
|
|
367
|
-
const bootInterval = setInterval(async () => {
|
|
368
|
-
const filesToLookup = this.tests
|
|
369
|
-
.map(([p, rt]) => {
|
|
370
|
-
const filepath = makePath(p, rt);
|
|
371
|
-
return {
|
|
372
|
-
filepath,
|
|
373
|
-
exists: (0, fs_promises_exists_1.default)(filepath),
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
const allFilesExist = (await Promise.all(filesToLookup.map((f) => f.exists))).every((b) => b);
|
|
377
|
-
if (!allFilesExist) {
|
|
378
|
-
console.log(this.spinner(), "waiting for files to build...");
|
|
379
|
-
filesToLookup.forEach((f) => {
|
|
380
|
-
console.log(f.exists, "\t", f.filepath);
|
|
333
|
+
// run a websocket as an alternative to node IPC
|
|
334
|
+
webSocketServer = new ws_1.WebSocketServer({
|
|
335
|
+
port: 8080,
|
|
336
|
+
host: "localhost",
|
|
381
337
|
});
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
338
|
+
webSocketServer.on('open', () => {
|
|
339
|
+
console.log('open');
|
|
340
|
+
// process.exit()
|
|
341
|
+
});
|
|
342
|
+
webSocketServer.on('close', (data) => {
|
|
343
|
+
console.log('webSocketServer close: %s', data);
|
|
344
|
+
// process.exit()
|
|
345
|
+
});
|
|
346
|
+
webSocketServer.on('listening', () => {
|
|
347
|
+
console.log("webSocketServer listening", webSocketServer.address());
|
|
348
|
+
// process.exit()
|
|
349
|
+
});
|
|
350
|
+
webSocketServer.on('connection', (webSocket) => {
|
|
351
|
+
console.log('webSocketServer connection');
|
|
352
|
+
webSocket.on('message', (webSocketData) => {
|
|
353
|
+
// console.log('webSocket message: %s', webSocketData);
|
|
354
|
+
const payload = JSON.parse(webSocketData.valueOf().toString());
|
|
355
|
+
// console.log('webSocket payload', JSON.stringify(payload.data.testResourceConfiguration.name, null, 2));
|
|
356
|
+
// as {
|
|
357
|
+
// type: string,
|
|
358
|
+
// data: ITTestResourceRequirement & {
|
|
359
|
+
// testResourceConfiguration: {
|
|
360
|
+
// name: string;
|
|
361
|
+
// }
|
|
362
|
+
// }
|
|
363
|
+
// };
|
|
364
|
+
const messageType = payload.type;
|
|
365
|
+
if (messageType === "testeranto:hola") {
|
|
366
|
+
const name = payload.data.requirement.name;
|
|
367
|
+
const requestedResources = payload.data;
|
|
368
|
+
this.websockets[name] = webSocket;
|
|
369
|
+
console.log('hola WS! connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets));
|
|
370
|
+
this.requestResource(requestedResources.requirement, 'ws');
|
|
371
|
+
}
|
|
372
|
+
else if (messageType === "testeranto:adios") {
|
|
373
|
+
console.log("adios WS", payload.data.testResourceConfiguration.name);
|
|
374
|
+
this.releaseTestResourceWs(payload);
|
|
375
|
+
}
|
|
393
376
|
});
|
|
394
377
|
});
|
|
395
|
-
|
|
396
|
-
.
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
pm2_1.default.start({
|
|
413
|
-
script: `yarn electron node_modules/testeranto/dist/common/electron.js ${htmlFile} '${JSON.stringify({
|
|
414
|
-
name: inputFilePath,
|
|
415
|
-
ports: [],
|
|
416
|
-
fs: path_1.default.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
417
|
-
})}'`,
|
|
418
|
-
name: inputFilePath,
|
|
419
|
-
autorestart: false,
|
|
420
|
-
args: partialTestResourceByCommandLineArg,
|
|
421
|
-
watch: [jsFile],
|
|
422
|
-
}, (err, proc) => {
|
|
423
|
-
if (err) {
|
|
424
|
-
console.error(err);
|
|
425
|
-
return pm2_1.default.disconnect();
|
|
426
|
-
}
|
|
378
|
+
const makePath = (fPath, rt) => {
|
|
379
|
+
return path_1.default.resolve("./" + config.outdir + "/" + fPath.replace(path_1.default.extname(fPath), "") + ".mjs");
|
|
380
|
+
};
|
|
381
|
+
const bootInterval = setInterval(async () => {
|
|
382
|
+
const filesToLookup = this.tests
|
|
383
|
+
.map(([p, rt]) => {
|
|
384
|
+
const filepath = makePath(p, rt);
|
|
385
|
+
return {
|
|
386
|
+
filepath,
|
|
387
|
+
exists: (0, fs_promises_exists_1.default)(filepath),
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
const allFilesExist = (await Promise.all(filesToLookup.map((f) => f.exists))).every((b) => b);
|
|
391
|
+
if (!allFilesExist) {
|
|
392
|
+
console.log(this.spinner(), "waiting for files to build...");
|
|
393
|
+
filesToLookup.forEach((f) => {
|
|
394
|
+
console.log(f.exists, "\t", f.filepath);
|
|
427
395
|
});
|
|
428
396
|
}
|
|
429
|
-
else
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
397
|
+
else {
|
|
398
|
+
clearInterval(bootInterval);
|
|
399
|
+
pm2_1.default.launchBus((err, pm2_bus) => {
|
|
400
|
+
pm2_bus.on("testeranto:hola", (packet) => {
|
|
401
|
+
console.log("hola IPC", packet);
|
|
402
|
+
this.requestResource(packet.data.requirement, 'ipc');
|
|
403
|
+
});
|
|
404
|
+
pm2_bus.on("testeranto:adios", (payload) => {
|
|
405
|
+
this.releaseTestResourcePm2(payload.data);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
this
|
|
409
|
+
.tests
|
|
410
|
+
.reduce((m, [inputFilePath, runtime]) => {
|
|
411
|
+
const script = makePath(inputFilePath, runtime);
|
|
412
|
+
const partialTestResourceByCommandLineArg = `${script} '${JSON.stringify({
|
|
433
413
|
name: inputFilePath,
|
|
434
414
|
ports: [],
|
|
435
415
|
fs: path_1.default.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
436
|
-
})}'
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
416
|
+
})}'`;
|
|
417
|
+
if (runtime === "web") {
|
|
418
|
+
const fileAsList = inputFilePath.split("/");
|
|
419
|
+
const fileListHead = fileAsList.slice(0, -1);
|
|
420
|
+
const fname = fileAsList[fileAsList.length - 1];
|
|
421
|
+
const fnameOnly = fname.split(".").slice(0, -1).join(".");
|
|
422
|
+
const htmlFile = [config.outdir, ...fileListHead, `${fnameOnly}.html`].join("/");
|
|
423
|
+
const jsFile = path_1.default.resolve(htmlFile.split(".html")[0] + ".mjs");
|
|
424
|
+
console.log("watching", jsFile);
|
|
425
|
+
pm2_1.default.start({
|
|
426
|
+
script: `yarn electron node_modules/testeranto/dist/common/electron.js ${htmlFile} '${JSON.stringify({
|
|
427
|
+
scheduled: true,
|
|
428
|
+
name: inputFilePath,
|
|
429
|
+
ports: [],
|
|
430
|
+
fs: path_1.default.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
431
|
+
})}'`,
|
|
432
|
+
name: inputFilePath,
|
|
433
|
+
autorestart: false,
|
|
434
|
+
args: partialTestResourceByCommandLineArg,
|
|
435
|
+
watch: [jsFile],
|
|
436
|
+
}, (err, proc) => {
|
|
437
|
+
if (err) {
|
|
438
|
+
console.error(err);
|
|
439
|
+
return pm2_1.default.disconnect();
|
|
440
|
+
}
|
|
441
|
+
});
|
|
444
442
|
}
|
|
445
|
-
|
|
443
|
+
else if (runtime === "node") {
|
|
444
|
+
const resolvedPath = path_1.default.resolve(script);
|
|
445
|
+
console.log("watching", resolvedPath);
|
|
446
|
+
pm2_1.default.start({
|
|
447
|
+
name: inputFilePath,
|
|
448
|
+
script: `node ${resolvedPath} '${JSON.stringify({
|
|
449
|
+
scheduled: true,
|
|
450
|
+
name: inputFilePath,
|
|
451
|
+
ports: [],
|
|
452
|
+
fs: path_1.default.resolve(process.cwd(), config.outdir, inputFilePath),
|
|
453
|
+
})}'`,
|
|
454
|
+
autorestart: false,
|
|
455
|
+
watch: [resolvedPath],
|
|
456
|
+
args: partialTestResourceByCommandLineArg
|
|
457
|
+
}, (err, proc) => {
|
|
458
|
+
if (err) {
|
|
459
|
+
console.error(err);
|
|
460
|
+
return pm2_1.default.disconnect();
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
this.exitCodes[inputFilePath] = null;
|
|
465
|
+
return [inputFilePath, ...m];
|
|
466
|
+
}, []);
|
|
467
|
+
setInterval(this.mainLoop, TIMEOUT).unref();
|
|
446
468
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
setInterval(this.mainLoop, TIMEOUT).unref();
|
|
451
|
-
}
|
|
452
|
-
}, TIMEOUT).unref();
|
|
469
|
+
}, TIMEOUT).unref();
|
|
470
|
+
});
|
|
471
|
+
}
|
|
453
472
|
});
|
|
454
473
|
});
|
|
455
474
|
});
|
|
@@ -473,21 +492,54 @@ class ITProject {
|
|
|
473
492
|
this.mode = "down";
|
|
474
493
|
}
|
|
475
494
|
shutdown() {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
495
|
+
let i = 0;
|
|
496
|
+
new Promise((res, reh) => {
|
|
497
|
+
console.log("final results: ");
|
|
498
|
+
const procsTable = [];
|
|
499
|
+
pm2_1.default.list((err, procs) => {
|
|
500
|
+
procs.forEach((proc, ndx) => {
|
|
501
|
+
const exitCode = this.exitCodes[proc.name];
|
|
502
|
+
if (exitCode !== 0) {
|
|
503
|
+
i++;
|
|
504
|
+
}
|
|
505
|
+
procsTable.push({
|
|
506
|
+
name: proc.name,
|
|
507
|
+
pm_id: proc.pm_id,
|
|
508
|
+
exitCode
|
|
509
|
+
});
|
|
510
|
+
if (ndx === procs.length - 1) {
|
|
511
|
+
console.table(procsTable);
|
|
512
|
+
res(i);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
}).then((failures) => {
|
|
517
|
+
console.log("Stopping PM2");
|
|
518
|
+
pm2_1.default.stop("all", (e) => console.error(e));
|
|
519
|
+
// pm2.killDaemon((e) => console.error(e));
|
|
520
|
+
pm2_1.default.disconnect();
|
|
521
|
+
console.log(`gracefully exiting with ${failures} failures`);
|
|
522
|
+
process.exit(failures);
|
|
523
|
+
});
|
|
481
524
|
}
|
|
482
525
|
spinner() {
|
|
483
526
|
this.spinCycle = (this.spinCycle + 1) % this.spinAnimation.length;
|
|
484
527
|
return this.spinAnimation[this.spinCycle];
|
|
485
528
|
}
|
|
486
|
-
async
|
|
529
|
+
async releaseTestResourceWs(payload) {
|
|
530
|
+
const name = payload.data.testResourceConfiguration.name;
|
|
531
|
+
const failed = payload.data.failed;
|
|
532
|
+
this.exitCodes[name] = failed;
|
|
533
|
+
Object.keys(this.ports).forEach((port) => {
|
|
534
|
+
if (this.ports[port] === name) {
|
|
535
|
+
this.ports[port] = OPEN_PORT;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async releaseTestResourcePm2(payload) {
|
|
487
540
|
const name = payload.testResourceConfiguration.name;
|
|
488
541
|
const failed = payload.failed;
|
|
489
|
-
|
|
490
|
-
// reset ports
|
|
542
|
+
this.exitCodes[name] = failed;
|
|
491
543
|
pm2_1.default.list((err, processes) => {
|
|
492
544
|
processes.forEach((proc) => {
|
|
493
545
|
if (proc.name === name) {
|
|
@@ -499,86 +551,55 @@ class ITProject {
|
|
|
499
551
|
}
|
|
500
552
|
});
|
|
501
553
|
});
|
|
502
|
-
this.exitCodes[name] = failed;
|
|
503
554
|
}
|
|
504
555
|
allocateViaWs(resourceRequest) {
|
|
505
|
-
const
|
|
556
|
+
const name = resourceRequest.requirement.name;
|
|
506
557
|
const testResourceRequirement = resourceRequest.requirement;
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
558
|
+
const websocket = this.websockets[name];
|
|
559
|
+
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
560
|
+
websocket.send(JSON.stringify({
|
|
561
|
+
data: {
|
|
562
|
+
testResourceConfiguration: {
|
|
563
|
+
ports: [],
|
|
564
|
+
},
|
|
565
|
+
}
|
|
566
|
+
}));
|
|
567
|
+
}
|
|
568
|
+
else if (((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) || 0) > 0) {
|
|
569
|
+
// clear any port-slots associated with this job
|
|
570
|
+
Object.values(this.ports).forEach((jobMaybe, portNumber) => {
|
|
571
|
+
if (jobMaybe && jobMaybe === name) {
|
|
572
|
+
this.ports[portNumber] = OPEN_PORT;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
// find a list of open ports
|
|
576
|
+
const foundOpenPorts = Object.keys(this.ports).filter((p) => this.ports[p] === OPEN_PORT);
|
|
577
|
+
if (foundOpenPorts.length >= testResourceRequirement.ports) {
|
|
578
|
+
const selectionOfPorts = foundOpenPorts.slice(0, testResourceRequirement.ports);
|
|
579
|
+
websocket.send(JSON.stringify({
|
|
580
|
+
data: {
|
|
581
|
+
testResourceConfiguration: {
|
|
582
|
+
ports: selectionOfPorts,
|
|
523
583
|
},
|
|
524
|
-
};
|
|
525
|
-
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
526
|
-
pm2_1.default.sendDataToProcessId(p.pid, message, function (err, res) {
|
|
527
|
-
// console.log("sendDataToProcessId", err, res, message);
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
if (((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) || 0) > 0) {
|
|
531
|
-
// clear any port-slots associated with this job
|
|
532
|
-
Object.values(this.ports).forEach((jobMaybe, portNumber) => {
|
|
533
|
-
if (jobMaybe && jobMaybe === pName) {
|
|
534
|
-
this.ports[portNumber] = OPEN_PORT;
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
|
-
// find a list of open ports
|
|
538
|
-
const foundOpenPorts = Object.keys(this.ports).filter((p) => this.ports[p] === OPEN_PORT);
|
|
539
|
-
// if there are enough open port-slots...
|
|
540
|
-
if (foundOpenPorts.length >= testResourceRequirement.ports) {
|
|
541
|
-
const selectionOfPorts = foundOpenPorts.slice(0, testResourceRequirement.ports);
|
|
542
|
-
const message = {
|
|
543
|
-
// these fields must be present
|
|
544
|
-
id: p.pid,
|
|
545
|
-
topic: "some topic",
|
|
546
|
-
// process:msg will be send as 'message' on target process
|
|
547
|
-
type: "process:msg",
|
|
548
|
-
// Data to be sent
|
|
549
|
-
data: {
|
|
550
|
-
testResourceConfiguration: {
|
|
551
|
-
// fs: fPath,
|
|
552
|
-
ports: selectionOfPorts,
|
|
553
|
-
},
|
|
554
|
-
id: p.pid,
|
|
555
|
-
},
|
|
556
|
-
};
|
|
557
|
-
pm2_1.default.sendDataToProcessId(p.pid, message, function (err, res) {
|
|
558
|
-
// no-op
|
|
559
|
-
});
|
|
560
|
-
// mark the selected ports as occupied
|
|
561
|
-
for (const foundOpenPort of selectionOfPorts) {
|
|
562
|
-
this.ports[foundOpenPort] = p.pid.toString();
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
else {
|
|
566
|
-
console.log(`no port was open so send the ${p.pid} job to the back of the resourceQueue`);
|
|
567
|
-
this.resourceQueue.push(resourceRequest);
|
|
568
|
-
}
|
|
569
584
|
}
|
|
585
|
+
}));
|
|
586
|
+
// mark the selected ports as occupied
|
|
587
|
+
for (const foundOpenPort of selectionOfPorts) {
|
|
588
|
+
this.ports[foundOpenPort] = name;
|
|
570
589
|
}
|
|
571
|
-
}
|
|
572
|
-
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
console.log(`no port was open so send the ${name} job to the back of the resourceQueue`);
|
|
593
|
+
this.resourceQueue.push(resourceRequest);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
573
596
|
}
|
|
574
597
|
allocateViaIpc(resourceRequest) {
|
|
575
|
-
console.log("allocateViaIpc", resourceRequest);
|
|
576
598
|
const pName = resourceRequest.requirement.name;
|
|
577
599
|
const testResourceRequirement = resourceRequest.requirement;
|
|
578
600
|
pm2_1.default.list((err, processes) => {
|
|
579
601
|
console.error(err);
|
|
580
602
|
processes.forEach((p) => {
|
|
581
|
-
console.log("p.pid, p.name, p.pm_id", p.pid, p.name, p.pm_id);
|
|
582
603
|
if (p.name === pName && p.pid) {
|
|
583
604
|
const message = {
|
|
584
605
|
// these fields must be present
|
|
@@ -594,7 +615,6 @@ class ITProject {
|
|
|
594
615
|
id: p.pm_id,
|
|
595
616
|
},
|
|
596
617
|
};
|
|
597
|
-
console.log("message", message);
|
|
598
618
|
if ((testResourceRequirement === null || testResourceRequirement === void 0 ? void 0 : testResourceRequirement.ports) === 0) {
|
|
599
619
|
pm2_1.default.sendDataToProcessId(p.pm_id, message, function (err, res) {
|
|
600
620
|
// console.log("sendDataToProcessId", err, res, message);
|