Skip to content

Commit

Permalink
Fix coverage report for cics repo
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Apr 4, 2024
1 parent a2f0971 commit 7bd36a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion coverage-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ projects:
unit-vsce:
junit-artifact: main.yml/ubuntu-latest-20.x-results/vsce/__tests__/__results__/unit
system:
test-count: npm-jest
test-count: npm-jest:packages/cli:packages/sdk
"zowe/zowe-cli-db2-plugin":
unit:
junit-artifact: zowe-cli-plugin.yml/ubuntu-latest-20.x-results/unit
Expand Down
15 changes: 9 additions & 6 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ async function checkLcovArtifact(repo, type, workflow, artifact, dirname) {
return { lineCoverage, hitLines, foundLines, branchCoverage, hitBranches, foundBranches };
};

async function checkTestCount(repo, type, tools) {
async function checkTestCount(repo, type, tools, ...subDirs) {
const tempDir = await gitCloneDir(repo);
await exec.exec("npm", ["install", "--ignore-scripts", "--silent"], { cwd: tempDir });
const output = await exec.getExecOutput("npm", ["run", `test:${type}`, "--", "--listTests"], { cwd: tempDir });
let numTests = 0;
for (const testFile of output.stdout.trim().split("\n").filter(line => line.includes(tempDir))) {
const testContents = stripComments(fs.readFileSync(testFile, "utf-8"));
numTests += (testContents.match(/\bit\(/g) || []).length;
for (const subDir of (subDirs.length ? subDirs : [""])) {
const output = await exec.getExecOutput("npm", ["run", `test:${type}`, "--", "--listTests"],
{ cwd: path.join(tempDir, subDir) });
for (const testFile of output.stdout.trim().split("\n").filter(line => line.includes(tempDir))) {
const testContents = stripComments(fs.readFileSync(testFile, "utf-8"));
numTests += (testContents.match(/\bit\(/g) || []).length;
}
}
return { numTests };
};
Expand All @@ -132,7 +135,7 @@ async function checkTestCount(repo, type, tools) {
covData = { ...covData, ...await checkLcovArtifact(repoName, testType, ...splitAndAppend(covConfig, "/", 3)) };
break;
case "test-count":
covData = { ...covData, ...await checkTestCount(repoName, testType, covConfig) };
covData = { ...covData, ...await checkTestCount(repoName, testType, ...covConfig.split(":")) };
break;
default:
throw new Error("Unsupported coverage type " + covType);
Expand Down

0 comments on commit 7bd36a7

Please sign in to comment.