@teamscale/javascript-instrumenter 0.0.1-beta.50 → 0.0.1-beta.51
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/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.51",
|
|
4
4
|
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Postprocessor.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Postprocessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAQN,cAAc,
|
|
1
|
+
{"version":3,"file":"Postprocessor.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Postprocessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAQN,cAAc,EASd,MAAM,cAAc,CAAC;AAqKtB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,GAClD,MAAM,CAaR"}
|
|
@@ -10,6 +10,34 @@ const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
|
10
10
|
const types_1 = require("@babel/types");
|
|
11
11
|
const commons_1 = require("@cqse/commons");
|
|
12
12
|
const COVERAGE_OBJ_FUNCTION_NAME_PREFIX = 'cov_';
|
|
13
|
+
/**
|
|
14
|
+
* Generator for identifiers that are unique across files to instrument.
|
|
15
|
+
* Relevant in case no Ecmascript modules are used.
|
|
16
|
+
*
|
|
17
|
+
* We assume that the files to be executed in a browser can
|
|
18
|
+
* stem from different runs of the instrumenter. We have to decrease
|
|
19
|
+
* the probability of colliding identifiers.
|
|
20
|
+
*/
|
|
21
|
+
const fileIdSeqGenerator = (() => {
|
|
22
|
+
const instrumenterRunId = process.pid;
|
|
23
|
+
let fileIdSeq = 0;
|
|
24
|
+
return {
|
|
25
|
+
next: () => {
|
|
26
|
+
fileIdSeq++;
|
|
27
|
+
let num;
|
|
28
|
+
if (fileIdSeq < 10000) {
|
|
29
|
+
num = instrumenterRunId * 10000 + fileIdSeq;
|
|
30
|
+
}
|
|
31
|
+
else if (fileIdSeq < 100000) {
|
|
32
|
+
num = instrumenterRunId * 100000 + fileIdSeq;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error(`Not more that 100k files supported to be instrumented in one run.`);
|
|
36
|
+
}
|
|
37
|
+
return num.toString(36);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
13
41
|
function getIstanbulCoverageFunctionDeclarationName(node) {
|
|
14
42
|
var _a;
|
|
15
43
|
if (!(0, types_1.isFunctionDeclaration)(node)) {
|
|
@@ -25,7 +53,6 @@ function getIstanbulCoverageFunctionDeclarationName(node) {
|
|
|
25
53
|
}
|
|
26
54
|
function createFileIdMappingHandler() {
|
|
27
55
|
const fileIdMap = new Map();
|
|
28
|
-
let fileIdSeq = 0;
|
|
29
56
|
return {
|
|
30
57
|
enterPath(path) {
|
|
31
58
|
var _a;
|
|
@@ -40,7 +67,7 @@ function createFileIdMappingHandler() {
|
|
|
40
67
|
const declarator = declaration.declarations[0];
|
|
41
68
|
if ((0, types_1.isIdentifier)(declarator.id) && declarator.id.name === 'hash') {
|
|
42
69
|
// We take note of the hash that is stored within the `cov_*' function.
|
|
43
|
-
const fileIdVarName = `_$
|
|
70
|
+
const fileIdVarName = `_$f${fileIdSeqGenerator.next()}`;
|
|
44
71
|
const fileId = declarator.init.value;
|
|
45
72
|
fileIdMap.set(coverageFunctionName, fileIdVarName);
|
|
46
73
|
grandParentPath.insertBefore(newStringConstDeclarationNode(fileIdVarName, fileId));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.51",
|
|
4
4
|
"description": "JavaScript coverage instrumenter with coverage forwarding to a collector process",
|
|
5
5
|
"main": "dist/src/main.js",
|
|
6
6
|
"bin": "dist/src/main.js",
|