-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from jamestalmage/recast-forking
- Loading branch information
Showing
10 changed files
with
169 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
coverage | ||
node_modules | ||
!node_modules/spawn-wrap | ||
test/build/ | ||
.self_coverage | ||
*.covered.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var istanbul = require('istanbul') | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
;[ | ||
'index.js', | ||
'lib/source-map-cache.js' | ||
].forEach(function (name) { | ||
var indexPath = path.join(__dirname, name) | ||
var source = fs.readFileSync(indexPath, 'utf8') | ||
|
||
var instrumentor = new istanbul.Instrumenter({ | ||
coverageVariable: '___nyc_self_coverage___', | ||
esModules: true, | ||
noAutoWrap: true | ||
}) | ||
|
||
var instrumentedSource = instrumentor.instrumentSync(source, indexPath) | ||
|
||
var outputPath = path.join(__dirname, name.replace(/\.js$/, '.covered.js')) | ||
fs.writeFileSync(outputPath, instrumentedSource) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
var fs = require('fs') | ||
var path = require('path') | ||
var del = require('del') | ||
var mkdirp = require('mkdirp') | ||
var forkingTap = require('forking-tap') | ||
var zeroFill = require('zero-fill') | ||
var sanitizeFilename = require('sanitize-filename') | ||
|
||
// Delete previous files. | ||
process.chdir(__dirname) | ||
del.sync(['test/build']) | ||
mkdirp.sync(path.join(__dirname, 'test/build')) | ||
|
||
var testDir = path.join(__dirname, 'test/src') | ||
var buildDir = path.join(__dirname, 'test/build') | ||
var originalTestsFilename = path.join(testDir, 'nyc-test.js') | ||
var originalTestSource = fs.readFileSync(originalTestsFilename, 'utf8') | ||
var individualTests = forkingTap(originalTestSource, { | ||
filename: originalTestsFilename, | ||
attachComment: true | ||
}) | ||
|
||
individualTests.forEach(function (test, i) { | ||
var filename = ['built', zeroFill(3, i)] | ||
.concat(test.nestedName) | ||
.join('-') + '.js' | ||
|
||
// file names with spaces are legal, but annoying to use w/ CLI commands | ||
filename = filename.replace(/\s/g, '_') | ||
|
||
// istanbul freaks out if the there are `'` characters in the file name | ||
filename = filename.replace(/'/g, '') | ||
|
||
// remove any illegal chars | ||
filename = sanitizeFilename(filename) | ||
|
||
fs.writeFileSync(path.join(buildDir, filename), test.code) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* global ___nyc_self_coverage___ */ | ||
|
||
var path = require('path') | ||
var fs = require('fs') | ||
var mkdirp = require('mkdirp') | ||
var onExit = require('signal-exit') | ||
|
||
onExit(function () { | ||
var coverage = global.___nyc_self_coverage___ | ||
if (typeof ___nyc_self_coverage___ === 'object') coverage = ___nyc_self_coverage___ | ||
if (!coverage) return | ||
|
||
var selfCoverageDir = path.join(__dirname, '../.self_coverage') | ||
mkdirp.sync(selfCoverageDir) | ||
fs.writeFileSync( | ||
path.join(selfCoverageDir, process.pid + '.json'), | ||
JSON.stringify(coverage), | ||
'utf-8' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.