@hypertestco/node-sdk-v3 0.0.1-29 → 0.0.1-31
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/index.cjs +131 -39
- package/index.mjs +131 -39
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -147439,7 +147439,7 @@ var opentelemetry = __toESM(require_src30());
|
|
|
147439
147439
|
var import_register = __toESM(require_register());
|
|
147440
147440
|
|
|
147441
147441
|
// ../../package.json
|
|
147442
|
-
var version = "0.0.1-
|
|
147442
|
+
var version = "0.0.1-31";
|
|
147443
147443
|
|
|
147444
147444
|
// ../utils/syncSleep/index.ts
|
|
147445
147445
|
function synchronousBlock(seconds) {
|
|
@@ -153294,7 +153294,7 @@ var MemoryStore = class _MemoryStore {
|
|
|
153294
153294
|
}
|
|
153295
153295
|
updateRequestCoverage(htRequestId, filePathAbs, lineNumber) {
|
|
153296
153296
|
let executionCounter = this.getHtRequestIdExecutionCounter(htRequestId);
|
|
153297
|
-
if (executionCounter) {
|
|
153297
|
+
if (executionCounter && Number.isFinite(executionCounter)) {
|
|
153298
153298
|
executionCounter += 1;
|
|
153299
153299
|
this.htRequestIdExecutionCounterMap.set(htRequestId, executionCounter);
|
|
153300
153300
|
} else {
|
|
@@ -155323,6 +155323,69 @@ function isPlatformIncorrect(coverage, platform) {
|
|
|
155323
155323
|
}
|
|
155324
155324
|
return true;
|
|
155325
155325
|
}
|
|
155326
|
+
function getLinesCoveredWithExecutionOrder(coverage, platform, codeCoverageData) {
|
|
155327
|
+
if (Object.keys(coverage).length === 0) {
|
|
155328
|
+
return {};
|
|
155329
|
+
}
|
|
155330
|
+
if (isPlatformIncorrect(coverage, platform)) {
|
|
155331
|
+
console.log(`Your application platform: ${platform} and the coverage is not compatible.
|
|
155332
|
+
Code coverage features will not work.
|
|
155333
|
+
|
|
155334
|
+
How to rectify ?
|
|
155335
|
+
Please verify that your application platform type is correct.
|
|
155336
|
+
You need to go to hypertest dashboard to verify.
|
|
155337
|
+
Please contact hypertest team if the issue still persists.`);
|
|
155338
|
+
return {};
|
|
155339
|
+
}
|
|
155340
|
+
if (platform === import_generatedClient4.Platform.Java) {
|
|
155341
|
+
const unstretchedLinesCovered2 = coverage;
|
|
155342
|
+
return normalizePaths(unstretchedLinesCovered2);
|
|
155343
|
+
}
|
|
155344
|
+
const projectRoot2 = getProjectRoot();
|
|
155345
|
+
const unstretchedLinesCovered = {};
|
|
155346
|
+
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
155347
|
+
const linesCoveredPerFile = {};
|
|
155348
|
+
const filePathRel = import_node_path.default.relative(projectRoot2, filePathAbs);
|
|
155349
|
+
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
155350
|
+
filePathRel,
|
|
155351
|
+
fileCoverage.statementMap
|
|
155352
|
+
);
|
|
155353
|
+
for (const [statementNumber, count] of Object.entries(fileCoverage.s)) {
|
|
155354
|
+
if (count) {
|
|
155355
|
+
const {
|
|
155356
|
+
start: { line: startLine },
|
|
155357
|
+
end: { line: endLine },
|
|
155358
|
+
topLevelChildStatements
|
|
155359
|
+
} = statementMapWithChildStatements[statementNumber];
|
|
155360
|
+
let currentExecutionOrderArr = [];
|
|
155361
|
+
for (const orderArr of Object.values(codeCoverageData)) {
|
|
155362
|
+
if (orderArr.includes(count)) {
|
|
155363
|
+
currentExecutionOrderArr = orderArr;
|
|
155364
|
+
break;
|
|
155365
|
+
}
|
|
155366
|
+
}
|
|
155367
|
+
let currentLine = startLine;
|
|
155368
|
+
let childStatementIdx = 0;
|
|
155369
|
+
while (currentLine <= endLine) {
|
|
155370
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
155371
|
+
linesCoveredPerFile[currentLine.toString()] = currentExecutionOrderArr;
|
|
155372
|
+
currentLine++;
|
|
155373
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
155374
|
+
linesCoveredPerFile[currentLine.toString()] = currentExecutionOrderArr;
|
|
155375
|
+
currentLine++;
|
|
155376
|
+
} else {
|
|
155377
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
155378
|
+
childStatementIdx++;
|
|
155379
|
+
}
|
|
155380
|
+
}
|
|
155381
|
+
linesCoveredPerFile[startLine.toString()] = currentExecutionOrderArr;
|
|
155382
|
+
linesCoveredPerFile[endLine.toString()] = currentExecutionOrderArr;
|
|
155383
|
+
}
|
|
155384
|
+
}
|
|
155385
|
+
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
155386
|
+
}
|
|
155387
|
+
return normalizePaths(unstretchedLinesCovered);
|
|
155388
|
+
}
|
|
155326
155389
|
function getLinesCovered(coverage, platform) {
|
|
155327
155390
|
if (Object.keys(coverage).length === 0) {
|
|
155328
155391
|
return {
|
|
@@ -155360,7 +155423,7 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
155360
155423
|
const stretchedLinesCovered = {};
|
|
155361
155424
|
const unstretchedLinesCovered = {};
|
|
155362
155425
|
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
155363
|
-
const linesCoveredPerFile =
|
|
155426
|
+
const linesCoveredPerFile = /* @__PURE__ */ new Set();
|
|
155364
155427
|
const filePathRel = import_node_path.default.relative(projectRoot2, filePathAbs);
|
|
155365
155428
|
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
155366
155429
|
filePathRel,
|
|
@@ -155371,35 +155434,29 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
155371
155434
|
const {
|
|
155372
155435
|
start: { line: startLine },
|
|
155373
155436
|
end: { line: endLine },
|
|
155374
|
-
topLevelChildStatements
|
|
155437
|
+
topLevelChildStatements
|
|
155375
155438
|
} = statementMapWithChildStatements[statementNumber];
|
|
155376
|
-
|
|
155377
|
-
|
|
155378
|
-
|
|
155379
|
-
|
|
155380
|
-
|
|
155381
|
-
|
|
155382
|
-
|
|
155383
|
-
|
|
155384
|
-
while (currentLine < endLine) {
|
|
155385
|
-
let lineIsCoveredByChild = false;
|
|
155386
|
-
for (const child of sortedChildren) {
|
|
155387
|
-
if (currentLine >= child.start.line && currentLine <= child.end.line) {
|
|
155388
|
-
lineIsCoveredByChild = true;
|
|
155389
|
-
break;
|
|
155390
|
-
}
|
|
155391
|
-
}
|
|
155392
|
-
if (!lineIsCoveredByChild) {
|
|
155393
|
-
linesCoveredPerFile[currentLine] = executionOrders;
|
|
155394
|
-
}
|
|
155439
|
+
let currentLine = startLine;
|
|
155440
|
+
let childStatementIdx = 0;
|
|
155441
|
+
while (currentLine <= endLine) {
|
|
155442
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
155443
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
155444
|
+
currentLine++;
|
|
155445
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
155446
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
155395
155447
|
currentLine++;
|
|
155448
|
+
} else {
|
|
155449
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
155450
|
+
childStatementIdx++;
|
|
155396
155451
|
}
|
|
155397
155452
|
}
|
|
155453
|
+
linesCoveredPerFile.add(startLine.toString());
|
|
155454
|
+
linesCoveredPerFile.add(endLine.toString());
|
|
155398
155455
|
}
|
|
155399
155456
|
}
|
|
155400
|
-
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
155457
|
+
unstretchedLinesCovered[filePathRel] = [...linesCoveredPerFile];
|
|
155401
155458
|
stretchedLinesCovered[filePathRel] = stretchCoverage(
|
|
155402
|
-
|
|
155459
|
+
unstretchedLinesCovered[filePathRel]
|
|
155403
155460
|
);
|
|
155404
155461
|
}
|
|
155405
155462
|
return {
|
|
@@ -155420,6 +155477,13 @@ function computeCoverageHash(coverage, commitId, platform) {
|
|
|
155420
155477
|
};
|
|
155421
155478
|
return sha1_default(stableStringify(hashPayload));
|
|
155422
155479
|
}
|
|
155480
|
+
function computeCoverageHashFromExtractedLineCoverageWithEachFile(linesCovered, commitId) {
|
|
155481
|
+
const hashPayload = {
|
|
155482
|
+
coverage: compressRequestCoverage(linesCovered),
|
|
155483
|
+
commitId
|
|
155484
|
+
};
|
|
155485
|
+
return sha1_default(stableStringify(hashPayload));
|
|
155486
|
+
}
|
|
155423
155487
|
|
|
155424
155488
|
// src/instrumentation/helpers/samplingLogic.ts
|
|
155425
155489
|
var import_generatedClient5 = __toESM(require_generatedClient2());
|
|
@@ -155443,7 +155507,7 @@ function remapCoverage(requestCoverage = {}) {
|
|
|
155443
155507
|
(coverage, filePathAbs) => {
|
|
155444
155508
|
const s = {};
|
|
155445
155509
|
for (const lineNumber of Object.keys(requestCoverage[filePathAbs])) {
|
|
155446
|
-
s[lineNumber] = requestCoverage[filePathAbs][lineNumber]
|
|
155510
|
+
s[lineNumber] = requestCoverage[filePathAbs][lineNumber][0];
|
|
155447
155511
|
}
|
|
155448
155512
|
coverage[filePathAbs] = {
|
|
155449
155513
|
path: filePathAbs,
|
|
@@ -155590,6 +155654,10 @@ var setGitCommitHash = (commitHash) => {
|
|
|
155590
155654
|
}
|
|
155591
155655
|
};
|
|
155592
155656
|
var setCommitHashFromGit = () => {
|
|
155657
|
+
if (process.env.HT_COMMIT_ID && !process.env.HT_COMMIT_ID.toLocaleLowerCase().includes("unknown")) {
|
|
155658
|
+
_gitCommitHash = process.env.HT_COMMIT_ID;
|
|
155659
|
+
return _gitCommitHash;
|
|
155660
|
+
}
|
|
155593
155661
|
const spawnSyncOutput = (0, import_child_process3.spawnSync)("git", ["rev-parse", "HEAD"], {
|
|
155594
155662
|
cwd: process.cwd(),
|
|
155595
155663
|
/**
|
|
@@ -155610,7 +155678,13 @@ var setCommitHashFromGit = () => {
|
|
|
155610
155678
|
console.error(
|
|
155611
155679
|
`Error occurred while trying to get git commit hash. Exit code: ${exitCode}, stderr: ${spawnSyncOutput.stderr.toString()}. Please set commit hash manually using 'HT_COMMIT_ID' env variable or 'setGitCommitHash' method.`
|
|
155612
155680
|
);
|
|
155613
|
-
|
|
155681
|
+
process.env.HT_MODE = "DISABLED";
|
|
155682
|
+
console.log(
|
|
155683
|
+
"HT_MODE set to DISABLED due to inability to fetch current git commit hash"
|
|
155684
|
+
);
|
|
155685
|
+
updateHtMode();
|
|
155686
|
+
synchronousBlock(30);
|
|
155687
|
+
return;
|
|
155614
155688
|
}
|
|
155615
155689
|
_gitCommitHash = spawnSyncOutput.stdout.toString().trim();
|
|
155616
155690
|
return _gitCommitHash;
|
|
@@ -161208,19 +161282,36 @@ var HtServerMockAbstract = class {
|
|
|
161208
161282
|
}
|
|
161209
161283
|
const coverage = storeInstance4.getRequestCoverage(htRequestId);
|
|
161210
161284
|
if (coverage && Object.keys(coverage).length > 0) {
|
|
161211
|
-
|
|
161212
|
-
const
|
|
161213
|
-
|
|
161214
|
-
|
|
161215
|
-
|
|
161285
|
+
let totalRemappedCoverage = {};
|
|
161286
|
+
for (const filePath of Object.keys(coverage)) {
|
|
161287
|
+
const singleFileCoverage = {};
|
|
161288
|
+
singleFileCoverage[filePath] = coverage[filePath];
|
|
161289
|
+
const remappedSingleFileCoverage = remapCoverage(singleFileCoverage);
|
|
161290
|
+
const remappedCoverageData = extractCoverageData(
|
|
161291
|
+
remappedSingleFileCoverage
|
|
161292
|
+
);
|
|
161293
|
+
const linesCovered = getLinesCoveredWithExecutionOrder(
|
|
161294
|
+
remappedCoverageData,
|
|
161295
|
+
import_generatedClient6.Platform.NodeJS,
|
|
161296
|
+
coverage[filePath]
|
|
161297
|
+
);
|
|
161298
|
+
Object.assign(totalRemappedCoverage, linesCovered);
|
|
161299
|
+
}
|
|
161300
|
+
const coverageWithoutExecutionOrder = {};
|
|
161301
|
+
for (const filePath of Object.keys(totalRemappedCoverage)) {
|
|
161302
|
+
coverageWithoutExecutionOrder[filePath] = Object.keys(
|
|
161303
|
+
totalRemappedCoverage[filePath]
|
|
161304
|
+
);
|
|
161305
|
+
}
|
|
161306
|
+
const coverageHash = computeCoverageHashFromExtractedLineCoverageWithEachFile(
|
|
161307
|
+
coverageWithoutExecutionOrder,
|
|
161308
|
+
getGitCommitHash()
|
|
161216
161309
|
);
|
|
161217
161310
|
this.span.setAttribute("coverageHash", coverageHash);
|
|
161218
|
-
|
|
161219
|
-
|
|
161220
|
-
|
|
161221
|
-
import_generatedClient6.Platform.NodeJS
|
|
161311
|
+
this.span.setAttribute(
|
|
161312
|
+
"coverage",
|
|
161313
|
+
JSON.stringify(totalRemappedCoverage)
|
|
161222
161314
|
);
|
|
161223
|
-
this.span.setAttribute("coverage", JSON.stringify(linesCovered));
|
|
161224
161315
|
storeInstance4.deleteRequestCoverage(htRequestId);
|
|
161225
161316
|
}
|
|
161226
161317
|
this.span.setAttribute("output_status", this.outputStatus);
|
|
@@ -161234,7 +161325,7 @@ var HtServerMockAbstract = class {
|
|
|
161234
161325
|
if (this.parentHtRequestId) {
|
|
161235
161326
|
this.span.setAttribute("parentHtRequestId", this.parentHtRequestId);
|
|
161236
161327
|
}
|
|
161237
|
-
const gitCommitHash =
|
|
161328
|
+
const gitCommitHash = getGitCommitHash();
|
|
161238
161329
|
this.span.setAttribute("commit_hash", gitCommitHash);
|
|
161239
161330
|
const branch = process.env.HT_BRANCH_NAME || getBranchName();
|
|
161240
161331
|
this.span.setAttribute("branch", branch);
|
|
@@ -224314,7 +224405,8 @@ var initialiseNormally = (htConfig) => {
|
|
|
224314
224405
|
process.env.DD_TRACE_DISABLED_PLUGINS = current === "" ? "http2" : `${current},http2`;
|
|
224315
224406
|
}
|
|
224316
224407
|
const isCurrentFolderInGitRepo = isCurrentFolderInGitRepoFn();
|
|
224317
|
-
|
|
224408
|
+
const isDebugRun = process.env.HT_SDK_DEBUG === "true";
|
|
224409
|
+
if (!isDebugRun && isCurrentFolderInGitRepo && isHavingUncommittedChangesFn()) {
|
|
224318
224410
|
const gitDiff = getUncommittedChanges();
|
|
224319
224411
|
console.log(
|
|
224320
224412
|
"The following are the uncommitted changes in your repository."
|
package/index.mjs
CHANGED
|
@@ -154920,7 +154920,7 @@ import fs2 from "fs";
|
|
|
154920
154920
|
import path3 from "path";
|
|
154921
154921
|
|
|
154922
154922
|
// ../../package.json
|
|
154923
|
-
var version = "0.0.1-
|
|
154923
|
+
var version = "0.0.1-31";
|
|
154924
154924
|
|
|
154925
154925
|
// ../utils/syncSleep/index.ts
|
|
154926
154926
|
function synchronousBlock(seconds) {
|
|
@@ -160775,7 +160775,7 @@ var MemoryStore = class _MemoryStore {
|
|
|
160775
160775
|
}
|
|
160776
160776
|
updateRequestCoverage(htRequestId, filePathAbs, lineNumber) {
|
|
160777
160777
|
let executionCounter = this.getHtRequestIdExecutionCounter(htRequestId);
|
|
160778
|
-
if (executionCounter) {
|
|
160778
|
+
if (executionCounter && Number.isFinite(executionCounter)) {
|
|
160779
160779
|
executionCounter += 1;
|
|
160780
160780
|
this.htRequestIdExecutionCounterMap.set(htRequestId, executionCounter);
|
|
160781
160781
|
} else {
|
|
@@ -163223,6 +163223,69 @@ function isPlatformIncorrect(coverage, platform) {
|
|
|
163223
163223
|
}
|
|
163224
163224
|
return true;
|
|
163225
163225
|
}
|
|
163226
|
+
function getLinesCoveredWithExecutionOrder(coverage, platform, codeCoverageData) {
|
|
163227
|
+
if (Object.keys(coverage).length === 0) {
|
|
163228
|
+
return {};
|
|
163229
|
+
}
|
|
163230
|
+
if (isPlatformIncorrect(coverage, platform)) {
|
|
163231
|
+
console.log(`Your application platform: ${platform} and the coverage is not compatible.
|
|
163232
|
+
Code coverage features will not work.
|
|
163233
|
+
|
|
163234
|
+
How to rectify ?
|
|
163235
|
+
Please verify that your application platform type is correct.
|
|
163236
|
+
You need to go to hypertest dashboard to verify.
|
|
163237
|
+
Please contact hypertest team if the issue still persists.`);
|
|
163238
|
+
return {};
|
|
163239
|
+
}
|
|
163240
|
+
if (platform === import_generatedClient4.Platform.Java) {
|
|
163241
|
+
const unstretchedLinesCovered2 = coverage;
|
|
163242
|
+
return normalizePaths(unstretchedLinesCovered2);
|
|
163243
|
+
}
|
|
163244
|
+
const projectRoot2 = getProjectRoot();
|
|
163245
|
+
const unstretchedLinesCovered = {};
|
|
163246
|
+
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
163247
|
+
const linesCoveredPerFile = {};
|
|
163248
|
+
const filePathRel = path.relative(projectRoot2, filePathAbs);
|
|
163249
|
+
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
163250
|
+
filePathRel,
|
|
163251
|
+
fileCoverage.statementMap
|
|
163252
|
+
);
|
|
163253
|
+
for (const [statementNumber, count] of Object.entries(fileCoverage.s)) {
|
|
163254
|
+
if (count) {
|
|
163255
|
+
const {
|
|
163256
|
+
start: { line: startLine },
|
|
163257
|
+
end: { line: endLine },
|
|
163258
|
+
topLevelChildStatements
|
|
163259
|
+
} = statementMapWithChildStatements[statementNumber];
|
|
163260
|
+
let currentExecutionOrderArr = [];
|
|
163261
|
+
for (const orderArr of Object.values(codeCoverageData)) {
|
|
163262
|
+
if (orderArr.includes(count)) {
|
|
163263
|
+
currentExecutionOrderArr = orderArr;
|
|
163264
|
+
break;
|
|
163265
|
+
}
|
|
163266
|
+
}
|
|
163267
|
+
let currentLine = startLine;
|
|
163268
|
+
let childStatementIdx = 0;
|
|
163269
|
+
while (currentLine <= endLine) {
|
|
163270
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
163271
|
+
linesCoveredPerFile[currentLine.toString()] = currentExecutionOrderArr;
|
|
163272
|
+
currentLine++;
|
|
163273
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
163274
|
+
linesCoveredPerFile[currentLine.toString()] = currentExecutionOrderArr;
|
|
163275
|
+
currentLine++;
|
|
163276
|
+
} else {
|
|
163277
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
163278
|
+
childStatementIdx++;
|
|
163279
|
+
}
|
|
163280
|
+
}
|
|
163281
|
+
linesCoveredPerFile[startLine.toString()] = currentExecutionOrderArr;
|
|
163282
|
+
linesCoveredPerFile[endLine.toString()] = currentExecutionOrderArr;
|
|
163283
|
+
}
|
|
163284
|
+
}
|
|
163285
|
+
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
163286
|
+
}
|
|
163287
|
+
return normalizePaths(unstretchedLinesCovered);
|
|
163288
|
+
}
|
|
163226
163289
|
function getLinesCovered(coverage, platform) {
|
|
163227
163290
|
if (Object.keys(coverage).length === 0) {
|
|
163228
163291
|
return {
|
|
@@ -163260,7 +163323,7 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
163260
163323
|
const stretchedLinesCovered = {};
|
|
163261
163324
|
const unstretchedLinesCovered = {};
|
|
163262
163325
|
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
163263
|
-
const linesCoveredPerFile =
|
|
163326
|
+
const linesCoveredPerFile = /* @__PURE__ */ new Set();
|
|
163264
163327
|
const filePathRel = path.relative(projectRoot2, filePathAbs);
|
|
163265
163328
|
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
163266
163329
|
filePathRel,
|
|
@@ -163271,35 +163334,29 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
163271
163334
|
const {
|
|
163272
163335
|
start: { line: startLine },
|
|
163273
163336
|
end: { line: endLine },
|
|
163274
|
-
topLevelChildStatements
|
|
163337
|
+
topLevelChildStatements
|
|
163275
163338
|
} = statementMapWithChildStatements[statementNumber];
|
|
163276
|
-
|
|
163277
|
-
|
|
163278
|
-
|
|
163279
|
-
|
|
163280
|
-
|
|
163281
|
-
|
|
163282
|
-
|
|
163283
|
-
|
|
163284
|
-
while (currentLine < endLine) {
|
|
163285
|
-
let lineIsCoveredByChild = false;
|
|
163286
|
-
for (const child of sortedChildren) {
|
|
163287
|
-
if (currentLine >= child.start.line && currentLine <= child.end.line) {
|
|
163288
|
-
lineIsCoveredByChild = true;
|
|
163289
|
-
break;
|
|
163290
|
-
}
|
|
163291
|
-
}
|
|
163292
|
-
if (!lineIsCoveredByChild) {
|
|
163293
|
-
linesCoveredPerFile[currentLine] = executionOrders;
|
|
163294
|
-
}
|
|
163339
|
+
let currentLine = startLine;
|
|
163340
|
+
let childStatementIdx = 0;
|
|
163341
|
+
while (currentLine <= endLine) {
|
|
163342
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
163343
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
163344
|
+
currentLine++;
|
|
163345
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
163346
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
163295
163347
|
currentLine++;
|
|
163348
|
+
} else {
|
|
163349
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
163350
|
+
childStatementIdx++;
|
|
163296
163351
|
}
|
|
163297
163352
|
}
|
|
163353
|
+
linesCoveredPerFile.add(startLine.toString());
|
|
163354
|
+
linesCoveredPerFile.add(endLine.toString());
|
|
163298
163355
|
}
|
|
163299
163356
|
}
|
|
163300
|
-
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
163357
|
+
unstretchedLinesCovered[filePathRel] = [...linesCoveredPerFile];
|
|
163301
163358
|
stretchedLinesCovered[filePathRel] = stretchCoverage(
|
|
163302
|
-
|
|
163359
|
+
unstretchedLinesCovered[filePathRel]
|
|
163303
163360
|
);
|
|
163304
163361
|
}
|
|
163305
163362
|
return {
|
|
@@ -163320,6 +163377,13 @@ function computeCoverageHash(coverage, commitId, platform) {
|
|
|
163320
163377
|
};
|
|
163321
163378
|
return sha1_default(stableStringify(hashPayload));
|
|
163322
163379
|
}
|
|
163380
|
+
function computeCoverageHashFromExtractedLineCoverageWithEachFile(linesCovered, commitId) {
|
|
163381
|
+
const hashPayload = {
|
|
163382
|
+
coverage: compressRequestCoverage(linesCovered),
|
|
163383
|
+
commitId
|
|
163384
|
+
};
|
|
163385
|
+
return sha1_default(stableStringify(hashPayload));
|
|
163386
|
+
}
|
|
163323
163387
|
|
|
163324
163388
|
// src/instrumentation/helpers/samplingLogic.ts
|
|
163325
163389
|
var import_generatedClient5 = __toESM(require_generatedClient2());
|
|
@@ -163343,7 +163407,7 @@ function remapCoverage(requestCoverage = {}) {
|
|
|
163343
163407
|
(coverage, filePathAbs) => {
|
|
163344
163408
|
const s = {};
|
|
163345
163409
|
for (const lineNumber of Object.keys(requestCoverage[filePathAbs])) {
|
|
163346
|
-
s[lineNumber] = requestCoverage[filePathAbs][lineNumber]
|
|
163410
|
+
s[lineNumber] = requestCoverage[filePathAbs][lineNumber][0];
|
|
163347
163411
|
}
|
|
163348
163412
|
coverage[filePathAbs] = {
|
|
163349
163413
|
path: filePathAbs,
|
|
@@ -163490,6 +163554,10 @@ var setGitCommitHash = (commitHash) => {
|
|
|
163490
163554
|
}
|
|
163491
163555
|
};
|
|
163492
163556
|
var setCommitHashFromGit = () => {
|
|
163557
|
+
if (process.env.HT_COMMIT_ID && !process.env.HT_COMMIT_ID.toLocaleLowerCase().includes("unknown")) {
|
|
163558
|
+
_gitCommitHash = process.env.HT_COMMIT_ID;
|
|
163559
|
+
return _gitCommitHash;
|
|
163560
|
+
}
|
|
163493
163561
|
const spawnSyncOutput = spawnSync3("git", ["rev-parse", "HEAD"], {
|
|
163494
163562
|
cwd: process.cwd(),
|
|
163495
163563
|
/**
|
|
@@ -163510,7 +163578,13 @@ var setCommitHashFromGit = () => {
|
|
|
163510
163578
|
console.error(
|
|
163511
163579
|
`Error occurred while trying to get git commit hash. Exit code: ${exitCode}, stderr: ${spawnSyncOutput.stderr.toString()}. Please set commit hash manually using 'HT_COMMIT_ID' env variable or 'setGitCommitHash' method.`
|
|
163512
163580
|
);
|
|
163513
|
-
|
|
163581
|
+
process.env.HT_MODE = "DISABLED";
|
|
163582
|
+
console.log(
|
|
163583
|
+
"HT_MODE set to DISABLED due to inability to fetch current git commit hash"
|
|
163584
|
+
);
|
|
163585
|
+
updateHtMode();
|
|
163586
|
+
synchronousBlock(30);
|
|
163587
|
+
return;
|
|
163514
163588
|
}
|
|
163515
163589
|
_gitCommitHash = spawnSyncOutput.stdout.toString().trim();
|
|
163516
163590
|
return _gitCommitHash;
|
|
@@ -164989,19 +165063,36 @@ var HtServerMockAbstract = class {
|
|
|
164989
165063
|
}
|
|
164990
165064
|
const coverage = storeInstance4.getRequestCoverage(htRequestId);
|
|
164991
165065
|
if (coverage && Object.keys(coverage).length > 0) {
|
|
164992
|
-
|
|
164993
|
-
const
|
|
164994
|
-
|
|
164995
|
-
|
|
164996
|
-
|
|
165066
|
+
let totalRemappedCoverage = {};
|
|
165067
|
+
for (const filePath of Object.keys(coverage)) {
|
|
165068
|
+
const singleFileCoverage = {};
|
|
165069
|
+
singleFileCoverage[filePath] = coverage[filePath];
|
|
165070
|
+
const remappedSingleFileCoverage = remapCoverage(singleFileCoverage);
|
|
165071
|
+
const remappedCoverageData = extractCoverageData(
|
|
165072
|
+
remappedSingleFileCoverage
|
|
165073
|
+
);
|
|
165074
|
+
const linesCovered = getLinesCoveredWithExecutionOrder(
|
|
165075
|
+
remappedCoverageData,
|
|
165076
|
+
import_generatedClient6.Platform.NodeJS,
|
|
165077
|
+
coverage[filePath]
|
|
165078
|
+
);
|
|
165079
|
+
Object.assign(totalRemappedCoverage, linesCovered);
|
|
165080
|
+
}
|
|
165081
|
+
const coverageWithoutExecutionOrder = {};
|
|
165082
|
+
for (const filePath of Object.keys(totalRemappedCoverage)) {
|
|
165083
|
+
coverageWithoutExecutionOrder[filePath] = Object.keys(
|
|
165084
|
+
totalRemappedCoverage[filePath]
|
|
165085
|
+
);
|
|
165086
|
+
}
|
|
165087
|
+
const coverageHash = computeCoverageHashFromExtractedLineCoverageWithEachFile(
|
|
165088
|
+
coverageWithoutExecutionOrder,
|
|
165089
|
+
getGitCommitHash()
|
|
164997
165090
|
);
|
|
164998
165091
|
this.span.setAttribute("coverageHash", coverageHash);
|
|
164999
|
-
|
|
165000
|
-
|
|
165001
|
-
|
|
165002
|
-
import_generatedClient6.Platform.NodeJS
|
|
165092
|
+
this.span.setAttribute(
|
|
165093
|
+
"coverage",
|
|
165094
|
+
JSON.stringify(totalRemappedCoverage)
|
|
165003
165095
|
);
|
|
165004
|
-
this.span.setAttribute("coverage", JSON.stringify(linesCovered));
|
|
165005
165096
|
storeInstance4.deleteRequestCoverage(htRequestId);
|
|
165006
165097
|
}
|
|
165007
165098
|
this.span.setAttribute("output_status", this.outputStatus);
|
|
@@ -165015,7 +165106,7 @@ var HtServerMockAbstract = class {
|
|
|
165015
165106
|
if (this.parentHtRequestId) {
|
|
165016
165107
|
this.span.setAttribute("parentHtRequestId", this.parentHtRequestId);
|
|
165017
165108
|
}
|
|
165018
|
-
const gitCommitHash =
|
|
165109
|
+
const gitCommitHash = getGitCommitHash();
|
|
165019
165110
|
this.span.setAttribute("commit_hash", gitCommitHash);
|
|
165020
165111
|
const branch = process.env.HT_BRANCH_NAME || getBranchName();
|
|
165021
165112
|
this.span.setAttribute("branch", branch);
|
|
@@ -231829,7 +231920,8 @@ var initialiseNormally = (htConfig) => {
|
|
|
231829
231920
|
process.env.DD_TRACE_DISABLED_PLUGINS = current === "" ? "http2" : `${current},http2`;
|
|
231830
231921
|
}
|
|
231831
231922
|
const isCurrentFolderInGitRepo = isCurrentFolderInGitRepoFn();
|
|
231832
|
-
|
|
231923
|
+
const isDebugRun = process.env.HT_SDK_DEBUG === "true";
|
|
231924
|
+
if (!isDebugRun && isCurrentFolderInGitRepo && isHavingUncommittedChangesFn()) {
|
|
231833
231925
|
const gitDiff = getUncommittedChanges();
|
|
231834
231926
|
console.log(
|
|
231835
231927
|
"The following are the uncommitted changes in your repository."
|