@hypertestco/node-sdk-v3 0.0.1-29 → 0.0.1-30
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 +124 -39
- package/index.mjs +124 -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-30";
|
|
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,62 @@ 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 currentLine = startLine;
|
|
155361
|
+
let childStatementIdx = 0;
|
|
155362
|
+
while (currentLine <= endLine) {
|
|
155363
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
155364
|
+
linesCoveredPerFile[currentLine.toString()] = codeCoverageData[statementNumber];
|
|
155365
|
+
currentLine++;
|
|
155366
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
155367
|
+
linesCoveredPerFile[currentLine.toString()] = codeCoverageData[statementNumber];
|
|
155368
|
+
currentLine++;
|
|
155369
|
+
} else {
|
|
155370
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
155371
|
+
childStatementIdx++;
|
|
155372
|
+
}
|
|
155373
|
+
}
|
|
155374
|
+
linesCoveredPerFile[startLine.toString()] = codeCoverageData[statementNumber];
|
|
155375
|
+
linesCoveredPerFile[endLine.toString()] = codeCoverageData[statementNumber];
|
|
155376
|
+
}
|
|
155377
|
+
}
|
|
155378
|
+
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
155379
|
+
}
|
|
155380
|
+
return normalizePaths(unstretchedLinesCovered);
|
|
155381
|
+
}
|
|
155326
155382
|
function getLinesCovered(coverage, platform) {
|
|
155327
155383
|
if (Object.keys(coverage).length === 0) {
|
|
155328
155384
|
return {
|
|
@@ -155360,7 +155416,7 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
155360
155416
|
const stretchedLinesCovered = {};
|
|
155361
155417
|
const unstretchedLinesCovered = {};
|
|
155362
155418
|
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
155363
|
-
const linesCoveredPerFile =
|
|
155419
|
+
const linesCoveredPerFile = /* @__PURE__ */ new Set();
|
|
155364
155420
|
const filePathRel = import_node_path.default.relative(projectRoot2, filePathAbs);
|
|
155365
155421
|
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
155366
155422
|
filePathRel,
|
|
@@ -155371,35 +155427,29 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
155371
155427
|
const {
|
|
155372
155428
|
start: { line: startLine },
|
|
155373
155429
|
end: { line: endLine },
|
|
155374
|
-
topLevelChildStatements
|
|
155430
|
+
topLevelChildStatements
|
|
155375
155431
|
} = statementMapWithChildStatements[statementNumber];
|
|
155376
|
-
|
|
155377
|
-
|
|
155378
|
-
|
|
155379
|
-
|
|
155380
|
-
|
|
155381
|
-
linesCoveredPerFile[endLine.toString()] = executionOrders;
|
|
155382
|
-
let currentLine = startLine + 1;
|
|
155383
|
-
const sortedChildren = [...topLevelChildStatements].sort((a, b2) => a.start.line - b2.start.line);
|
|
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
|
-
}
|
|
155432
|
+
let currentLine = startLine;
|
|
155433
|
+
let childStatementIdx = 0;
|
|
155434
|
+
while (currentLine <= endLine) {
|
|
155435
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
155436
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
155395
155437
|
currentLine++;
|
|
155438
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
155439
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
155440
|
+
currentLine++;
|
|
155441
|
+
} else {
|
|
155442
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
155443
|
+
childStatementIdx++;
|
|
155396
155444
|
}
|
|
155397
155445
|
}
|
|
155446
|
+
linesCoveredPerFile.add(startLine.toString());
|
|
155447
|
+
linesCoveredPerFile.add(endLine.toString());
|
|
155398
155448
|
}
|
|
155399
155449
|
}
|
|
155400
|
-
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
155450
|
+
unstretchedLinesCovered[filePathRel] = [...linesCoveredPerFile];
|
|
155401
155451
|
stretchedLinesCovered[filePathRel] = stretchCoverage(
|
|
155402
|
-
|
|
155452
|
+
unstretchedLinesCovered[filePathRel]
|
|
155403
155453
|
);
|
|
155404
155454
|
}
|
|
155405
155455
|
return {
|
|
@@ -155420,6 +155470,13 @@ function computeCoverageHash(coverage, commitId, platform) {
|
|
|
155420
155470
|
};
|
|
155421
155471
|
return sha1_default(stableStringify(hashPayload));
|
|
155422
155472
|
}
|
|
155473
|
+
function computeCoverageHashFromExtractedLineCoverageWithEachFile(linesCovered, commitId) {
|
|
155474
|
+
const hashPayload = {
|
|
155475
|
+
coverage: compressRequestCoverage(linesCovered),
|
|
155476
|
+
commitId
|
|
155477
|
+
};
|
|
155478
|
+
return sha1_default(stableStringify(hashPayload));
|
|
155479
|
+
}
|
|
155423
155480
|
|
|
155424
155481
|
// src/instrumentation/helpers/samplingLogic.ts
|
|
155425
155482
|
var import_generatedClient5 = __toESM(require_generatedClient2());
|
|
@@ -155443,7 +155500,7 @@ function remapCoverage(requestCoverage = {}) {
|
|
|
155443
155500
|
(coverage, filePathAbs) => {
|
|
155444
155501
|
const s = {};
|
|
155445
155502
|
for (const lineNumber of Object.keys(requestCoverage[filePathAbs])) {
|
|
155446
|
-
s[lineNumber] =
|
|
155503
|
+
s[lineNumber] = 1;
|
|
155447
155504
|
}
|
|
155448
155505
|
coverage[filePathAbs] = {
|
|
155449
155506
|
path: filePathAbs,
|
|
@@ -155590,6 +155647,10 @@ var setGitCommitHash = (commitHash) => {
|
|
|
155590
155647
|
}
|
|
155591
155648
|
};
|
|
155592
155649
|
var setCommitHashFromGit = () => {
|
|
155650
|
+
if (process.env.HT_COMMIT_ID && !process.env.HT_COMMIT_ID.toLocaleLowerCase().includes("unknown")) {
|
|
155651
|
+
_gitCommitHash = process.env.HT_COMMIT_ID;
|
|
155652
|
+
return _gitCommitHash;
|
|
155653
|
+
}
|
|
155593
155654
|
const spawnSyncOutput = (0, import_child_process3.spawnSync)("git", ["rev-parse", "HEAD"], {
|
|
155594
155655
|
cwd: process.cwd(),
|
|
155595
155656
|
/**
|
|
@@ -155610,7 +155671,13 @@ var setCommitHashFromGit = () => {
|
|
|
155610
155671
|
console.error(
|
|
155611
155672
|
`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
155673
|
);
|
|
155613
|
-
|
|
155674
|
+
process.env.HT_MODE = "DISABLED";
|
|
155675
|
+
console.log(
|
|
155676
|
+
"HT_MODE set to DISABLED due to inability to fetch current git commit hash"
|
|
155677
|
+
);
|
|
155678
|
+
updateHtMode();
|
|
155679
|
+
synchronousBlock(30);
|
|
155680
|
+
return;
|
|
155614
155681
|
}
|
|
155615
155682
|
_gitCommitHash = spawnSyncOutput.stdout.toString().trim();
|
|
155616
155683
|
return _gitCommitHash;
|
|
@@ -161208,19 +161275,36 @@ var HtServerMockAbstract = class {
|
|
|
161208
161275
|
}
|
|
161209
161276
|
const coverage = storeInstance4.getRequestCoverage(htRequestId);
|
|
161210
161277
|
if (coverage && Object.keys(coverage).length > 0) {
|
|
161211
|
-
|
|
161212
|
-
const
|
|
161213
|
-
|
|
161214
|
-
|
|
161215
|
-
|
|
161278
|
+
let totalRemappedCoverage = {};
|
|
161279
|
+
for (const filePath of Object.keys(coverage)) {
|
|
161280
|
+
const singleFileCoverage = {};
|
|
161281
|
+
singleFileCoverage[filePath] = coverage[filePath];
|
|
161282
|
+
const remappedSingleFileCoverage = remapCoverage(singleFileCoverage);
|
|
161283
|
+
const remappedCoverageData = extractCoverageData(
|
|
161284
|
+
remappedSingleFileCoverage
|
|
161285
|
+
);
|
|
161286
|
+
const linesCovered = getLinesCoveredWithExecutionOrder(
|
|
161287
|
+
remappedCoverageData,
|
|
161288
|
+
import_generatedClient6.Platform.NodeJS,
|
|
161289
|
+
coverage[filePath]
|
|
161290
|
+
);
|
|
161291
|
+
Object.assign(totalRemappedCoverage, linesCovered);
|
|
161292
|
+
}
|
|
161293
|
+
const coverageWithoutExecutionOrder = {};
|
|
161294
|
+
for (const filePath of Object.keys(totalRemappedCoverage)) {
|
|
161295
|
+
coverageWithoutExecutionOrder[filePath] = Object.keys(
|
|
161296
|
+
totalRemappedCoverage[filePath]
|
|
161297
|
+
);
|
|
161298
|
+
}
|
|
161299
|
+
const coverageHash = computeCoverageHashFromExtractedLineCoverageWithEachFile(
|
|
161300
|
+
coverageWithoutExecutionOrder,
|
|
161301
|
+
getGitCommitHash()
|
|
161216
161302
|
);
|
|
161217
161303
|
this.span.setAttribute("coverageHash", coverageHash);
|
|
161218
|
-
|
|
161219
|
-
|
|
161220
|
-
|
|
161221
|
-
import_generatedClient6.Platform.NodeJS
|
|
161304
|
+
this.span.setAttribute(
|
|
161305
|
+
"coverage",
|
|
161306
|
+
JSON.stringify(totalRemappedCoverage)
|
|
161222
161307
|
);
|
|
161223
|
-
this.span.setAttribute("coverage", JSON.stringify(linesCovered));
|
|
161224
161308
|
storeInstance4.deleteRequestCoverage(htRequestId);
|
|
161225
161309
|
}
|
|
161226
161310
|
this.span.setAttribute("output_status", this.outputStatus);
|
|
@@ -161234,7 +161318,7 @@ var HtServerMockAbstract = class {
|
|
|
161234
161318
|
if (this.parentHtRequestId) {
|
|
161235
161319
|
this.span.setAttribute("parentHtRequestId", this.parentHtRequestId);
|
|
161236
161320
|
}
|
|
161237
|
-
const gitCommitHash =
|
|
161321
|
+
const gitCommitHash = getGitCommitHash();
|
|
161238
161322
|
this.span.setAttribute("commit_hash", gitCommitHash);
|
|
161239
161323
|
const branch = process.env.HT_BRANCH_NAME || getBranchName();
|
|
161240
161324
|
this.span.setAttribute("branch", branch);
|
|
@@ -224314,7 +224398,8 @@ var initialiseNormally = (htConfig) => {
|
|
|
224314
224398
|
process.env.DD_TRACE_DISABLED_PLUGINS = current === "" ? "http2" : `${current},http2`;
|
|
224315
224399
|
}
|
|
224316
224400
|
const isCurrentFolderInGitRepo = isCurrentFolderInGitRepoFn();
|
|
224317
|
-
|
|
224401
|
+
const isDebugRun = process.env.HT_SDK_DEBUG === "true";
|
|
224402
|
+
if (!isDebugRun && isCurrentFolderInGitRepo && isHavingUncommittedChangesFn()) {
|
|
224318
224403
|
const gitDiff = getUncommittedChanges();
|
|
224319
224404
|
console.log(
|
|
224320
224405
|
"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-30";
|
|
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,62 @@ 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 currentLine = startLine;
|
|
163261
|
+
let childStatementIdx = 0;
|
|
163262
|
+
while (currentLine <= endLine) {
|
|
163263
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
163264
|
+
linesCoveredPerFile[currentLine.toString()] = codeCoverageData[statementNumber];
|
|
163265
|
+
currentLine++;
|
|
163266
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
163267
|
+
linesCoveredPerFile[currentLine.toString()] = codeCoverageData[statementNumber];
|
|
163268
|
+
currentLine++;
|
|
163269
|
+
} else {
|
|
163270
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
163271
|
+
childStatementIdx++;
|
|
163272
|
+
}
|
|
163273
|
+
}
|
|
163274
|
+
linesCoveredPerFile[startLine.toString()] = codeCoverageData[statementNumber];
|
|
163275
|
+
linesCoveredPerFile[endLine.toString()] = codeCoverageData[statementNumber];
|
|
163276
|
+
}
|
|
163277
|
+
}
|
|
163278
|
+
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
163279
|
+
}
|
|
163280
|
+
return normalizePaths(unstretchedLinesCovered);
|
|
163281
|
+
}
|
|
163226
163282
|
function getLinesCovered(coverage, platform) {
|
|
163227
163283
|
if (Object.keys(coverage).length === 0) {
|
|
163228
163284
|
return {
|
|
@@ -163260,7 +163316,7 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
163260
163316
|
const stretchedLinesCovered = {};
|
|
163261
163317
|
const unstretchedLinesCovered = {};
|
|
163262
163318
|
for (const [filePathAbs, fileCoverage] of Object.entries(coverage)) {
|
|
163263
|
-
const linesCoveredPerFile =
|
|
163319
|
+
const linesCoveredPerFile = /* @__PURE__ */ new Set();
|
|
163264
163320
|
const filePathRel = path.relative(projectRoot2, filePathAbs);
|
|
163265
163321
|
const statementMapWithChildStatements = getStatementMapWithChildStatements(
|
|
163266
163322
|
filePathRel,
|
|
@@ -163271,35 +163327,29 @@ Please contact hypertest team if the issue still persists.`);
|
|
|
163271
163327
|
const {
|
|
163272
163328
|
start: { line: startLine },
|
|
163273
163329
|
end: { line: endLine },
|
|
163274
|
-
topLevelChildStatements
|
|
163330
|
+
topLevelChildStatements
|
|
163275
163331
|
} = statementMapWithChildStatements[statementNumber];
|
|
163276
|
-
|
|
163277
|
-
|
|
163278
|
-
|
|
163279
|
-
|
|
163280
|
-
|
|
163281
|
-
linesCoveredPerFile[endLine.toString()] = executionOrders;
|
|
163282
|
-
let currentLine = startLine + 1;
|
|
163283
|
-
const sortedChildren = [...topLevelChildStatements].sort((a, b2) => a.start.line - b2.start.line);
|
|
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
|
-
}
|
|
163332
|
+
let currentLine = startLine;
|
|
163333
|
+
let childStatementIdx = 0;
|
|
163334
|
+
while (currentLine <= endLine) {
|
|
163335
|
+
if (childStatementIdx === topLevelChildStatements.length) {
|
|
163336
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
163295
163337
|
currentLine++;
|
|
163338
|
+
} else if (currentLine < topLevelChildStatements[childStatementIdx].start.line) {
|
|
163339
|
+
linesCoveredPerFile.add(currentLine.toString());
|
|
163340
|
+
currentLine++;
|
|
163341
|
+
} else {
|
|
163342
|
+
currentLine = topLevelChildStatements[childStatementIdx].end.line + 1;
|
|
163343
|
+
childStatementIdx++;
|
|
163296
163344
|
}
|
|
163297
163345
|
}
|
|
163346
|
+
linesCoveredPerFile.add(startLine.toString());
|
|
163347
|
+
linesCoveredPerFile.add(endLine.toString());
|
|
163298
163348
|
}
|
|
163299
163349
|
}
|
|
163300
|
-
unstretchedLinesCovered[filePathRel] = linesCoveredPerFile;
|
|
163350
|
+
unstretchedLinesCovered[filePathRel] = [...linesCoveredPerFile];
|
|
163301
163351
|
stretchedLinesCovered[filePathRel] = stretchCoverage(
|
|
163302
|
-
|
|
163352
|
+
unstretchedLinesCovered[filePathRel]
|
|
163303
163353
|
);
|
|
163304
163354
|
}
|
|
163305
163355
|
return {
|
|
@@ -163320,6 +163370,13 @@ function computeCoverageHash(coverage, commitId, platform) {
|
|
|
163320
163370
|
};
|
|
163321
163371
|
return sha1_default(stableStringify(hashPayload));
|
|
163322
163372
|
}
|
|
163373
|
+
function computeCoverageHashFromExtractedLineCoverageWithEachFile(linesCovered, commitId) {
|
|
163374
|
+
const hashPayload = {
|
|
163375
|
+
coverage: compressRequestCoverage(linesCovered),
|
|
163376
|
+
commitId
|
|
163377
|
+
};
|
|
163378
|
+
return sha1_default(stableStringify(hashPayload));
|
|
163379
|
+
}
|
|
163323
163380
|
|
|
163324
163381
|
// src/instrumentation/helpers/samplingLogic.ts
|
|
163325
163382
|
var import_generatedClient5 = __toESM(require_generatedClient2());
|
|
@@ -163343,7 +163400,7 @@ function remapCoverage(requestCoverage = {}) {
|
|
|
163343
163400
|
(coverage, filePathAbs) => {
|
|
163344
163401
|
const s = {};
|
|
163345
163402
|
for (const lineNumber of Object.keys(requestCoverage[filePathAbs])) {
|
|
163346
|
-
s[lineNumber] =
|
|
163403
|
+
s[lineNumber] = 1;
|
|
163347
163404
|
}
|
|
163348
163405
|
coverage[filePathAbs] = {
|
|
163349
163406
|
path: filePathAbs,
|
|
@@ -163490,6 +163547,10 @@ var setGitCommitHash = (commitHash) => {
|
|
|
163490
163547
|
}
|
|
163491
163548
|
};
|
|
163492
163549
|
var setCommitHashFromGit = () => {
|
|
163550
|
+
if (process.env.HT_COMMIT_ID && !process.env.HT_COMMIT_ID.toLocaleLowerCase().includes("unknown")) {
|
|
163551
|
+
_gitCommitHash = process.env.HT_COMMIT_ID;
|
|
163552
|
+
return _gitCommitHash;
|
|
163553
|
+
}
|
|
163493
163554
|
const spawnSyncOutput = spawnSync3("git", ["rev-parse", "HEAD"], {
|
|
163494
163555
|
cwd: process.cwd(),
|
|
163495
163556
|
/**
|
|
@@ -163510,7 +163571,13 @@ var setCommitHashFromGit = () => {
|
|
|
163510
163571
|
console.error(
|
|
163511
163572
|
`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
163573
|
);
|
|
163513
|
-
|
|
163574
|
+
process.env.HT_MODE = "DISABLED";
|
|
163575
|
+
console.log(
|
|
163576
|
+
"HT_MODE set to DISABLED due to inability to fetch current git commit hash"
|
|
163577
|
+
);
|
|
163578
|
+
updateHtMode();
|
|
163579
|
+
synchronousBlock(30);
|
|
163580
|
+
return;
|
|
163514
163581
|
}
|
|
163515
163582
|
_gitCommitHash = spawnSyncOutput.stdout.toString().trim();
|
|
163516
163583
|
return _gitCommitHash;
|
|
@@ -164989,19 +165056,36 @@ var HtServerMockAbstract = class {
|
|
|
164989
165056
|
}
|
|
164990
165057
|
const coverage = storeInstance4.getRequestCoverage(htRequestId);
|
|
164991
165058
|
if (coverage && Object.keys(coverage).length > 0) {
|
|
164992
|
-
|
|
164993
|
-
const
|
|
164994
|
-
|
|
164995
|
-
|
|
164996
|
-
|
|
165059
|
+
let totalRemappedCoverage = {};
|
|
165060
|
+
for (const filePath of Object.keys(coverage)) {
|
|
165061
|
+
const singleFileCoverage = {};
|
|
165062
|
+
singleFileCoverage[filePath] = coverage[filePath];
|
|
165063
|
+
const remappedSingleFileCoverage = remapCoverage(singleFileCoverage);
|
|
165064
|
+
const remappedCoverageData = extractCoverageData(
|
|
165065
|
+
remappedSingleFileCoverage
|
|
165066
|
+
);
|
|
165067
|
+
const linesCovered = getLinesCoveredWithExecutionOrder(
|
|
165068
|
+
remappedCoverageData,
|
|
165069
|
+
import_generatedClient6.Platform.NodeJS,
|
|
165070
|
+
coverage[filePath]
|
|
165071
|
+
);
|
|
165072
|
+
Object.assign(totalRemappedCoverage, linesCovered);
|
|
165073
|
+
}
|
|
165074
|
+
const coverageWithoutExecutionOrder = {};
|
|
165075
|
+
for (const filePath of Object.keys(totalRemappedCoverage)) {
|
|
165076
|
+
coverageWithoutExecutionOrder[filePath] = Object.keys(
|
|
165077
|
+
totalRemappedCoverage[filePath]
|
|
165078
|
+
);
|
|
165079
|
+
}
|
|
165080
|
+
const coverageHash = computeCoverageHashFromExtractedLineCoverageWithEachFile(
|
|
165081
|
+
coverageWithoutExecutionOrder,
|
|
165082
|
+
getGitCommitHash()
|
|
164997
165083
|
);
|
|
164998
165084
|
this.span.setAttribute("coverageHash", coverageHash);
|
|
164999
|
-
|
|
165000
|
-
|
|
165001
|
-
|
|
165002
|
-
import_generatedClient6.Platform.NodeJS
|
|
165085
|
+
this.span.setAttribute(
|
|
165086
|
+
"coverage",
|
|
165087
|
+
JSON.stringify(totalRemappedCoverage)
|
|
165003
165088
|
);
|
|
165004
|
-
this.span.setAttribute("coverage", JSON.stringify(linesCovered));
|
|
165005
165089
|
storeInstance4.deleteRequestCoverage(htRequestId);
|
|
165006
165090
|
}
|
|
165007
165091
|
this.span.setAttribute("output_status", this.outputStatus);
|
|
@@ -165015,7 +165099,7 @@ var HtServerMockAbstract = class {
|
|
|
165015
165099
|
if (this.parentHtRequestId) {
|
|
165016
165100
|
this.span.setAttribute("parentHtRequestId", this.parentHtRequestId);
|
|
165017
165101
|
}
|
|
165018
|
-
const gitCommitHash =
|
|
165102
|
+
const gitCommitHash = getGitCommitHash();
|
|
165019
165103
|
this.span.setAttribute("commit_hash", gitCommitHash);
|
|
165020
165104
|
const branch = process.env.HT_BRANCH_NAME || getBranchName();
|
|
165021
165105
|
this.span.setAttribute("branch", branch);
|
|
@@ -231829,7 +231913,8 @@ var initialiseNormally = (htConfig) => {
|
|
|
231829
231913
|
process.env.DD_TRACE_DISABLED_PLUGINS = current === "" ? "http2" : `${current},http2`;
|
|
231830
231914
|
}
|
|
231831
231915
|
const isCurrentFolderInGitRepo = isCurrentFolderInGitRepoFn();
|
|
231832
|
-
|
|
231916
|
+
const isDebugRun = process.env.HT_SDK_DEBUG === "true";
|
|
231917
|
+
if (!isDebugRun && isCurrentFolderInGitRepo && isHavingUncommittedChangesFn()) {
|
|
231833
231918
|
const gitDiff = getUncommittedChanges();
|
|
231834
231919
|
console.log(
|
|
231835
231920
|
"The following are the uncommitted changes in your repository."
|