@teamscale/coverage-collector 0.0.1-beta.30 → 0.0.1-beta.34
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/coverage-collector",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.34",
|
|
4
4
|
"description": "Collector for JavaScript code coverage information",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cqse/commons": "^0.0.1-beta.26",
|
|
26
26
|
"argparse": "^2.0.1",
|
|
27
|
-
"async": "^3.2.
|
|
27
|
+
"async": "^3.2.3",
|
|
28
28
|
"axios": "^0.24.0",
|
|
29
|
+
"bunyan": "^1.8.15",
|
|
29
30
|
"dotenv": "^14.1.0",
|
|
30
31
|
"form-data": "^4.0.0",
|
|
32
|
+
"mkdirp": "^1.0.4",
|
|
31
33
|
"rxjs": "^7.1.0",
|
|
32
34
|
"source-map": "^0.7.3",
|
|
33
35
|
"tmp": "^0.2.1",
|
|
@@ -41,6 +43,7 @@
|
|
|
41
43
|
"@types/async": "^3.2.6",
|
|
42
44
|
"@types/bunyan": "^1.8.8",
|
|
43
45
|
"@types/jest": "^27.0.1",
|
|
46
|
+
"@types/mkdirp": "^1.0.2",
|
|
44
47
|
"@types/node": "^15.0.1",
|
|
45
48
|
"@types/source-map": "^0.5.7",
|
|
46
49
|
"@types/tmp": "^0.2.3",
|
|
@@ -133,14 +133,19 @@ class WebSocketCollectingServer {
|
|
|
133
133
|
*/
|
|
134
134
|
handleCoverageMessage(session, body) {
|
|
135
135
|
var _a;
|
|
136
|
-
const bodyPattern = /(?<fileId>\S+) (?<positions>((\d+:\d+)
|
|
136
|
+
const bodyPattern = /(?<fileId>\S+) (?<positions>((\d+:\d+(:\d+:\d+)?\s+)*(\d+:\d+(:\d+:\d+)?)))/;
|
|
137
137
|
const matches = bodyPattern.exec(body);
|
|
138
138
|
if (matches === null || matches === void 0 ? void 0 : matches.groups) {
|
|
139
139
|
const fileId = matches.groups.fileId;
|
|
140
140
|
const positions = ((_a = matches.groups.positions) !== null && _a !== void 0 ? _a : '').split(/\s+/);
|
|
141
141
|
for (const position of positions) {
|
|
142
|
-
const
|
|
143
|
-
|
|
142
|
+
const positionParts = position.split(':');
|
|
143
|
+
if (positionParts.length === 2) {
|
|
144
|
+
session.putCoverage(fileId, Number.parseInt(positionParts[0]), Number.parseInt(positionParts[1]), Number.parseInt(positionParts[1]), Number.parseInt(positionParts[2]));
|
|
145
|
+
}
|
|
146
|
+
else if (positionParts.length === 4) {
|
|
147
|
+
session.putCoverage(fileId, Number.parseInt(positionParts[0]), Number.parseInt(positionParts[1]), Number.parseInt(positionParts[2]), Number.parseInt(positionParts[3]));
|
|
148
|
+
}
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
}
|
|
@@ -46,7 +46,7 @@ export declare class Session {
|
|
|
46
46
|
* @param line - The line number within the bundle.
|
|
47
47
|
* @param column - The column within the bundle.
|
|
48
48
|
*/
|
|
49
|
-
putCoverage(fileId: string,
|
|
49
|
+
putCoverage(fileId: string, startLine: number, startColumn: number, endLine: number, endColumn: number): void;
|
|
50
50
|
/**
|
|
51
51
|
* Map to the original file position.
|
|
52
52
|
*
|
|
@@ -54,13 +54,50 @@ class Session {
|
|
|
54
54
|
* @param line - The line number within the bundle.
|
|
55
55
|
* @param column - The column within the bundle.
|
|
56
56
|
*/
|
|
57
|
-
putCoverage(fileId,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
putCoverage(fileId, startLine, startColumn, endLine, endColumn) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
// Iterate over the lines to scan
|
|
60
|
+
let line = startLine;
|
|
61
|
+
while (line <= endLine) {
|
|
62
|
+
// Determine the column range to consider for this line
|
|
63
|
+
let scanFromColumn;
|
|
64
|
+
if (line === startLine) {
|
|
65
|
+
scanFromColumn = startColumn;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
scanFromColumn = 0;
|
|
69
|
+
}
|
|
70
|
+
let scanToColumn;
|
|
71
|
+
if (line === endLine) {
|
|
72
|
+
scanToColumn = endColumn;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Since we do not know the length of the different lines, we assume
|
|
76
|
+
// all to end in the lager of `endColumn` and `startColumn`.
|
|
77
|
+
// A better estimate (or the correct value) is supposed to be implemented
|
|
78
|
+
// in context of TS-30077.
|
|
79
|
+
scanToColumn = Math.max(endColumn, startColumn);
|
|
80
|
+
}
|
|
81
|
+
let column = scanFromColumn;
|
|
82
|
+
let lastCoveredLine = -1;
|
|
83
|
+
while (column <= scanToColumn) {
|
|
84
|
+
const originalPosition = this.mapToOriginal(fileId, line, column);
|
|
85
|
+
if (originalPosition.line && originalPosition.source) {
|
|
86
|
+
if (lastCoveredLine !== originalPosition.line) {
|
|
87
|
+
this.storage.putCoverage(this.projectId, originalPosition.source, [originalPosition.line]);
|
|
88
|
+
lastCoveredLine = originalPosition.line;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.storage.signalUnmappedCoverage(this.projectId);
|
|
93
|
+
}
|
|
94
|
+
// Step to the next column to map back to the original.
|
|
95
|
+
// `originalPosition.name` is the token on the position, that is, if it is present
|
|
96
|
+
// we increment the column by its length.
|
|
97
|
+
column = column + Math.max(1, ((_b = (_a = originalPosition.name) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 1));
|
|
98
|
+
}
|
|
99
|
+
// And the next line
|
|
100
|
+
line++;
|
|
64
101
|
}
|
|
65
102
|
}
|
|
66
103
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/coverage-collector",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.34",
|
|
4
4
|
"description": "Collector for JavaScript code coverage information",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cqse/commons": "^0.0.1-beta.26",
|
|
26
26
|
"argparse": "^2.0.1",
|
|
27
|
-
"async": "^3.2.
|
|
27
|
+
"async": "^3.2.3",
|
|
28
28
|
"axios": "^0.24.0",
|
|
29
|
+
"bunyan": "^1.8.15",
|
|
29
30
|
"dotenv": "^14.1.0",
|
|
30
31
|
"form-data": "^4.0.0",
|
|
32
|
+
"mkdirp": "^1.0.4",
|
|
31
33
|
"rxjs": "^7.1.0",
|
|
32
34
|
"source-map": "^0.7.3",
|
|
33
35
|
"tmp": "^0.2.1",
|
|
@@ -41,6 +43,7 @@
|
|
|
41
43
|
"@types/async": "^3.2.6",
|
|
42
44
|
"@types/bunyan": "^1.8.8",
|
|
43
45
|
"@types/jest": "^27.0.1",
|
|
46
|
+
"@types/mkdirp": "^1.0.2",
|
|
44
47
|
"@types/node": "^15.0.1",
|
|
45
48
|
"@types/source-map": "^0.5.7",
|
|
46
49
|
"@types/tmp": "^0.2.3",
|