@codingame/monaco-vscode-extensions-service-override 1.83.15-next.0 → 1.83.16
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/package.json +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +3 -3
- package/vscode/src/vs/base/common/prefixTree.js +0 -131
- package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +0 -103
- package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +0 -28
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +0 -336
- package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-extensions-service-override",
|
|
3
|
-
"version": "1.83.
|
|
3
|
+
"version": "1.83.16",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@1.83.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@1.83.16",
|
|
22
22
|
"monaco-editor": "0.44.0",
|
|
23
23
|
"vscode-semver": "npm:semver@=5.5.0",
|
|
24
|
-
"@codingame/monaco-vscode-files-service-override": "1.83.
|
|
24
|
+
"@codingame/monaco-vscode-files-service-override": "1.83.16"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -3,16 +3,16 @@ import { Disposable, MutableDisposable, DisposableStore, toDisposable } from 'mo
|
|
|
3
3
|
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
4
4
|
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
5
5
|
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
6
|
-
import { MutableObservableValue } from '
|
|
6
|
+
import { MutableObservableValue } from 'vscode/vscode/vs/workbench/contrib/testing/common/observableValue';
|
|
7
7
|
import { ITestItem, ITestMessage, TestsDiffOp } from 'vscode/vscode/vs/workbench/contrib/testing/common/testTypes';
|
|
8
8
|
import { TestCoverage } from '../../contrib/testing/common/testCoverage.js';
|
|
9
9
|
import { ITestProfileService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testProfileService';
|
|
10
|
-
import { LiveTestResult } from '
|
|
10
|
+
import { LiveTestResult } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResult';
|
|
11
11
|
import { ITestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
|
|
12
12
|
import { ITestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
|
|
13
13
|
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
|
|
14
14
|
import { MainContext, ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
|
|
15
|
-
import { WellDefinedPrefixTree } from '
|
|
15
|
+
import { WellDefinedPrefixTree } from 'vscode/vscode/vs/base/common/prefixTree';
|
|
16
16
|
import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
|
|
17
17
|
|
|
18
18
|
let MainThreadTesting = class MainThreadTesting extends Disposable {
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const unset = Symbol('unset');
|
|
2
|
-
class WellDefinedPrefixTree {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.root = ( new Node());
|
|
5
|
-
this._size = 0;
|
|
6
|
-
}
|
|
7
|
-
get size() {
|
|
8
|
-
return this._size;
|
|
9
|
-
}
|
|
10
|
-
insert(key, value) {
|
|
11
|
-
this.opNode(key, n => n.value = value);
|
|
12
|
-
}
|
|
13
|
-
mutate(key, mutate) {
|
|
14
|
-
this.opNode(key, n => n.value = mutate(n.value === unset ? undefined : n.value));
|
|
15
|
-
}
|
|
16
|
-
delete(key) {
|
|
17
|
-
const path = [{ part: '', node: this.root }];
|
|
18
|
-
let i = 0;
|
|
19
|
-
for (const part of key) {
|
|
20
|
-
const node = path[i].node.children?.get(part);
|
|
21
|
-
if (!node) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
path.push({ part, node });
|
|
25
|
-
i++;
|
|
26
|
-
}
|
|
27
|
-
const value = path[i].node.value;
|
|
28
|
-
if (value === unset) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
this._size--;
|
|
32
|
-
for (; i > 0; i--) {
|
|
33
|
-
const parent = path[i - 1];
|
|
34
|
-
parent.node.children.delete(path[i].part);
|
|
35
|
-
if (parent.node.children.size > 0 || parent.node.value !== unset) {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
find(key) {
|
|
42
|
-
let node = this.root;
|
|
43
|
-
for (const segment of key) {
|
|
44
|
-
const next = node.children?.get(segment);
|
|
45
|
-
if (!next) {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
node = next;
|
|
49
|
-
}
|
|
50
|
-
return node.value === unset ? undefined : node.value;
|
|
51
|
-
}
|
|
52
|
-
hasKeyOrParent(key) {
|
|
53
|
-
let node = this.root;
|
|
54
|
-
for (const segment of key) {
|
|
55
|
-
const next = node.children?.get(segment);
|
|
56
|
-
if (!next) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
if (next.value !== unset) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
node = next;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
hasKeyOrChildren(key) {
|
|
67
|
-
let node = this.root;
|
|
68
|
-
for (const segment of key) {
|
|
69
|
-
const next = node.children?.get(segment);
|
|
70
|
-
if (!next) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
node = next;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
hasKey(key) {
|
|
78
|
-
let node = this.root;
|
|
79
|
-
for (const segment of key) {
|
|
80
|
-
const next = node.children?.get(segment);
|
|
81
|
-
if (!next) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
node = next;
|
|
85
|
-
}
|
|
86
|
-
return node.value !== unset;
|
|
87
|
-
}
|
|
88
|
-
opNode(key, fn) {
|
|
89
|
-
let node = this.root;
|
|
90
|
-
for (const part of key) {
|
|
91
|
-
if (!node.children) {
|
|
92
|
-
const next = ( new Node());
|
|
93
|
-
node.children = ( new Map([[part, next]]));
|
|
94
|
-
node = next;
|
|
95
|
-
}
|
|
96
|
-
else if (!( node.children.has(part))) {
|
|
97
|
-
const next = ( new Node());
|
|
98
|
-
node.children.set(part, next);
|
|
99
|
-
node = next;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
node = node.children.get(part);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (node.value === unset) {
|
|
106
|
-
this._size++;
|
|
107
|
-
}
|
|
108
|
-
fn(node);
|
|
109
|
-
}
|
|
110
|
-
*values() {
|
|
111
|
-
const stack = [this.root];
|
|
112
|
-
while (stack.length > 0) {
|
|
113
|
-
const node = stack.pop();
|
|
114
|
-
if (node.value !== unset) {
|
|
115
|
-
yield node.value;
|
|
116
|
-
}
|
|
117
|
-
if (node.children) {
|
|
118
|
-
for (const child of ( node.children.values())) {
|
|
119
|
-
stack.push(child);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
class Node {
|
|
126
|
-
constructor() {
|
|
127
|
-
this.value = unset;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { WellDefinedPrefixTree };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
|
|
2
|
-
import { statePriority, makeEmptyCounts, maxPriority } from './testingStates.js';
|
|
3
|
-
|
|
4
|
-
const isDurationAccessor = (accessor) => 'getOwnDuration' in accessor;
|
|
5
|
-
const getComputedState = (accessor, node, force = false) => {
|
|
6
|
-
let computed = accessor.getCurrentComputedState(node);
|
|
7
|
-
if (computed === undefined || force) {
|
|
8
|
-
computed = accessor.getOwnState(node) ?? 0 ;
|
|
9
|
-
let childrenCount = 0;
|
|
10
|
-
const stateMap = makeEmptyCounts();
|
|
11
|
-
for (const child of accessor.getChildren(node)) {
|
|
12
|
-
const childComputed = getComputedState(accessor, child);
|
|
13
|
-
childrenCount++;
|
|
14
|
-
stateMap[childComputed]++;
|
|
15
|
-
computed = childComputed === 5 && computed === 0
|
|
16
|
-
? 5 : maxPriority(computed, childComputed);
|
|
17
|
-
}
|
|
18
|
-
if (childrenCount > LARGE_NODE_THRESHOLD) {
|
|
19
|
-
largeNodeChildrenStates.set(node, stateMap);
|
|
20
|
-
}
|
|
21
|
-
accessor.setComputedState(node, computed);
|
|
22
|
-
}
|
|
23
|
-
return computed;
|
|
24
|
-
};
|
|
25
|
-
const getComputedDuration = (accessor, node, force = false) => {
|
|
26
|
-
let computed = accessor.getCurrentComputedDuration(node);
|
|
27
|
-
if (computed === undefined || force) {
|
|
28
|
-
const own = accessor.getOwnDuration(node);
|
|
29
|
-
if (own !== undefined) {
|
|
30
|
-
computed = own;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
computed = undefined;
|
|
34
|
-
for (const child of accessor.getChildren(node)) {
|
|
35
|
-
const d = getComputedDuration(accessor, child);
|
|
36
|
-
if (d !== undefined) {
|
|
37
|
-
computed = (computed || 0) + d;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
accessor.setComputedDuration(node, computed);
|
|
42
|
-
}
|
|
43
|
-
return computed;
|
|
44
|
-
};
|
|
45
|
-
const LARGE_NODE_THRESHOLD = 64;
|
|
46
|
-
const largeNodeChildrenStates = ( new WeakMap());
|
|
47
|
-
const refreshComputedState = (accessor, node, explicitNewComputedState, refreshDuration = true) => {
|
|
48
|
-
const oldState = accessor.getCurrentComputedState(node);
|
|
49
|
-
const oldPriority = statePriority[oldState];
|
|
50
|
-
const newState = explicitNewComputedState ?? getComputedState(accessor, node, true);
|
|
51
|
-
const newPriority = statePriority[newState];
|
|
52
|
-
const toUpdate = ( new Set());
|
|
53
|
-
if (newPriority !== oldPriority) {
|
|
54
|
-
accessor.setComputedState(node, newState);
|
|
55
|
-
toUpdate.add(node);
|
|
56
|
-
let moveFromState = oldState;
|
|
57
|
-
let moveToState = newState;
|
|
58
|
-
for (const parent of accessor.getParents(node)) {
|
|
59
|
-
const lnm = largeNodeChildrenStates.get(parent);
|
|
60
|
-
if (lnm) {
|
|
61
|
-
lnm[moveFromState]--;
|
|
62
|
-
lnm[moveToState]++;
|
|
63
|
-
}
|
|
64
|
-
const prev = accessor.getCurrentComputedState(parent);
|
|
65
|
-
if (newPriority > oldPriority) {
|
|
66
|
-
if (prev !== undefined && statePriority[prev] >= newPriority) {
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
if (lnm && lnm[moveToState] > 1) {
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
accessor.setComputedState(parent, newState);
|
|
73
|
-
toUpdate.add(parent);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
if (prev === undefined || statePriority[prev] > oldPriority) {
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
if (lnm && lnm[moveFromState] > 0) {
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
moveToState = getComputedState(accessor, parent, true);
|
|
83
|
-
accessor.setComputedState(parent, moveToState);
|
|
84
|
-
toUpdate.add(parent);
|
|
85
|
-
}
|
|
86
|
-
moveFromState = prev;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (isDurationAccessor(accessor) && refreshDuration) {
|
|
90
|
-
for (const parent of Iterable.concat(Iterable.single(node), accessor.getParents(node))) {
|
|
91
|
-
const oldDuration = accessor.getCurrentComputedDuration(parent);
|
|
92
|
-
const newDuration = getComputedDuration(accessor, parent, true);
|
|
93
|
-
if (oldDuration === newDuration) {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
accessor.setComputedDuration(parent, newDuration);
|
|
97
|
-
toUpdate.add(parent);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return toUpdate;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { refreshComputedState };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
2
|
-
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
-
|
|
4
|
-
class MutableObservableValue extends Disposable {
|
|
5
|
-
get value() {
|
|
6
|
-
return this._value;
|
|
7
|
-
}
|
|
8
|
-
set value(v) {
|
|
9
|
-
if (v !== this._value) {
|
|
10
|
-
this._value = v;
|
|
11
|
-
this.changeEmitter.fire(v);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
static stored(stored, defaultValue) {
|
|
15
|
-
const o = ( new MutableObservableValue(stored.get(defaultValue)));
|
|
16
|
-
o._register(stored);
|
|
17
|
-
o._register(o.onDidChange(value => stored.store(value)));
|
|
18
|
-
return o;
|
|
19
|
-
}
|
|
20
|
-
constructor(_value) {
|
|
21
|
-
super();
|
|
22
|
-
this._value = _value;
|
|
23
|
-
this.changeEmitter = this._register(( new Emitter()));
|
|
24
|
-
this.onDidChange = this.changeEmitter.event;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { MutableObservableValue };
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
2
|
-
import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
3
|
-
import { Event, Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
4
|
-
import { Lazy } from 'monaco-editor/esm/vs/base/common/lazy.js';
|
|
5
|
-
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
6
|
-
import { language } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
7
|
-
import { removeAnsiEscapeCodes } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
8
|
-
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
9
|
-
import { refreshComputedState } from './getComputedState.js';
|
|
10
|
-
import { MutableObservableValue } from './observableValue.js';
|
|
11
|
-
import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
|
|
12
|
-
import { makeEmptyCounts, terminalStatePriorities, maxPriority } from './testingStates.js';
|
|
13
|
-
import { TestResultItem, getMarkId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testTypes';
|
|
14
|
-
|
|
15
|
-
({
|
|
16
|
-
buffers: [],
|
|
17
|
-
length: 0,
|
|
18
|
-
onDidWriteData: Event.None,
|
|
19
|
-
endPromise: Promise.resolve(),
|
|
20
|
-
getRange: () => VSBuffer.alloc(0),
|
|
21
|
-
getRangeIter: () => [],
|
|
22
|
-
});
|
|
23
|
-
class TaskRawOutput {
|
|
24
|
-
constructor() {
|
|
25
|
-
this.writeDataEmitter = ( new Emitter());
|
|
26
|
-
this.endDeferred = ( new DeferredPromise());
|
|
27
|
-
this.offset = 0;
|
|
28
|
-
this.onDidWriteData = this.writeDataEmitter.event;
|
|
29
|
-
this.endPromise = this.endDeferred.p;
|
|
30
|
-
this.buffers = [];
|
|
31
|
-
}
|
|
32
|
-
get length() {
|
|
33
|
-
return this.offset;
|
|
34
|
-
}
|
|
35
|
-
getRange(start, length) {
|
|
36
|
-
const buf = VSBuffer.alloc(length);
|
|
37
|
-
let bufLastWrite = 0;
|
|
38
|
-
for (const chunk of this.getRangeIter(start, length)) {
|
|
39
|
-
buf.buffer.set(chunk.buffer, bufLastWrite);
|
|
40
|
-
bufLastWrite += chunk.byteLength;
|
|
41
|
-
}
|
|
42
|
-
return bufLastWrite < length ? buf.slice(0, bufLastWrite) : buf;
|
|
43
|
-
}
|
|
44
|
-
*getRangeIter(start, length) {
|
|
45
|
-
let soFar = 0;
|
|
46
|
-
let internalLastRead = 0;
|
|
47
|
-
for (const b of this.buffers) {
|
|
48
|
-
if (internalLastRead + b.byteLength <= start) {
|
|
49
|
-
internalLastRead += b.byteLength;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const bstart = Math.max(0, start - internalLastRead);
|
|
53
|
-
const bend = Math.min(b.byteLength, bstart + length - soFar);
|
|
54
|
-
yield b.slice(bstart, bend);
|
|
55
|
-
soFar += bend - bstart;
|
|
56
|
-
internalLastRead += b.byteLength;
|
|
57
|
-
if (soFar === length) {
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
append(data, marker) {
|
|
63
|
-
const offset = this.offset;
|
|
64
|
-
let length = data.byteLength;
|
|
65
|
-
if (marker === undefined) {
|
|
66
|
-
this.push(data);
|
|
67
|
-
return { offset, length };
|
|
68
|
-
}
|
|
69
|
-
const start = VSBuffer.fromString(getMarkCode(marker, true));
|
|
70
|
-
const end = VSBuffer.fromString(getMarkCode(marker, false));
|
|
71
|
-
length += start.byteLength + end.byteLength;
|
|
72
|
-
this.push(start);
|
|
73
|
-
let trimLen = data.byteLength;
|
|
74
|
-
for (; trimLen > 0; trimLen--) {
|
|
75
|
-
const last = data.buffer[trimLen - 1];
|
|
76
|
-
if (last !== 13 && last !== 10 ) {
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
this.push(data.slice(0, trimLen));
|
|
81
|
-
this.push(end);
|
|
82
|
-
this.push(data.slice(trimLen));
|
|
83
|
-
return { offset, length };
|
|
84
|
-
}
|
|
85
|
-
push(data) {
|
|
86
|
-
if (data.byteLength === 0) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
this.buffers.push(data);
|
|
90
|
-
this.writeDataEmitter.fire(data);
|
|
91
|
-
this.offset += data.byteLength;
|
|
92
|
-
}
|
|
93
|
-
end() {
|
|
94
|
-
this.endDeferred.complete();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const getMarkCode = (marker, start) => `\x1b]633;SetMark;Id=${getMarkId(marker, start)};Hidden\x07`;
|
|
98
|
-
const itemToNode = (controllerId, item, parent) => ({
|
|
99
|
-
controllerId,
|
|
100
|
-
expand: 0 ,
|
|
101
|
-
item: { ...item },
|
|
102
|
-
children: [],
|
|
103
|
-
tasks: [],
|
|
104
|
-
ownComputedState: 0 ,
|
|
105
|
-
computedState: 0 ,
|
|
106
|
-
});
|
|
107
|
-
class LiveTestResult extends Disposable {
|
|
108
|
-
get completedAt() {
|
|
109
|
-
return this._completedAt;
|
|
110
|
-
}
|
|
111
|
-
get tests() {
|
|
112
|
-
return ( this.testById.values());
|
|
113
|
-
}
|
|
114
|
-
constructor(id, persist, request) {
|
|
115
|
-
super();
|
|
116
|
-
this.id = id;
|
|
117
|
-
this.persist = persist;
|
|
118
|
-
this.request = request;
|
|
119
|
-
this.completeEmitter = this._register(( new Emitter()));
|
|
120
|
-
this.newTaskEmitter = this._register(( new Emitter()));
|
|
121
|
-
this.endTaskEmitter = this._register(( new Emitter()));
|
|
122
|
-
this.changeEmitter = this._register(( new Emitter()));
|
|
123
|
-
this.testById = ( new Map());
|
|
124
|
-
this.testMarkerCounter = 0;
|
|
125
|
-
this.startedAt = Date.now();
|
|
126
|
-
this.onChange = this.changeEmitter.event;
|
|
127
|
-
this.onComplete = this.completeEmitter.event;
|
|
128
|
-
this.onNewTask = this.newTaskEmitter.event;
|
|
129
|
-
this.onEndTask = this.endTaskEmitter.event;
|
|
130
|
-
this.tasks = [];
|
|
131
|
-
this.name = ( localizeWithPath(
|
|
132
|
-
'vs/workbench/contrib/testing/common/testResult',
|
|
133
|
-
'runFinished',
|
|
134
|
-
'Test run at {0}',
|
|
135
|
-
( new Date()).toLocaleString(language)
|
|
136
|
-
));
|
|
137
|
-
this.counts = makeEmptyCounts();
|
|
138
|
-
this.computedStateAccessor = {
|
|
139
|
-
getOwnState: i => i.ownComputedState,
|
|
140
|
-
getCurrentComputedState: i => i.computedState,
|
|
141
|
-
setComputedState: (i, s) => i.computedState = s,
|
|
142
|
-
getChildren: i => i.children,
|
|
143
|
-
getParents: i => {
|
|
144
|
-
const { testById: testByExtId } = this;
|
|
145
|
-
return (function* () {
|
|
146
|
-
const parentId = TestId.fromString(i.item.extId).parentId;
|
|
147
|
-
if (parentId) {
|
|
148
|
-
for (const id of parentId.idsToRoot()) {
|
|
149
|
-
yield testByExtId.get(( id.toString()));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
})();
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
this.doSerialize = ( new Lazy(() => ({
|
|
156
|
-
id: this.id,
|
|
157
|
-
completedAt: this.completedAt,
|
|
158
|
-
tasks: ( this.tasks.map(t => ({ id: t.id, name: t.name }))),
|
|
159
|
-
name: this.name,
|
|
160
|
-
request: this.request,
|
|
161
|
-
items: ( [...( this.testById.values())].map(TestResultItem.serializeWithoutMessages)),
|
|
162
|
-
})));
|
|
163
|
-
this.doSerializeWithMessages = ( new Lazy(() => ({
|
|
164
|
-
id: this.id,
|
|
165
|
-
completedAt: this.completedAt,
|
|
166
|
-
tasks: ( this.tasks.map(t => ({ id: t.id, name: t.name }))),
|
|
167
|
-
name: this.name,
|
|
168
|
-
request: this.request,
|
|
169
|
-
items: ( [...( this.testById.values())].map(TestResultItem.serialize)),
|
|
170
|
-
})));
|
|
171
|
-
}
|
|
172
|
-
getStateById(extTestId) {
|
|
173
|
-
return this.testById.get(extTestId);
|
|
174
|
-
}
|
|
175
|
-
appendOutput(output, taskId, location, testId) {
|
|
176
|
-
const preview = output.byteLength > 100 ? ( output.slice(0, 100).toString()) + '…' : ( output.toString());
|
|
177
|
-
let marker;
|
|
178
|
-
if (testId || location) {
|
|
179
|
-
marker = this.testMarkerCounter++;
|
|
180
|
-
}
|
|
181
|
-
const index = this.mustGetTaskIndex(taskId);
|
|
182
|
-
const task = this.tasks[index];
|
|
183
|
-
const { offset, length } = task.output.append(output, marker);
|
|
184
|
-
const message = {
|
|
185
|
-
location,
|
|
186
|
-
message: removeAnsiEscapeCodes(preview),
|
|
187
|
-
offset,
|
|
188
|
-
length,
|
|
189
|
-
marker,
|
|
190
|
-
type: 1 ,
|
|
191
|
-
};
|
|
192
|
-
const test = testId && this.testById.get(testId);
|
|
193
|
-
if (test) {
|
|
194
|
-
test.tasks[index].messages.push(message);
|
|
195
|
-
this.changeEmitter.fire({ item: test, result: this, reason: 2 , message });
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
task.otherMessages.push(message);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
addTask(task) {
|
|
202
|
-
this.tasks.push({ ...task, coverage: this._register(( new MutableObservableValue(undefined))), otherMessages: [], output: ( new TaskRawOutput()) });
|
|
203
|
-
for (const test of this.tests) {
|
|
204
|
-
test.tasks.push({ duration: undefined, messages: [], state: 0 });
|
|
205
|
-
}
|
|
206
|
-
this.newTaskEmitter.fire(this.tasks.length - 1);
|
|
207
|
-
}
|
|
208
|
-
addTestChainToRun(controllerId, chain) {
|
|
209
|
-
let parent = this.testById.get(chain[0].extId);
|
|
210
|
-
if (!parent) {
|
|
211
|
-
parent = this.addTestToRun(controllerId, chain[0], null);
|
|
212
|
-
}
|
|
213
|
-
for (let i = 1; i < chain.length; i++) {
|
|
214
|
-
parent = this.addTestToRun(controllerId, chain[i], parent.item.extId);
|
|
215
|
-
}
|
|
216
|
-
return undefined;
|
|
217
|
-
}
|
|
218
|
-
updateState(testId, taskId, state, duration) {
|
|
219
|
-
const entry = this.testById.get(testId);
|
|
220
|
-
if (!entry) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const index = this.mustGetTaskIndex(taskId);
|
|
224
|
-
const oldTerminalStatePrio = terminalStatePriorities[entry.tasks[index].state];
|
|
225
|
-
const newTerminalStatePrio = terminalStatePriorities[state];
|
|
226
|
-
if (oldTerminalStatePrio !== undefined &&
|
|
227
|
-
(newTerminalStatePrio === undefined || newTerminalStatePrio < oldTerminalStatePrio)) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
this.fireUpdateAndRefresh(entry, index, state, duration);
|
|
231
|
-
}
|
|
232
|
-
appendMessage(testId, taskId, message) {
|
|
233
|
-
const entry = this.testById.get(testId);
|
|
234
|
-
if (!entry) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
entry.tasks[this.mustGetTaskIndex(taskId)].messages.push(message);
|
|
238
|
-
this.changeEmitter.fire({ item: entry, result: this, reason: 2 , message });
|
|
239
|
-
}
|
|
240
|
-
markTaskComplete(taskId) {
|
|
241
|
-
const index = this.mustGetTaskIndex(taskId);
|
|
242
|
-
const task = this.tasks[index];
|
|
243
|
-
task.running = false;
|
|
244
|
-
task.output.end();
|
|
245
|
-
this.setAllToState(0 , taskId, t => t.state === 1 || t.state === 2 );
|
|
246
|
-
this.endTaskEmitter.fire(index);
|
|
247
|
-
}
|
|
248
|
-
markComplete() {
|
|
249
|
-
if (this._completedAt !== undefined) {
|
|
250
|
-
throw new Error('cannot complete a test result multiple times');
|
|
251
|
-
}
|
|
252
|
-
for (const task of this.tasks) {
|
|
253
|
-
if (task.running) {
|
|
254
|
-
this.markTaskComplete(task.id);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
this._completedAt = Date.now();
|
|
258
|
-
this.completeEmitter.fire();
|
|
259
|
-
}
|
|
260
|
-
markRetired(testIds) {
|
|
261
|
-
for (const [id, test] of this.testById) {
|
|
262
|
-
if (!test.retired && (!testIds || testIds.hasKeyOrParent(TestId.fromString(id).path))) {
|
|
263
|
-
test.retired = true;
|
|
264
|
-
this.changeEmitter.fire({ reason: 0 , item: test, result: this });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
toJSON() {
|
|
269
|
-
return this.completedAt && this.persist ? this.doSerialize.value : undefined;
|
|
270
|
-
}
|
|
271
|
-
toJSONWithMessages() {
|
|
272
|
-
return this.completedAt && this.persist ? this.doSerializeWithMessages.value : undefined;
|
|
273
|
-
}
|
|
274
|
-
setAllToState(state, taskId, when) {
|
|
275
|
-
const index = this.mustGetTaskIndex(taskId);
|
|
276
|
-
for (const test of ( this.testById.values())) {
|
|
277
|
-
if (when(test.tasks[index], test)) {
|
|
278
|
-
this.fireUpdateAndRefresh(test, index, state);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
fireUpdateAndRefresh(entry, taskIndex, newState, newOwnDuration) {
|
|
283
|
-
const previousOwnComputed = entry.ownComputedState;
|
|
284
|
-
const previousOwnDuration = entry.ownDuration;
|
|
285
|
-
const changeEvent = {
|
|
286
|
-
item: entry,
|
|
287
|
-
result: this,
|
|
288
|
-
reason: 1 ,
|
|
289
|
-
previousState: previousOwnComputed,
|
|
290
|
-
previousOwnDuration: previousOwnDuration,
|
|
291
|
-
};
|
|
292
|
-
entry.tasks[taskIndex].state = newState;
|
|
293
|
-
if (newOwnDuration !== undefined) {
|
|
294
|
-
entry.tasks[taskIndex].duration = newOwnDuration;
|
|
295
|
-
entry.ownDuration = Math.max(entry.ownDuration || 0, newOwnDuration);
|
|
296
|
-
}
|
|
297
|
-
const newOwnComputed = maxPriority(...( entry.tasks.map(t => t.state)));
|
|
298
|
-
if (newOwnComputed === previousOwnComputed) {
|
|
299
|
-
if (newOwnDuration !== previousOwnDuration) {
|
|
300
|
-
this.changeEmitter.fire(changeEvent);
|
|
301
|
-
}
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
entry.ownComputedState = newOwnComputed;
|
|
305
|
-
this.counts[previousOwnComputed]--;
|
|
306
|
-
this.counts[newOwnComputed]++;
|
|
307
|
-
refreshComputedState(this.computedStateAccessor, entry).forEach(t => this.changeEmitter.fire(t === entry ? changeEvent : {
|
|
308
|
-
item: t,
|
|
309
|
-
result: this,
|
|
310
|
-
reason: 0 ,
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
addTestToRun(controllerId, item, parent) {
|
|
314
|
-
const node = itemToNode(controllerId, item);
|
|
315
|
-
this.testById.set(item.extId, node);
|
|
316
|
-
this.counts[0 ]++;
|
|
317
|
-
if (parent) {
|
|
318
|
-
this.testById.get(parent)?.children.push(node);
|
|
319
|
-
}
|
|
320
|
-
if (this.tasks.length) {
|
|
321
|
-
for (let i = 0; i < this.tasks.length; i++) {
|
|
322
|
-
node.tasks.push({ duration: undefined, messages: [], state: 0 });
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return node;
|
|
326
|
-
}
|
|
327
|
-
mustGetTaskIndex(taskId) {
|
|
328
|
-
const index = this.tasks.findIndex(t => t.id === taskId);
|
|
329
|
-
if (index === -1) {
|
|
330
|
-
throw new Error(`Unknown task ${taskId} in updateState`);
|
|
331
|
-
}
|
|
332
|
-
return index;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export { LiveTestResult, TaskRawOutput };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const statePriority = {
|
|
2
|
-
[2 ]: 6,
|
|
3
|
-
[6 ]: 5,
|
|
4
|
-
[4 ]: 4,
|
|
5
|
-
[1 ]: 3,
|
|
6
|
-
[3 ]: 2,
|
|
7
|
-
[0 ]: 0,
|
|
8
|
-
[5 ]: 1,
|
|
9
|
-
};
|
|
10
|
-
Object.entries(statePriority).reduce((acc, [stateStr, priority]) => {
|
|
11
|
-
const state = Number(stateStr);
|
|
12
|
-
acc[state] = { statusNode: true, state, priority };
|
|
13
|
-
return acc;
|
|
14
|
-
}, {});
|
|
15
|
-
const cmpPriority = (a, b) => statePriority[b] - statePriority[a];
|
|
16
|
-
const maxPriority = (...states) => {
|
|
17
|
-
switch (states.length) {
|
|
18
|
-
case 0:
|
|
19
|
-
return 0 ;
|
|
20
|
-
case 1:
|
|
21
|
-
return states[0];
|
|
22
|
-
case 2:
|
|
23
|
-
return statePriority[states[0]] > statePriority[states[1]] ? states[0] : states[1];
|
|
24
|
-
default: {
|
|
25
|
-
let max = states[0];
|
|
26
|
-
for (let i = 1; i < states.length; i++) {
|
|
27
|
-
if (statePriority[max] < statePriority[states[i]]) {
|
|
28
|
-
max = states[i];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return max;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const statesInOrder = ( ( Object.keys(statePriority)).map(s => Number(s))).sort(cmpPriority);
|
|
36
|
-
const terminalStatePriorities = {
|
|
37
|
-
[3 ]: 0,
|
|
38
|
-
[5 ]: 1,
|
|
39
|
-
[4 ]: 2,
|
|
40
|
-
[6 ]: 3,
|
|
41
|
-
};
|
|
42
|
-
const makeEmptyCounts = () => {
|
|
43
|
-
return ( new Uint32Array(statesInOrder.length));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export { cmpPriority, makeEmptyCounts, maxPriority, statePriority, statesInOrder, terminalStatePriorities };
|