Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LCOV Support #352

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions __tests__/__outputs__/lcov-report-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
![Tests failed](https://img.shields.io/badge/tests-4%20passed%2C%202%20failed-critical)
## ❌ <a id="user-content-r0" href="#r0">fixtures/lcov.info</a>
**6** tests were completed in **0ms** with **4** passed, **2** failed and **0** skipped.
|Test suite|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|[src/services/notifier/NotifierService.js](#r0s0)|2✅|1❌||0ms|
|[src/services/notifier/providers/DiscordNotifierProvider.js](#r0s1)|2✅|1❌||0ms|
### ❌ <a id="user-content-r0s0" href="#r0s0">src/services/notifier/NotifierService.js</a>
```
src/services/notifier/NotifierService.js
✅ lines 100% (21/21)
✅ functions 100% (10/10)
❌ branches 50% (3/6)
```
### ❌ <a id="user-content-r0s1" href="#r0s1">src/services/notifier/providers/DiscordNotifierProvider.js</a>
```
src/services/notifier/providers/DiscordNotifierProvider.js
✅ lines 100% (17/17)
✅ functions 100% (3/3)
❌ branches 75% (3/4)
```
62 changes: 62 additions & 0 deletions __tests__/__snapshots__/lcov.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`lcov report coverage report from facebook/jest test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/lcov.info",
"suites": [
TestSuiteResult {
"groups": [
TestGroupResult {
"name": "src/services/notifier/NotifierService.js",
"tests": [
{
"name": "lines 100% (21/21)",
"result": "success",
"time": 0,
},
{
"name": "functions 100% (10/10)",
"result": "success",
"time": 0,
},
{
"name": "branches 50% (3/6)",
"result": "failed",
"time": 0,
},
],
},
],
"name": "src/services/notifier/NotifierService.js",
"totalTime": undefined,
},
TestSuiteResult {
"groups": [
TestGroupResult {
"name": "src/services/notifier/providers/DiscordNotifierProvider.js",
"tests": [
{
"name": "lines 100% (17/17)",
"result": "success",
"time": 0,
},
{
"name": "functions 100% (3/3)",
"result": "success",
"time": 0,
},
{
"name": "branches 75% (3/4)",
"result": "failed",
"time": 0,
},
],
},
],
"name": "src/services/notifier/providers/DiscordNotifierProvider.js",
"totalTime": undefined,
},
],
"totalTime": undefined,
}
`;
92 changes: 92 additions & 0 deletions __tests__/fixtures/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
TN:
SF:src/services/notifier/NotifierService.js
FN:9,(anonymous_0)
FN:10,(anonymous_1)
FN:26,(anonymous_2)
FN:27,(anonymous_3)
FN:29,(anonymous_4)
FN:30,(anonymous_5)
FN:46,(anonymous_6)
FN:47,(anonymous_7)
FN:48,(anonymous_8)
FN:49,(anonymous_9)
FNF:10
FNH:10
FNDA:1,(anonymous_0)
FNDA:1,(anonymous_1)
FNDA:1,(anonymous_2)
FNDA:3,(anonymous_3)
FNDA:3,(anonymous_4)
FNDA:3,(anonymous_5)
FNDA:1,(anonymous_6)
FNDA:3,(anonymous_7)
FNDA:3,(anonymous_8)
FNDA:3,(anonymous_9)
DA:9,1
DA:10,1
DA:11,1
DA:13,1
DA:14,1
DA:26,1
DA:27,3
DA:29,1
DA:30,3
DA:31,3
DA:33,3
DA:34,3
DA:46,1
DA:47,3
DA:48,3
DA:51,3
DA:53,3
DA:54,3
DA:58,3
DA:61,1
DA:64,1
LF:21
LH:21
BRDA:11,0,0,1
BRDA:11,0,1,0
BRDA:31,1,0,3
BRDA:31,1,1,0
BRDA:51,2,0,3
BRDA:51,2,1,0
BRF:6
BRH:3
end_of_record
TN:
SF:src/services/notifier/providers/DiscordNotifierProvider.js
FN:12,(anonymous_0)
FN:33,(anonymous_1)
FN:51,(anonymous_2)
FNF:3
FNH:3
FNDA:1,(anonymous_0)
FNDA:1,(anonymous_1)
FNDA:1,(anonymous_2)
DA:3,1
DA:12,1
DA:13,1
DA:14,1
DA:22,1
DA:23,1
DA:33,1
DA:34,1
DA:35,1
DA:40,1
DA:41,1
DA:51,1
DA:52,1
DA:53,1
DA:58,1
DA:59,1
DA:62,1
LF:17
LH:17
BRDA:18,0,0,0
BRDA:18,0,1,1
BRDA:20,1,0,1
BRDA:20,1,1,1
BRF:4
BRH:3
end_of_record
23 changes: 23 additions & 0 deletions __tests__/lcov.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as fs from 'fs'
import * as path from 'path'

import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
import {LcovParser} from '../src/parsers/lcov/lcov-parser'

describe('lcov report coverage', () => {
it('report from facebook/jest test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'lcov.info')
const outputPath = path.join(__dirname, '__outputs__', 'lcov-report-results.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})

const parser = new LcovParser({parseErrors: true, trackedFiles: []})
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()

const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
})
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ inputs:
- jest-junit
- mocha-json
- swift-xunit
- lcov
required: true
list-suites:
description: |
Expand Down
Loading