-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Build: Produce C/JS code coverage reports from make #10856
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| 'use strict'; | ||
| const process = require('process'); | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
| const mkdirSync = fs.mkdirSync; | ||
| const writeFileSync = fs.writeFileSync; | ||
|
|
||
| var isWritingCoverage = false; | ||
| function writeCoverage() { | ||
| if (isWritingCoverage || !global.__coverage__) { | ||
| return; | ||
| } | ||
| isWritingCoverage = true; | ||
|
|
||
| const dirname = path.join(path.dirname(process.execPath), '.coverage'); | ||
| const filename = `coverage-${process.pid}-${Date.now()}.json`; | ||
| try { | ||
| mkdirSync(dirname); | ||
| } catch (err) { | ||
| if (err.code !== 'EEXIST') { | ||
| console.error(err); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const target = path.join(dirname, filename); | ||
| const coverageInfo = JSON.stringify(global.__coverage__); | ||
| try { | ||
| writeFileSync(target, coverageInfo); | ||
| } catch (err) { | ||
| console.error(err); | ||
| } | ||
| } | ||
|
|
||
| function setup() { | ||
| var reallyReallyExit = process.reallyExit; | ||
|
||
|
|
||
| process.reallyExit = function(code) { | ||
| writeCoverage(); | ||
| reallyReallyExit(code); | ||
| }; | ||
|
||
|
|
||
| process.on('exit', writeCoverage); | ||
| } | ||
|
||
|
|
||
| exports.setup = setup; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| 'use strict'; | ||
| require('../common'); | ||
| const common = require('../common'); | ||
|
||
| const assert = require('assert'); | ||
| const fs = require('fs'); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too much whitespace, need to remove two of these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed