@jsenv/test 3.6.7 → 3.6.8
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/jsenv_test.js +234 -668
- package/dist/jsenv_test_node_modules.js +295 -0
- package/package.json +10 -10
- package/src/execution/execute_test_plan.js +21 -82
- package/src/execution/reporters/reporter_list.js +3 -73
- package/src/helpers/call_orderer.js +0 -39
- package/src/helpers/cpu_usage.js +0 -221
- package/src/helpers/cpu_usage.test_manual.js +0 -17
package/dist/jsenv_test.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { readGitHubWorkflowEnv, startGithubCheckRun } from "@jsenv/github-check-run";
|
|
2
|
-
import process$1, { cpuUsage, memoryUsage } from "node:process";
|
|
3
|
-
import os, { cpus, totalmem, release, availableParallelism, freemem } from "node:os";
|
|
4
|
-
import tty from "node:tty";
|
|
5
|
-
import stringWidth from "string-width";
|
|
6
2
|
import { applyNodeEsmResolution } from "@jsenv/node-esm-resolution";
|
|
3
|
+
import { startMonitoringCpuUsage, startMonitoringMemoryUsage, getAvailableMemory, countAvailableCpus, getOsVersion } from "@jsenv/os-metrics";
|
|
7
4
|
import { readdir, chmod, stat, lstat, chmodSync, statSync, lstatSync, promises, readFile as readFile$1, readdirSync, openSync, closeSync, unlinkSync, rmdirSync, mkdirSync, readFileSync, writeFileSync as writeFileSync$1, unlink, rmdir, existsSync } from "node:fs";
|
|
8
5
|
import { takeCoverage } from "node:v8";
|
|
9
6
|
import stripAnsi from "strip-ansi";
|
|
10
7
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
11
8
|
import { createRequire } from "node:module";
|
|
12
9
|
import { applyBabelPlugins } from "@jsenv/ast";
|
|
10
|
+
import { memoryUsage } from "node:process";
|
|
11
|
+
import { createSupportsColor, isUnicodeSupported, clearTerminal, eraseLines } from "./jsenv_test_node_modules.js";
|
|
12
|
+
import { measureTextWidth } from "@jsenv/terminal-text-size";
|
|
13
13
|
import { createException } from "@jsenv/exception";
|
|
14
14
|
import crypto from "node:crypto";
|
|
15
15
|
import { dirname } from "node:path";
|
|
@@ -20,6 +20,8 @@ import { injectSupervisorIntoHTML, supervisorFileUrl } from "@jsenv/plugin-super
|
|
|
20
20
|
import { findFreePort } from "@jsenv/server";
|
|
21
21
|
import { Worker } from "node:worker_threads";
|
|
22
22
|
import he from "he";
|
|
23
|
+
import "node:os";
|
|
24
|
+
import "node:tty";
|
|
23
25
|
|
|
24
26
|
const createCallbackListNotifiedOnce = () => {
|
|
25
27
|
let callbacks = [];
|
|
@@ -530,329 +532,86 @@ const SIGINT_CALLBACK = {
|
|
|
530
532
|
},
|
|
531
533
|
};
|
|
532
534
|
|
|
533
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
534
|
-
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
535
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
|
|
536
|
-
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
537
|
-
const position = argv.indexOf(prefix + flag);
|
|
538
|
-
const terminatorPosition = argv.indexOf('--');
|
|
539
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
const {env} = process$1;
|
|
543
|
-
|
|
544
|
-
let flagForceColor;
|
|
545
|
-
if (
|
|
546
|
-
hasFlag('no-color')
|
|
547
|
-
|| hasFlag('no-colors')
|
|
548
|
-
|| hasFlag('color=false')
|
|
549
|
-
|| hasFlag('color=never')
|
|
550
|
-
) {
|
|
551
|
-
flagForceColor = 0;
|
|
552
|
-
} else if (
|
|
553
|
-
hasFlag('color')
|
|
554
|
-
|| hasFlag('colors')
|
|
555
|
-
|| hasFlag('color=true')
|
|
556
|
-
|| hasFlag('color=always')
|
|
557
|
-
) {
|
|
558
|
-
flagForceColor = 1;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function envForceColor() {
|
|
562
|
-
if (!('FORCE_COLOR' in env)) {
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if (env.FORCE_COLOR === 'true') {
|
|
567
|
-
return 1;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (env.FORCE_COLOR === 'false') {
|
|
571
|
-
return 0;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
if (env.FORCE_COLOR.length === 0) {
|
|
575
|
-
return 1;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
579
|
-
|
|
580
|
-
if (![0, 1, 2, 3].includes(level)) {
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
return level;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
function translateLevel(level) {
|
|
588
|
-
if (level === 0) {
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
return {
|
|
593
|
-
level,
|
|
594
|
-
hasBasic: true,
|
|
595
|
-
has256: level >= 2,
|
|
596
|
-
has16m: level >= 3,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
601
|
-
const noFlagForceColor = envForceColor();
|
|
602
|
-
if (noFlagForceColor !== undefined) {
|
|
603
|
-
flagForceColor = noFlagForceColor;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
607
|
-
|
|
608
|
-
if (forceColor === 0) {
|
|
609
|
-
return 0;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (sniffFlags) {
|
|
613
|
-
if (hasFlag('color=16m')
|
|
614
|
-
|| hasFlag('color=full')
|
|
615
|
-
|| hasFlag('color=truecolor')) {
|
|
616
|
-
return 3;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
if (hasFlag('color=256')) {
|
|
620
|
-
return 2;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// Check for Azure DevOps pipelines.
|
|
625
|
-
// Has to be above the `!streamIsTTY` check.
|
|
626
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
627
|
-
return 1;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
631
|
-
return 0;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
const min = forceColor || 0;
|
|
635
|
-
|
|
636
|
-
if (env.TERM === 'dumb') {
|
|
637
|
-
return min;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (process$1.platform === 'win32') {
|
|
641
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
642
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
643
|
-
const osRelease = os.release().split('.');
|
|
644
|
-
if (
|
|
645
|
-
Number(osRelease[0]) >= 10
|
|
646
|
-
&& Number(osRelease[2]) >= 10_586
|
|
647
|
-
) {
|
|
648
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return 1;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
if ('CI' in env) {
|
|
655
|
-
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
|
656
|
-
return 3;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
660
|
-
return 1;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
return min;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
667
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (env.COLORTERM === 'truecolor') {
|
|
671
|
-
return 3;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
if (env.TERM === 'xterm-kitty') {
|
|
675
|
-
return 3;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
if ('TERM_PROGRAM' in env) {
|
|
679
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
680
|
-
|
|
681
|
-
switch (env.TERM_PROGRAM) {
|
|
682
|
-
case 'iTerm.app': {
|
|
683
|
-
return version >= 3 ? 3 : 2;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
case 'Apple_Terminal': {
|
|
687
|
-
return 2;
|
|
688
|
-
}
|
|
689
|
-
// No default
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
694
|
-
return 2;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
698
|
-
return 1;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
if ('COLORTERM' in env) {
|
|
702
|
-
return 1;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
return min;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
function createSupportsColor(stream, options = {}) {
|
|
709
|
-
const level = _supportsColor(stream, {
|
|
710
|
-
streamIsTTY: stream && stream.isTTY,
|
|
711
|
-
...options,
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
return translateLevel(level);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
({
|
|
718
|
-
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
|
719
|
-
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
function isUnicodeSupported() {
|
|
723
|
-
const {env} = process$1;
|
|
724
|
-
const {TERM, TERM_PROGRAM} = env;
|
|
725
|
-
|
|
726
|
-
if (process$1.platform !== 'win32') {
|
|
727
|
-
return TERM !== 'linux'; // Linux console (kernel)
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
return Boolean(env.WT_SESSION) // Windows Terminal
|
|
731
|
-
|| Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
732
|
-
|| env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
733
|
-
|| TERM_PROGRAM === 'Terminus-Sublime'
|
|
734
|
-
|| TERM_PROGRAM === 'vscode'
|
|
735
|
-
|| TERM === 'xterm-256color'
|
|
736
|
-
|| TERM === 'alacritty'
|
|
737
|
-
|| TERM === 'rxvt-unicode'
|
|
738
|
-
|| TERM === 'rxvt-unicode-256color'
|
|
739
|
-
|| env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
|
|
743
|
-
|
|
744
|
-
const isBrowser = globalThis.window?.document !== undefined;
|
|
745
|
-
|
|
746
|
-
globalThis.process?.versions?.node !== undefined;
|
|
747
|
-
|
|
748
|
-
globalThis.process?.versions?.bun !== undefined;
|
|
749
|
-
|
|
750
|
-
globalThis.Deno?.version?.deno !== undefined;
|
|
751
|
-
|
|
752
|
-
globalThis.process?.versions?.electron !== undefined;
|
|
753
|
-
|
|
754
|
-
globalThis.navigator?.userAgent?.includes('jsdom') === true;
|
|
755
|
-
|
|
756
|
-
typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
|
|
757
|
-
|
|
758
|
-
typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
759
|
-
|
|
760
|
-
typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
|
|
761
|
-
|
|
762
|
-
typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
|
|
763
|
-
|
|
764
|
-
// Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
|
|
765
|
-
const platform = globalThis.navigator?.userAgentData?.platform;
|
|
766
|
-
|
|
767
|
-
platform === 'macOS'
|
|
768
|
-
|| globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
|
|
769
|
-
|| globalThis.navigator?.userAgent?.includes(' Mac ') === true
|
|
770
|
-
|| globalThis.process?.platform === 'darwin';
|
|
771
|
-
|
|
772
|
-
platform === 'Windows'
|
|
773
|
-
|| globalThis.navigator?.platform === 'Win32'
|
|
774
|
-
|| globalThis.process?.platform === 'win32';
|
|
775
|
-
|
|
776
|
-
platform === 'Linux'
|
|
777
|
-
|| globalThis.navigator?.platform?.startsWith('Linux') === true
|
|
778
|
-
|| globalThis.navigator?.userAgent?.includes(' Linux ') === true
|
|
779
|
-
|| globalThis.process?.platform === 'linux';
|
|
780
|
-
|
|
781
|
-
platform === 'Android'
|
|
782
|
-
|| globalThis.navigator?.platform === 'Android'
|
|
783
|
-
|| globalThis.navigator?.userAgent?.includes(' Android ') === true
|
|
784
|
-
|| globalThis.process?.platform === 'android';
|
|
785
|
-
|
|
786
|
-
const ESC = '\u001B[';
|
|
787
|
-
|
|
788
|
-
!isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
789
|
-
const isWindows$3 = !isBrowser && process$1.platform === 'win32';
|
|
790
|
-
|
|
791
|
-
isBrowser ? () => {
|
|
792
|
-
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
793
|
-
} : process$1.cwd;
|
|
794
|
-
|
|
795
|
-
const cursorUp = (count = 1) => ESC + count + 'A';
|
|
796
|
-
|
|
797
|
-
const cursorLeft = ESC + 'G';
|
|
798
|
-
|
|
799
|
-
const eraseLines = count => {
|
|
800
|
-
let clear = '';
|
|
801
|
-
|
|
802
|
-
for (let i = 0; i < count; i++) {
|
|
803
|
-
clear += eraseLine + (i < count - 1 ? cursorUp() : '');
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
if (count) {
|
|
807
|
-
clear += cursorLeft;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
return clear;
|
|
811
|
-
};
|
|
812
|
-
const eraseLine = ESC + '2K';
|
|
813
|
-
const eraseScreen = ESC + '2J';
|
|
814
|
-
|
|
815
|
-
const clearTerminal = isWindows$3
|
|
816
|
-
? `${eraseScreen}${ESC}0f`
|
|
817
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
818
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
819
|
-
// 3. Moves cursor to the top-left position
|
|
820
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
821
|
-
: `${eraseScreen}${ESC}3J${ESC}H`;
|
|
822
|
-
|
|
823
535
|
const createDetailedMessage = (message, details = {}) => {
|
|
824
|
-
let
|
|
536
|
+
let text = `${message}`;
|
|
537
|
+
const namedSectionsText = renderNamedSections(details);
|
|
538
|
+
if (namedSectionsText) {
|
|
539
|
+
text += `
|
|
540
|
+
${namedSectionsText}`;
|
|
541
|
+
}
|
|
542
|
+
return text;
|
|
543
|
+
};
|
|
825
544
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
545
|
+
const renderNamedSections = (namedSections) => {
|
|
546
|
+
let text = "";
|
|
547
|
+
let keys = Object.keys(namedSections);
|
|
548
|
+
for (const key of keys) {
|
|
549
|
+
const isLastKey = key === keys[keys.length - 1];
|
|
550
|
+
const value = namedSections[key];
|
|
551
|
+
text += `--- ${key} ---
|
|
830
552
|
${
|
|
831
553
|
Array.isArray(value)
|
|
832
554
|
? value.join(`
|
|
833
555
|
`)
|
|
834
556
|
: value
|
|
835
557
|
}`;
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
558
|
+
if (!isLastKey) {
|
|
559
|
+
text += "\n";
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return text;
|
|
839
563
|
};
|
|
840
564
|
|
|
841
565
|
// https://github.com/Marak/colors.js/blob/master/lib/styles.js
|
|
842
566
|
// https://stackoverflow.com/a/75985833/2634179
|
|
843
567
|
const RESET = "\x1b[0m";
|
|
844
568
|
|
|
569
|
+
const RED = "red";
|
|
570
|
+
const GREEN = "green";
|
|
571
|
+
const YELLOW = "yellow";
|
|
572
|
+
const BLUE = "blue";
|
|
573
|
+
const MAGENTA = "magenta";
|
|
574
|
+
const CYAN = "cyan";
|
|
575
|
+
const GREY = "grey";
|
|
576
|
+
const WHITE = "white";
|
|
577
|
+
const BLACK = "black";
|
|
578
|
+
|
|
579
|
+
const TEXT_COLOR_ANSI_CODES = {
|
|
580
|
+
[RED]: "\x1b[31m",
|
|
581
|
+
[GREEN]: "\x1b[32m",
|
|
582
|
+
[YELLOW]: "\x1b[33m",
|
|
583
|
+
[BLUE]: "\x1b[34m",
|
|
584
|
+
[MAGENTA]: "\x1b[35m",
|
|
585
|
+
[CYAN]: "\x1b[36m",
|
|
586
|
+
[GREY]: "\x1b[90m",
|
|
587
|
+
[WHITE]: "\x1b[37m",
|
|
588
|
+
[BLACK]: "\x1b[30m",
|
|
589
|
+
};
|
|
590
|
+
const BACKGROUND_COLOR_ANSI_CODES = {
|
|
591
|
+
[RED]: "\x1b[41m",
|
|
592
|
+
[GREEN]: "\x1b[42m",
|
|
593
|
+
[YELLOW]: "\x1b[43m",
|
|
594
|
+
[BLUE]: "\x1b[44m",
|
|
595
|
+
[MAGENTA]: "\x1b[45m",
|
|
596
|
+
[CYAN]: "\x1b[46m",
|
|
597
|
+
[GREY]: "\x1b[100m",
|
|
598
|
+
[WHITE]: "\x1b[47m",
|
|
599
|
+
[BLACK]: "\x1b[40m",
|
|
600
|
+
};
|
|
601
|
+
|
|
845
602
|
const createAnsi = ({ supported }) => {
|
|
846
603
|
const ANSI = {
|
|
847
604
|
supported,
|
|
848
605
|
|
|
849
|
-
RED
|
|
850
|
-
GREEN
|
|
851
|
-
YELLOW
|
|
852
|
-
BLUE
|
|
853
|
-
MAGENTA
|
|
854
|
-
CYAN
|
|
855
|
-
GREY
|
|
606
|
+
RED,
|
|
607
|
+
GREEN,
|
|
608
|
+
YELLOW,
|
|
609
|
+
BLUE,
|
|
610
|
+
MAGENTA,
|
|
611
|
+
CYAN,
|
|
612
|
+
GREY,
|
|
613
|
+
WHITE,
|
|
614
|
+
BLACK,
|
|
856
615
|
color: (text, color) => {
|
|
857
616
|
if (!ANSI.supported) {
|
|
858
617
|
return text;
|
|
@@ -864,7 +623,29 @@ const createAnsi = ({ supported }) => {
|
|
|
864
623
|
// cannot set color of blank chars
|
|
865
624
|
return text;
|
|
866
625
|
}
|
|
867
|
-
|
|
626
|
+
const ansiEscapeCodeForTextColor = TEXT_COLOR_ANSI_CODES[color];
|
|
627
|
+
if (!ansiEscapeCodeForTextColor) {
|
|
628
|
+
return text;
|
|
629
|
+
}
|
|
630
|
+
return `${ansiEscapeCodeForTextColor}${text}${RESET}`;
|
|
631
|
+
},
|
|
632
|
+
backgroundColor: (text, color) => {
|
|
633
|
+
if (!ANSI.supported) {
|
|
634
|
+
return text;
|
|
635
|
+
}
|
|
636
|
+
if (!color) {
|
|
637
|
+
return text;
|
|
638
|
+
}
|
|
639
|
+
if (typeof text === "string" && text.trim() === "") {
|
|
640
|
+
// cannot set background color of blank chars
|
|
641
|
+
return text;
|
|
642
|
+
}
|
|
643
|
+
const ansiEscapeCodeForBackgroundColor =
|
|
644
|
+
BACKGROUND_COLOR_ANSI_CODES[color];
|
|
645
|
+
if (!ansiEscapeCodeForBackgroundColor) {
|
|
646
|
+
return text;
|
|
647
|
+
}
|
|
648
|
+
return `${ansiEscapeCodeForBackgroundColor}${text}${RESET}`;
|
|
868
649
|
},
|
|
869
650
|
|
|
870
651
|
BOLD: "\x1b[1m",
|
|
@@ -881,7 +662,8 @@ const createAnsi = ({ supported }) => {
|
|
|
881
662
|
if (text === "") {
|
|
882
663
|
return text;
|
|
883
664
|
}
|
|
884
|
-
|
|
665
|
+
const ansiEscapeCodeForEffect = effect;
|
|
666
|
+
return `${ansiEscapeCodeForEffect}${text}${RESET}`;
|
|
885
667
|
},
|
|
886
668
|
};
|
|
887
669
|
|
|
@@ -1012,6 +794,23 @@ const setDecimalsPrecision = (
|
|
|
1012
794
|
const asFloat = asInteger / coef;
|
|
1013
795
|
return number < 0 ? -asFloat : asFloat;
|
|
1014
796
|
};
|
|
797
|
+
|
|
798
|
+
// https://www.codingem.com/javascript-how-to-limit-decimal-places/
|
|
799
|
+
// export const roundNumber = (number, maxDecimals) => {
|
|
800
|
+
// const decimalsExp = Math.pow(10, maxDecimals)
|
|
801
|
+
// const numberRoundInt = Math.round(decimalsExp * (number + Number.EPSILON))
|
|
802
|
+
// const numberRoundFloat = numberRoundInt / decimalsExp
|
|
803
|
+
// return numberRoundFloat
|
|
804
|
+
// }
|
|
805
|
+
|
|
806
|
+
// export const setPrecision = (number, precision) => {
|
|
807
|
+
// if (Math.floor(number) === number) return number
|
|
808
|
+
// const [int, decimals] = number.toString().split(".")
|
|
809
|
+
// if (precision <= 0) return int
|
|
810
|
+
// const numberTruncated = `${int}.${decimals.slice(0, precision)}`
|
|
811
|
+
// return numberTruncated
|
|
812
|
+
// }
|
|
813
|
+
|
|
1015
814
|
const unitShort = {
|
|
1016
815
|
year: "y",
|
|
1017
816
|
month: "m",
|
|
@@ -1334,6 +1133,119 @@ const fillLeft$1 = (value, biggestValue, char = " ") => {
|
|
|
1334
1133
|
return padded;
|
|
1335
1134
|
};
|
|
1336
1135
|
|
|
1136
|
+
const createCallOrderer = () => {
|
|
1137
|
+
const queue = [];
|
|
1138
|
+
const callWhenPreviousExecutionAreDone = (executionIndex, callback) => {
|
|
1139
|
+
if (queue[executionIndex]) {
|
|
1140
|
+
throw new Error(`${executionIndex} already used`);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
let allBeforeAreDone = true;
|
|
1144
|
+
if (executionIndex > 0) {
|
|
1145
|
+
let beforeIndex = executionIndex - 1;
|
|
1146
|
+
do {
|
|
1147
|
+
const value = queue[beforeIndex];
|
|
1148
|
+
if (!value) {
|
|
1149
|
+
allBeforeAreDone = false;
|
|
1150
|
+
break;
|
|
1151
|
+
}
|
|
1152
|
+
} while (beforeIndex--);
|
|
1153
|
+
}
|
|
1154
|
+
if (!allBeforeAreDone) {
|
|
1155
|
+
queue[executionIndex] = callback;
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
queue[executionIndex] = true;
|
|
1159
|
+
callback();
|
|
1160
|
+
let afterIndex = executionIndex + 1;
|
|
1161
|
+
while (afterIndex < queue.length) {
|
|
1162
|
+
const value = queue[afterIndex];
|
|
1163
|
+
if (value === undefined) {
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
if (typeof value === "function") {
|
|
1167
|
+
queue[afterIndex] = true;
|
|
1168
|
+
value();
|
|
1169
|
+
}
|
|
1170
|
+
afterIndex++;
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
return callWhenPreviousExecutionAreDone;
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
const renderBigSection = (params) => {
|
|
1177
|
+
return renderSection({
|
|
1178
|
+
width: 45,
|
|
1179
|
+
...params,
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const renderSection = ({
|
|
1184
|
+
title,
|
|
1185
|
+
content,
|
|
1186
|
+
dashColor = ANSI.GREY,
|
|
1187
|
+
width = 38,
|
|
1188
|
+
bottomSeparator = true,
|
|
1189
|
+
}) => {
|
|
1190
|
+
let section = "";
|
|
1191
|
+
|
|
1192
|
+
if (title) {
|
|
1193
|
+
const titleWidth = stripAnsi(title).length;
|
|
1194
|
+
const minWidthRequired = `--- … ---`.length;
|
|
1195
|
+
const needsTruncate = titleWidth + minWidthRequired >= width;
|
|
1196
|
+
if (needsTruncate) {
|
|
1197
|
+
const titleTruncated = title.slice(0, width - minWidthRequired);
|
|
1198
|
+
const leftDashes = ANSI.color("---", dashColor);
|
|
1199
|
+
const rightDashes = ANSI.color("---", dashColor);
|
|
1200
|
+
section += `${leftDashes} ${titleTruncated}… ${rightDashes}`;
|
|
1201
|
+
} else {
|
|
1202
|
+
const remainingWidth = width - titleWidth - 2; // 2 for spaces around the title
|
|
1203
|
+
const dashLeftCount = Math.floor(remainingWidth / 2);
|
|
1204
|
+
const dashRightCount = remainingWidth - dashLeftCount;
|
|
1205
|
+
const leftDashes = ANSI.color("-".repeat(dashLeftCount), dashColor);
|
|
1206
|
+
const rightDashes = ANSI.color("-".repeat(dashRightCount), dashColor);
|
|
1207
|
+
section += `${leftDashes} ${title} ${rightDashes}`;
|
|
1208
|
+
}
|
|
1209
|
+
section += "\n";
|
|
1210
|
+
} else {
|
|
1211
|
+
const topDashes = ANSI.color(`-`.repeat(width), dashColor);
|
|
1212
|
+
section += topDashes;
|
|
1213
|
+
section += "\n";
|
|
1214
|
+
}
|
|
1215
|
+
section += `${content}`;
|
|
1216
|
+
if (bottomSeparator) {
|
|
1217
|
+
section += "\n";
|
|
1218
|
+
const bottomDashes = ANSI.color(`-`.repeat(width), dashColor);
|
|
1219
|
+
section += bottomDashes;
|
|
1220
|
+
}
|
|
1221
|
+
return section;
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
const renderDetails = (data) => {
|
|
1225
|
+
const details = [];
|
|
1226
|
+
for (const key of Object.keys(data)) {
|
|
1227
|
+
const value = data[key];
|
|
1228
|
+
let valueString = "";
|
|
1229
|
+
valueString += ANSI.color(`${key}:`, ANSI.GREY);
|
|
1230
|
+
const useNonGreyAnsiColor =
|
|
1231
|
+
typeof value === "string" && value.includes("\x1b");
|
|
1232
|
+
valueString += " ";
|
|
1233
|
+
valueString += useNonGreyAnsiColor
|
|
1234
|
+
? value
|
|
1235
|
+
: ANSI.color(String(value), ANSI.GREY);
|
|
1236
|
+
details.push(valueString);
|
|
1237
|
+
}
|
|
1238
|
+
if (details.length === 0) {
|
|
1239
|
+
return "";
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
let string = "";
|
|
1243
|
+
string += ` ${ANSI.color("(", ANSI.GREY)}`;
|
|
1244
|
+
string += details.join(ANSI.color(", ", ANSI.GREY));
|
|
1245
|
+
string += ANSI.color(")", ANSI.GREY);
|
|
1246
|
+
return string;
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1337
1249
|
const LOG_LEVEL_OFF = "off";
|
|
1338
1250
|
|
|
1339
1251
|
const LOG_LEVEL_DEBUG = "debug";
|
|
@@ -1457,7 +1369,7 @@ const createDynamicLog = ({
|
|
|
1457
1369
|
const logLines = lastOutput.split(/\r\n|\r|\n/);
|
|
1458
1370
|
let visualLineCount = 0;
|
|
1459
1371
|
for (const logLine of logLines) {
|
|
1460
|
-
const width =
|
|
1372
|
+
const width = measureTextWidth(logLine);
|
|
1461
1373
|
if (width === 0) {
|
|
1462
1374
|
visualLineCount++;
|
|
1463
1375
|
} else {
|
|
@@ -1522,7 +1434,8 @@ const createDynamicLog = ({
|
|
|
1522
1434
|
update("");
|
|
1523
1435
|
|
|
1524
1436
|
writing = true;
|
|
1525
|
-
callback();
|
|
1437
|
+
callback(update);
|
|
1438
|
+
lastOutput = "";
|
|
1526
1439
|
writing = false;
|
|
1527
1440
|
|
|
1528
1441
|
update(ouputAfterCallback);
|
|
@@ -4457,217 +4370,6 @@ const getCoverageFromTestPlanResults = async (
|
|
|
4457
4370
|
|
|
4458
4371
|
const isV8Coverage = (coverage) => Boolean(coverage.result);
|
|
4459
4372
|
|
|
4460
|
-
const createCallOrderer = () => {
|
|
4461
|
-
const queue = [];
|
|
4462
|
-
const callWhenPreviousExecutionAreDone = (executionIndex, callback) => {
|
|
4463
|
-
if (queue[executionIndex]) {
|
|
4464
|
-
throw new Error(`${executionIndex} already used`);
|
|
4465
|
-
}
|
|
4466
|
-
|
|
4467
|
-
let allBeforeAreDone = true;
|
|
4468
|
-
if (executionIndex > 0) {
|
|
4469
|
-
let beforeIndex = executionIndex - 1;
|
|
4470
|
-
do {
|
|
4471
|
-
const value = queue[beforeIndex];
|
|
4472
|
-
if (!value) {
|
|
4473
|
-
allBeforeAreDone = false;
|
|
4474
|
-
break;
|
|
4475
|
-
}
|
|
4476
|
-
} while (beforeIndex--);
|
|
4477
|
-
}
|
|
4478
|
-
if (!allBeforeAreDone) {
|
|
4479
|
-
queue[executionIndex] = callback;
|
|
4480
|
-
return;
|
|
4481
|
-
}
|
|
4482
|
-
queue[executionIndex] = true;
|
|
4483
|
-
callback();
|
|
4484
|
-
let afterIndex = executionIndex + 1;
|
|
4485
|
-
while (afterIndex < queue.length) {
|
|
4486
|
-
const value = queue[afterIndex];
|
|
4487
|
-
if (value === undefined) {
|
|
4488
|
-
break;
|
|
4489
|
-
}
|
|
4490
|
-
if (typeof value === "function") {
|
|
4491
|
-
queue[afterIndex] = true;
|
|
4492
|
-
value();
|
|
4493
|
-
}
|
|
4494
|
-
afterIndex++;
|
|
4495
|
-
}
|
|
4496
|
-
};
|
|
4497
|
-
return callWhenPreviousExecutionAreDone;
|
|
4498
|
-
};
|
|
4499
|
-
|
|
4500
|
-
// https://gist.github.com/GaetanoPiazzolla/c40e1ebb9f709d091208e89baf9f4e00
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
const startMeasuringTotalCpuUsage = () => {
|
|
4504
|
-
let previousCpuArray = cpus();
|
|
4505
|
-
let previousMs = Date.now();
|
|
4506
|
-
let previousCpuUsage = cpuUsage();
|
|
4507
|
-
|
|
4508
|
-
const overall = {
|
|
4509
|
-
inactive: 100,
|
|
4510
|
-
active: 0,
|
|
4511
|
-
system: 0,
|
|
4512
|
-
user: 0,
|
|
4513
|
-
};
|
|
4514
|
-
const thisProcess = {
|
|
4515
|
-
active: 0,
|
|
4516
|
-
system: 0,
|
|
4517
|
-
user: 0,
|
|
4518
|
-
};
|
|
4519
|
-
const details = previousCpuArray.map(() => {
|
|
4520
|
-
return {
|
|
4521
|
-
inactive: 100,
|
|
4522
|
-
active: 0,
|
|
4523
|
-
system: 0,
|
|
4524
|
-
user: 0,
|
|
4525
|
-
};
|
|
4526
|
-
});
|
|
4527
|
-
|
|
4528
|
-
const samples = [];
|
|
4529
|
-
const interval = setInterval(() => {
|
|
4530
|
-
let cpuArray = cpus();
|
|
4531
|
-
const ms = Date.now();
|
|
4532
|
-
const ellapsedMs = ms - previousMs;
|
|
4533
|
-
const cpuUsageSampleArray = [];
|
|
4534
|
-
let overallSystemMs = 0;
|
|
4535
|
-
let overallUserMs = 0;
|
|
4536
|
-
let overallInactiveMs = 0;
|
|
4537
|
-
let overallActiveMs = 0;
|
|
4538
|
-
let overallMsEllapsed = 0;
|
|
4539
|
-
let index = 0;
|
|
4540
|
-
for (const cpu of cpuArray) {
|
|
4541
|
-
const previousCpuTimes = previousCpuArray[index].times;
|
|
4542
|
-
const cpuTimes = cpu.times;
|
|
4543
|
-
const systemMs = cpuTimes.sys - previousCpuTimes.sys;
|
|
4544
|
-
const userMs = cpuTimes.user - previousCpuTimes.user;
|
|
4545
|
-
const activeMs = systemMs + userMs;
|
|
4546
|
-
const inactiveMs = ellapsedMs - activeMs;
|
|
4547
|
-
const cpuUsageSample = {
|
|
4548
|
-
inactive: inactiveMs / ellapsedMs,
|
|
4549
|
-
active: activeMs / ellapsedMs,
|
|
4550
|
-
system: systemMs / ellapsedMs,
|
|
4551
|
-
user: userMs / ellapsedMs,
|
|
4552
|
-
};
|
|
4553
|
-
cpuUsageSampleArray.push(cpuUsageSample);
|
|
4554
|
-
|
|
4555
|
-
overallSystemMs += systemMs;
|
|
4556
|
-
overallUserMs += userMs;
|
|
4557
|
-
overallInactiveMs += inactiveMs;
|
|
4558
|
-
overallActiveMs += activeMs;
|
|
4559
|
-
overallMsEllapsed += ellapsedMs;
|
|
4560
|
-
index++;
|
|
4561
|
-
}
|
|
4562
|
-
const overallUsageSample = {
|
|
4563
|
-
inactive: overallInactiveMs / overallMsEllapsed,
|
|
4564
|
-
active: overallActiveMs / overallMsEllapsed,
|
|
4565
|
-
system: overallSystemMs / overallMsEllapsed,
|
|
4566
|
-
user: overallUserMs / overallMsEllapsed,
|
|
4567
|
-
};
|
|
4568
|
-
previousCpuArray = cpuArray;
|
|
4569
|
-
previousMs = ms;
|
|
4570
|
-
|
|
4571
|
-
const processCpuUsage = cpuUsage();
|
|
4572
|
-
const thisProcessSystemMs = Math.round(
|
|
4573
|
-
(processCpuUsage.system - previousCpuUsage.system) / 1000,
|
|
4574
|
-
);
|
|
4575
|
-
const thisProcessUserMs = Math.round(
|
|
4576
|
-
(processCpuUsage.user - previousCpuUsage.user) / 1000,
|
|
4577
|
-
);
|
|
4578
|
-
previousCpuUsage = processCpuUsage;
|
|
4579
|
-
|
|
4580
|
-
const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
|
|
4581
|
-
const thisProcessInactiveMs = overallMsEllapsed - thisProcessActiveMs;
|
|
4582
|
-
const thisProcessSample = {
|
|
4583
|
-
inactive: thisProcessInactiveMs / overallMsEllapsed,
|
|
4584
|
-
active: thisProcessActiveMs / overallMsEllapsed,
|
|
4585
|
-
system: thisProcessSystemMs / overallMsEllapsed,
|
|
4586
|
-
user: thisProcessUserMs / overallMsEllapsed,
|
|
4587
|
-
};
|
|
4588
|
-
samples.push({
|
|
4589
|
-
cpuUsageSampleArray,
|
|
4590
|
-
overallUsageSample,
|
|
4591
|
-
thisProcessSample,
|
|
4592
|
-
});
|
|
4593
|
-
if (samples.length === 10) {
|
|
4594
|
-
{
|
|
4595
|
-
let index = 0;
|
|
4596
|
-
for (const detail of details) {
|
|
4597
|
-
let systemSum = 0;
|
|
4598
|
-
let userSum = 0;
|
|
4599
|
-
let inactiveSum = 0;
|
|
4600
|
-
let activeSum = 0;
|
|
4601
|
-
for (const sample of samples) {
|
|
4602
|
-
const { cpuUsageSampleArray } = sample;
|
|
4603
|
-
const cpuUsageSample = cpuUsageSampleArray[index];
|
|
4604
|
-
inactiveSum += cpuUsageSample.inactive;
|
|
4605
|
-
activeSum += cpuUsageSample.active;
|
|
4606
|
-
systemSum += cpuUsageSample.system;
|
|
4607
|
-
userSum += cpuUsageSample.user;
|
|
4608
|
-
}
|
|
4609
|
-
Object.assign(detail, {
|
|
4610
|
-
inactive: inactiveSum / samples.length,
|
|
4611
|
-
active: activeSum / samples.length,
|
|
4612
|
-
system: systemSum / samples.length,
|
|
4613
|
-
user: userSum / samples.length,
|
|
4614
|
-
});
|
|
4615
|
-
index++;
|
|
4616
|
-
}
|
|
4617
|
-
}
|
|
4618
|
-
{
|
|
4619
|
-
let overallSystemSum = 0;
|
|
4620
|
-
let overallUserSum = 0;
|
|
4621
|
-
let overallInactiveSum = 0;
|
|
4622
|
-
let overallActiveSum = 0;
|
|
4623
|
-
for (const sample of samples) {
|
|
4624
|
-
const { overallUsageSample } = sample;
|
|
4625
|
-
overallSystemSum += overallUsageSample.system;
|
|
4626
|
-
overallUserSum += overallUsageSample.user;
|
|
4627
|
-
overallInactiveSum += overallUsageSample.inactive;
|
|
4628
|
-
overallActiveSum += overallUsageSample.active;
|
|
4629
|
-
}
|
|
4630
|
-
Object.assign(overall, {
|
|
4631
|
-
inactive: overallInactiveSum / samples.length,
|
|
4632
|
-
active: overallActiveSum / samples.length,
|
|
4633
|
-
system: overallSystemSum / samples.length,
|
|
4634
|
-
user: overallUserSum / samples.length,
|
|
4635
|
-
});
|
|
4636
|
-
}
|
|
4637
|
-
{
|
|
4638
|
-
let thisProcessSystemSum = 0;
|
|
4639
|
-
let thisProcessUserSum = 0;
|
|
4640
|
-
let thisProcessInactiveSum = 0;
|
|
4641
|
-
let thisProcessActiveSum = 0;
|
|
4642
|
-
for (const sample of samples) {
|
|
4643
|
-
const { thisProcessSample } = sample;
|
|
4644
|
-
thisProcessSystemSum += thisProcessSample.system;
|
|
4645
|
-
thisProcessUserSum += thisProcessSample.user;
|
|
4646
|
-
thisProcessInactiveSum += thisProcessSample.inactive;
|
|
4647
|
-
thisProcessActiveSum += thisProcessSample.active;
|
|
4648
|
-
}
|
|
4649
|
-
Object.assign(thisProcess, {
|
|
4650
|
-
inactive: thisProcessInactiveSum / samples.length,
|
|
4651
|
-
active: thisProcessActiveSum / samples.length,
|
|
4652
|
-
system: thisProcessSystemSum / samples.length,
|
|
4653
|
-
user: thisProcessUserSum / samples.length,
|
|
4654
|
-
});
|
|
4655
|
-
}
|
|
4656
|
-
samples.length = 0;
|
|
4657
|
-
}
|
|
4658
|
-
}, 15);
|
|
4659
|
-
interval.unref();
|
|
4660
|
-
|
|
4661
|
-
return {
|
|
4662
|
-
overall,
|
|
4663
|
-
thisProcess,
|
|
4664
|
-
details,
|
|
4665
|
-
stop: () => {
|
|
4666
|
-
clearInterval(interval);
|
|
4667
|
-
},
|
|
4668
|
-
};
|
|
4669
|
-
};
|
|
4670
|
-
|
|
4671
4373
|
const githubAnnotationFromError = (
|
|
4672
4374
|
error,
|
|
4673
4375
|
{ rootDirectoryUrl, execution },
|
|
@@ -5955,79 +5657,6 @@ const renderStatusRepartition = (counters, { showProgression } = {}) => {
|
|
|
5955
5657
|
return `${parts.join(", ")}`;
|
|
5956
5658
|
};
|
|
5957
5659
|
|
|
5958
|
-
const renderBigSection = (params) => {
|
|
5959
|
-
return renderSection({
|
|
5960
|
-
width: 45,
|
|
5961
|
-
...params,
|
|
5962
|
-
});
|
|
5963
|
-
};
|
|
5964
|
-
|
|
5965
|
-
const renderSection = ({
|
|
5966
|
-
title,
|
|
5967
|
-
content,
|
|
5968
|
-
dashColor = ANSI.GREY,
|
|
5969
|
-
width = 38,
|
|
5970
|
-
bottomSeparator = true,
|
|
5971
|
-
}) => {
|
|
5972
|
-
let section = "";
|
|
5973
|
-
|
|
5974
|
-
if (title) {
|
|
5975
|
-
const titleWidth = stripAnsi(title).length;
|
|
5976
|
-
const minWidthRequired = `--- … ---`.length;
|
|
5977
|
-
const needsTruncate = titleWidth + minWidthRequired >= width;
|
|
5978
|
-
if (needsTruncate) {
|
|
5979
|
-
const titleTruncated = title.slice(0, width - minWidthRequired);
|
|
5980
|
-
const leftDashes = ANSI.color("---", dashColor);
|
|
5981
|
-
const rightDashes = ANSI.color("---", dashColor);
|
|
5982
|
-
section += `${leftDashes} ${titleTruncated}… ${rightDashes}`;
|
|
5983
|
-
} else {
|
|
5984
|
-
const remainingWidth = width - titleWidth - 2; // 2 for spaces around the title
|
|
5985
|
-
const dashLeftCount = Math.floor(remainingWidth / 2);
|
|
5986
|
-
const dashRightCount = remainingWidth - dashLeftCount;
|
|
5987
|
-
const leftDashes = ANSI.color("-".repeat(dashLeftCount), dashColor);
|
|
5988
|
-
const rightDashes = ANSI.color("-".repeat(dashRightCount), dashColor);
|
|
5989
|
-
section += `${leftDashes} ${title} ${rightDashes}`;
|
|
5990
|
-
}
|
|
5991
|
-
section += "\n";
|
|
5992
|
-
} else {
|
|
5993
|
-
const topDashes = ANSI.color(`-`.repeat(width), dashColor);
|
|
5994
|
-
section += topDashes;
|
|
5995
|
-
section += "\n";
|
|
5996
|
-
}
|
|
5997
|
-
section += `${content}`;
|
|
5998
|
-
if (bottomSeparator) {
|
|
5999
|
-
section += "\n";
|
|
6000
|
-
const bottomDashes = ANSI.color(`-`.repeat(width), dashColor);
|
|
6001
|
-
section += bottomDashes;
|
|
6002
|
-
}
|
|
6003
|
-
return section;
|
|
6004
|
-
};
|
|
6005
|
-
|
|
6006
|
-
const renderDetails = (data) => {
|
|
6007
|
-
const details = [];
|
|
6008
|
-
for (const key of Object.keys(data)) {
|
|
6009
|
-
const value = data[key];
|
|
6010
|
-
let valueString = "";
|
|
6011
|
-
valueString += ANSI.color(`${key}:`, ANSI.GREY);
|
|
6012
|
-
const useNonGreyAnsiColor =
|
|
6013
|
-
typeof value === "string" && value.includes("\x1b");
|
|
6014
|
-
valueString += " ";
|
|
6015
|
-
valueString += useNonGreyAnsiColor
|
|
6016
|
-
? value
|
|
6017
|
-
: ANSI.color(String(value), ANSI.GREY);
|
|
6018
|
-
details.push(valueString);
|
|
6019
|
-
}
|
|
6020
|
-
if (details.length === 0) {
|
|
6021
|
-
return "";
|
|
6022
|
-
}
|
|
6023
|
-
|
|
6024
|
-
let string = "";
|
|
6025
|
-
string += ` ${ANSI.color("(", ANSI.GREY)}`;
|
|
6026
|
-
string += details.join(ANSI.color(", ", ANSI.GREY));
|
|
6027
|
-
string += ANSI.color(")", ANSI.GREY);
|
|
6028
|
-
return string;
|
|
6029
|
-
};
|
|
6030
|
-
|
|
6031
5660
|
/*
|
|
6032
5661
|
* Export a function capable to run a file on a runtime.
|
|
6033
5662
|
*
|
|
@@ -6731,22 +6360,12 @@ const executeTestPlan = async ({
|
|
|
6731
6360
|
});
|
|
6732
6361
|
}
|
|
6733
6362
|
|
|
6734
|
-
const
|
|
6735
|
-
operation.addEndCallback(
|
|
6736
|
-
const processCpuUsageMonitoring =
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
return cpuUsage.overall.active;
|
|
6741
|
-
});
|
|
6742
|
-
const processMemoryUsageMonitoring = startMonitoringMetric(() => {
|
|
6743
|
-
return memoryUsage().rss;
|
|
6744
|
-
});
|
|
6745
|
-
const osMemoryUsageMonitoring = startMonitoringMetric(() => {
|
|
6746
|
-
const total = totalmem();
|
|
6747
|
-
const free = freemem();
|
|
6748
|
-
return total - free;
|
|
6749
|
-
});
|
|
6363
|
+
const cpuMonitoring = startMonitoringCpuUsage();
|
|
6364
|
+
operation.addEndCallback(cpuMonitoring.stop);
|
|
6365
|
+
const [processCpuUsageMonitoring, osCpuUsageMonitoring] = cpuMonitoring;
|
|
6366
|
+
const memoryMonitoring = startMonitoringMemoryUsage();
|
|
6367
|
+
const [processMemoryUsageMonitoring, osMemoryUsageMonitoring] =
|
|
6368
|
+
memoryMonitoring;
|
|
6750
6369
|
|
|
6751
6370
|
const timingsOrigin = Date.now();
|
|
6752
6371
|
const takeTiming = () => {
|
|
@@ -6762,9 +6381,9 @@ const executeTestPlan = async ({
|
|
|
6762
6381
|
: process.platform === "linux"
|
|
6763
6382
|
? "linux"
|
|
6764
6383
|
: "other",
|
|
6765
|
-
version:
|
|
6384
|
+
version: getOsVersion(),
|
|
6766
6385
|
availableCpu: countAvailableCpus(),
|
|
6767
|
-
availableMemory:
|
|
6386
|
+
availableMemory: getAvailableMemory(),
|
|
6768
6387
|
},
|
|
6769
6388
|
runtime: {
|
|
6770
6389
|
name: "node",
|
|
@@ -7731,59 +7350,6 @@ To fix this warning:
|
|
|
7731
7350
|
return testPlanResult;
|
|
7732
7351
|
};
|
|
7733
7352
|
|
|
7734
|
-
const startMonitoringMetric = (measure) => {
|
|
7735
|
-
const metrics = [];
|
|
7736
|
-
const takeMeasure = () => {
|
|
7737
|
-
const value = measure();
|
|
7738
|
-
metrics.push(value);
|
|
7739
|
-
return value;
|
|
7740
|
-
};
|
|
7741
|
-
|
|
7742
|
-
const info = {
|
|
7743
|
-
start: takeMeasure(),
|
|
7744
|
-
min: null,
|
|
7745
|
-
max: null,
|
|
7746
|
-
median: null,
|
|
7747
|
-
end: null,
|
|
7748
|
-
};
|
|
7749
|
-
return {
|
|
7750
|
-
info,
|
|
7751
|
-
measure: takeMeasure,
|
|
7752
|
-
end: () => {
|
|
7753
|
-
info.end = takeMeasure();
|
|
7754
|
-
metrics.sort((a, b) => a - b);
|
|
7755
|
-
info.min = metrics[0];
|
|
7756
|
-
info.max = metrics[metrics.length - 1];
|
|
7757
|
-
info.median = medianFromSortedArray(metrics);
|
|
7758
|
-
metrics.length = 0;
|
|
7759
|
-
},
|
|
7760
|
-
};
|
|
7761
|
-
};
|
|
7762
|
-
|
|
7763
|
-
const medianFromSortedArray = (array) => {
|
|
7764
|
-
const length = array.length;
|
|
7765
|
-
const isOdd = length % 2 === 1;
|
|
7766
|
-
if (isOdd) {
|
|
7767
|
-
const medianNumberIndex = (length - 1) / 2;
|
|
7768
|
-
const medianNumber = array[medianNumberIndex];
|
|
7769
|
-
return medianNumber;
|
|
7770
|
-
}
|
|
7771
|
-
const rightMiddleNumberIndex = length / 2;
|
|
7772
|
-
const leftMiddleNumberIndex = rightMiddleNumberIndex - 1;
|
|
7773
|
-
const leftMiddleNumber = array[leftMiddleNumberIndex];
|
|
7774
|
-
const rightMiddleNumber = array[rightMiddleNumberIndex];
|
|
7775
|
-
const medianNumber = (leftMiddleNumber + rightMiddleNumber) / 2;
|
|
7776
|
-
return medianNumber;
|
|
7777
|
-
};
|
|
7778
|
-
|
|
7779
|
-
const countAvailableCpus = () => {
|
|
7780
|
-
if (typeof availableParallelism === "function") {
|
|
7781
|
-
return availableParallelism();
|
|
7782
|
-
}
|
|
7783
|
-
const cpuArray = cpus();
|
|
7784
|
-
return cpuArray.length || 1;
|
|
7785
|
-
};
|
|
7786
|
-
|
|
7787
7353
|
const mutateCountersBeforeExecutionStarts = (counters) => {
|
|
7788
7354
|
counters.executing++;
|
|
7789
7355
|
counters.waiting--;
|