Skip to content

Commit

Permalink
Merge pull request #54 from p3drosola/master
Browse files Browse the repository at this point in the history
Add option to ignore paths
  • Loading branch information
mdeanjones authored Mar 1, 2023
2 parents e92d750 + 81d1576 commit 787e47a
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/lcov-result-merger.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ const args = yargs(hideBin(process.argv)).command(
'If using --prepend-source-files, this is needed to describe the relative path from the lcov ' +
'directory to the project root.',
},
ignore: {
type: 'array',
default: [],
description: 'Pass globs to ignore file paths',
},
});
}
).argv;

fg.stream(args.pattern, { absolute: true })
fg.stream(args.pattern, { absolute: true, ignore: args.ignore })
.pipe(lcovResultMerger(args))
.pipe(
through.obj((filePath) => {
const fileContentStr = fs.readFileSync(filePath, {
encoding: 'utf-8',
flag: 'r+'
flag: 'r+',
});
fs.unlinkSync(filePath);

Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/ignore/a/extra.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TN:
SF:./src/extra.js
FNF:0
FNH:0
DA:1,1
LF:1
LH:1
BRF:0
BRH:0
end_of_record
53 changes: 53 additions & 0 deletions test/fixtures/ignore/a/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
TN:
SF:./src/index.js
FNF:0
FNH:0
DA:1,1
LF:1
LH:1
BRF:0
BRH:0
end_of_record
TN:
SF:./src/Foo.js
FN:1,f1
FN:4,fn2
FN:7,fn3
FN:13,fn4
FN:19,fn5
FN:20,fn6
FN:33,fn7
FNF:7
FNH:7
FNDA:1,f1
FNDA:17,fn2
FNDA:8,fn3
FNDA:3,fn4
FNDA:9,fn5
FNDA:17,fn6
FNDA:9,fn7
DA:1,1
DA:4,1
DA:5,17
DA:8,8
DA:13,1
DA:14,3
DA:15,3
DA:16,3
DA:19,1
DA:20,9
DA:21,17
DA:24,9
DA:25,1
DA:28,8
DA:33,1
DA:34,9
DA:37,1
LF:17
LH:17
BRDA:24,1,0,-
BRDA:24,1,1,8
BRDA:24,1,2,-
BRF:2
BRH:2
end_of_record
53 changes: 53 additions & 0 deletions test/fixtures/ignore/b/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
TN:
SF:./src/index.js
FNF:0
FNH:0
DA:1,1
LF:1
LH:1
BRF:0
BRH:0
end_of_record
TN:
SF:./src/Foo.js
FN:1,f1
FN:4,fn2
FN:7,fn3
FN:13,fn4
FN:19,fn5
FN:20,fn6
FN:33,fn7
FNF:7
FNH:7
FNDA:1,f1
FNDA:17,fn2
FNDA:8,fn3
FNDA:3,fn4
FNDA:9,fn5
FNDA:17,fn6
FNDA:9,fn7
DA:1,1
DA:4,1
DA:5,17
DA:8,8
DA:13,1
DA:14,3
DA:15,3
DA:16,3
DA:19,1
DA:20,9
DA:21,17
DA:24,9
DA:25,1
DA:28,8
DA:33,1
DA:34,9
DA:37,1
LF:17
LH:17
BRDA:24,1,0,2
BRDA:24,1,1,8
BRDA:24,1,2,-
BRF:2
BRH:2
end_of_record
8 changes: 8 additions & 0 deletions test/lcov-result-merger-cmd-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ describe('lcovResultMerger CLI', function () {
actual.should.equal(getExpected('basic'));
});

it('should ignore paths with the --ignore option', async function () {
const actual = await runCli(
['--ignore="**/extra.info"'],
'"./test/fixtures/ignore/*/*.info"'
);
actual.should.equal(getExpected('basic'));
});

it('should optionally prepend source file lines', async function () {
const actual = await runCli([
'--prepend-source-files',
Expand Down

0 comments on commit 787e47a

Please sign in to comment.