Skip to content

Commit

Permalink
chore: Improve self-coverage collection. (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell authored Mar 13, 2019
1 parent d8f28e9 commit 364eb33
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/_generateReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _ = require('lodash')
var rimraf = require('rimraf')
var sourceMapFixtures = require('source-map-fixtures')

var NYC = require('../../')
var NYC = require('../../self-coverage')

// Load source map fixtures.
var fixtures = {
Expand Down
21 changes: 9 additions & 12 deletions test/nyc-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

require('source-map-support').install({ hookRequire: true })

const fs = require('fs')
const _ = require('lodash')
const ap = require('any-path')
const configUtil = require('../lib/config-util')
const fs = require('fs')

let NYC
try {
NYC = require('../index.covered.js')
} catch (e) {
NYC = require('../')
}
const configUtil = require('../self-coverage/lib/config-util')
const NYC = require('../self-coverage')
// we test exit handlers in nyc-integration.js.
NYC.prototype._wrapExit = () => {}

Expand All @@ -21,12 +16,14 @@ const rimraf = require('rimraf')
const isWindows = require('is-windows')()
const spawn = require('child_process').spawn
const fixtures = path.resolve(__dirname, './fixtures')
const bin = path.resolve(__dirname, '../bin/nyc')
const bin = path.resolve(__dirname, '../self-coverage/bin/nyc')
const resetState = require('./lib/reset-state')

require('chai').should()
require('tap').mochaGlobals()

const transpileHook = path.resolve(process.cwd(), './test/fixtures/transpile-hook')

describe('nyc', function () {
beforeEach(resetState)

Expand Down Expand Up @@ -392,7 +389,7 @@ describe('nyc', function () {
'utf-8'
)

var nyc = (new NYC(configUtil.buildYargs(fixtures).parse(['--require', './test/fixtures/transpile-hook'])))
var nyc = (new NYC(configUtil.buildYargs(fixtures).parse(['--require', transpileHook])))
nyc.reset()
nyc.addAllFiles()

Expand All @@ -418,7 +415,7 @@ describe('nyc', function () {
)

var nyc = (new NYC(configUtil.buildYargs(fixtures).parse([
'--require=./test/fixtures/transpile-hook',
`--require=${transpileHook}`,
'--extension=.do-not-transpile',
'--include=needs-transpile.do-not-transpile'
])))
Expand All @@ -438,7 +435,7 @@ describe('nyc', function () {
)

var nyc = (new NYC(configUtil.buildYargs(fixtures).parse([
'--require=./test/fixtures/transpile-hook',
`--require=${transpileHook}`,
'--extension=.whatever'
])))

Expand Down
2 changes: 1 addition & 1 deletion test/process-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('chai').should()
require('tap').mochaGlobals()

const processArgs = require('../lib/process-args')
const processArgs = require('../self-coverage/lib/process-args')

describe('process-args', function () {
describe('hideInstrumenterArgs', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/src/nyc-tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require('source-map-support').install({ hookRequire: true })

const fs = require('fs')
const _ = require('lodash')
const ap = require('any-path')
const configUtil = require('../../lib/config-util')
const fs = require('fs')
const enableCache = false

const configUtil = require('../../self-coverage/lib/config-util')
const _NYC = require('../../self-coverage')

function NYC (opts) {
Expand Down

0 comments on commit 364eb33

Please sign in to comment.