Comparing version 3.0.3 to 3.0.4
@@ -9,5 +9,10 @@ import FileCov from './file-cov.js'; | ||
const EMPTY_TEXT_REGEX = /^\s*$/; | ||
const ONE_LINE_REMARK_REGEX = /^\s*\/\//; | ||
const MUL_LINE_REMARK_OPEN_REGEX = /(?<prec>.*)\/\*/; | ||
const MUL_LINE_REMARK_CLOSE_REGEX = /\*\/(?<post>.*)/; | ||
async function buildJTFileCov(sourceUrl, everImported, sourceFetcher = defaultSourceFetcher) { | ||
if (!sourceUrl || typeof sourceUrl !== 'string') { | ||
throw new Error(`soure URL MUST be a non-empty string, got: '${sourceUrl}'`); | ||
throw new Error(`source URL MUST be a non-empty string, got: '${sourceUrl}'`); | ||
} | ||
@@ -27,38 +32,44 @@ if (typeof everImported !== 'boolean') { | ||
// setup lines from source | ||
const eolPoses = text.matchAll(/[\r\n]{1,2}/gm); | ||
let comment = false, | ||
indexPos = 0, | ||
linePos = 1; | ||
// get lines from source | ||
const lines = text.split(/(\r\n|\n)/); | ||
// all lines but last | ||
for (const eolPos of eolPoses) { | ||
const lineText = text.substring(indexPos, eolPos.index); | ||
let loc = true; | ||
if (eolPos.index === indexPos) { | ||
loc = false; // empty line | ||
let comment = false; | ||
let stillTakeThisLine = false; | ||
let indexPos = 0; | ||
let linePos = 0; | ||
for (let i = 0, l = lines.length; i < l; i++) { | ||
const line = lines[i]; | ||
linePos++; | ||
indexPos += line.length; | ||
if (!line || EMPTY_TEXT_REGEX.test(line)) { | ||
if (line === '\n' || line === '\r\n') { | ||
linePos--; | ||
} | ||
continue; | ||
} | ||
if (lineText.match(/\s*\/\//)) { | ||
loc = false; // comment starting with `//` | ||
if (ONE_LINE_REMARK_REGEX.test(line)) { | ||
continue; | ||
} | ||
if (lineText.match(/\/\*\*/)) { | ||
const matchOpenRemark = line.match(MUL_LINE_REMARK_OPEN_REGEX); | ||
if (matchOpenRemark) { | ||
comment = true; | ||
if (!EMPTY_TEXT_REGEX.test(matchOpenRemark.groups.prec)) { | ||
stillTakeThisLine = true; | ||
} | ||
} | ||
if (lineText.match(/\*\//)) { | ||
const matchCloseRemark = line.match(MUL_LINE_REMARK_CLOSE_REGEX); | ||
if (matchCloseRemark) { | ||
comment = false; | ||
loc = false; | ||
if (EMPTY_TEXT_REGEX.test(matchCloseRemark.groups.post) && !stillTakeThisLine) { | ||
continue; | ||
} | ||
} | ||
if (loc && !comment) { | ||
result.addLineCov(new LineCov(linePos, indexPos, eolPos.index)); | ||
if (!comment || stillTakeThisLine) { | ||
result.addLineCov(new LineCov(linePos, indexPos - line.length, indexPos)); | ||
} | ||
indexPos = eolPos.index + eolPos[0].length; | ||
linePos++; | ||
} | ||
// last line | ||
if (text.length > indexPos) { | ||
result.addL | ||
result.addLineCov(new LineCov(linePos, indexPos, text.length)); | ||
} | ||
return result; | ||
@@ -65,0 +76,0 @@ } |
@@ -148,2 +148,3 @@ // this is the main just-test SDK harness entrypoint from consumer perspective | ||
} catch (e) { | ||
console.error(e); | ||
runResult = e; | ||
@@ -150,0 +151,0 @@ } finally { |
@@ -67,3 +67,3 @@ /** | ||
if (!sesEnvs.length) { | ||
logger.info(`all session ${sessionId} environments closed, finalizing session`); | ||
logger.info(`all environments of session ${sessionId} are closed, finalizing session`); | ||
finalizeSession(sessionId); | ||
@@ -70,0 +70,0 @@ } |
{ | ||
"name": "just-test", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "JavaScript tests runner", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156191
4391