From 64834ca624928e80d12cbfd6fada8bf82c4e33d5 Mon Sep 17 00:00:00 2001 From: Eugene Retunsky Date: Tue, 18 Aug 2020 08:17:33 -0700 Subject: [PATCH] Ability to add exclusions to grcov https://github.com/actions-rs/grcov/issues/80 --- README.md | 6 ++++++ src/configuration.ts | 24 ++++++++++++++++++++++++ src/grcov.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/README.md b/README.md index aba1773..c5775fe 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,12 @@ ignore: path-mapping: - "/path1" - "/path2" +excl-br-line: "#\[(derive(.*)\]" +excl-br-start: "#\[test\]" +excl-br-stop: "cov:excl-br-stop" +excl-line: "cov:excl-line" +excl-start: "mod test" +excl-stop: "cov:excl-stop" ``` ## Notes diff --git a/src/configuration.ts b/src/configuration.ts index 6bb9de9..507c24c 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -32,6 +32,12 @@ export interface User { pathMapping?: string[], prefixDir?: string, outputPath?: string, + excl_br_line?: string, + excl_br_start?: string, + excl_br_stop?: string, + excl_line?: string, + excl_start?: string, + excl_stop?: string, } /** @@ -125,6 +131,24 @@ async function loadUser(path: string): Promise { if (contents['prefix-dir']) { user.prefixDir = contents['prefix-dir']; } + if (contents['excl-br-line']) { + user.excl_br_line = contents['excl-br-line']; + } + if (contents['excl-br-start']) { + user.excl_br_start = contents['excl-br-start']; + } + if (contents['excl-br-stop']) { + user.excl_br_stop = contents['excl-br-stop']; + } + if (contents['excl-line']) { + user.excl_line = contents['excl-line']; + } + if (contents['excl-start']) { + user.excl_start = contents['excl-start']; + } + if (contents['excl-stop']) { + user.excl_stop = contents['excl-stop']; + } if (contents['output-path']) { user.outputPath = contents['output-path']; } else if (contents['output-file']) { diff --git a/src/grcov.ts b/src/grcov.ts index 4b57504..e77c201 100644 --- a/src/grcov.ts +++ b/src/grcov.ts @@ -111,6 +111,36 @@ export class Grcov { args.push(config.user.prefixDir); } + if (config.user.excl_br_line) { + args.push('--excl-br-line'); + args.push(config.user.excl_br_line); + } + + if (config.user.excl_br_start) { + args.push('--excl-br-start'); + args.push(config.user.excl_br_start); + } + + if (config.user.excl_br_stop) { + args.push('--excl-br-stop'); + args.push(config.user.excl_br_stop); + } + + if (config.user.excl_line) { + args.push('--excl-line'); + args.push(config.user.excl_line); + } + + if (config.user.excl_start) { + args.push('--excl-start'); + args.push(config.user.excl_start); + } + + if (config.user.excl_stop) { + args.push('--excl-stop'); + args.push(config.user.excl_stop); + } + // TODO: // args.push('--service-job-number'); // args.push('');