Skip to content

Commit 6714de0

Browse files
JF Paradisjfparadis
JF Paradis
authored andcommitted
Add code coverage
1 parent 8da9239 commit 6714de0

File tree

8 files changed

+34
-2
lines changed

8 files changed

+34
-2
lines changed

.esmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cache": false
3+
}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
yarn.lock
3-
yarn-error.log
3+
yarn-error.log
4+
.nyc_output

.nycrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"include": [
3+
"shim/src/**/*.js"
4+
],
5+
"check-coverage": true,
6+
"per-file": false,
7+
"statements": 82,
8+
"branches": 62,
9+
"functions": 92,
10+
"lines": 84,
11+
"cache": false
12+
}

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"shim:build:prod": "cross-env NODE_ENV=production rollup -c shim/rollup.config.js",
1313
"shim:lint": "eslint ./shim/src/**/*.js ./shim/test/**/*.js",
1414
"shim:prettier": "prettier --config ./shim/.prettierrc --write ./shim/src/**/*.js ./shim/test/**/*.js",
15-
"shim:test": "tape -r esm ./shim/test/**/*.js"
15+
"shim:test": "tape -r esm ./shim/test/**/*.js",
16+
"shim:coverage": "nyc --require esm tape ./shim/test/**/*.js | tap-nyc"
1617
},
1718
"repository": {
1819
"type": "git",
@@ -49,10 +50,12 @@
4950
"eslint-plugin-prettier": "^2.6.0",
5051
"esm": "^3.0.37",
5152
"forever": "^0.15.2",
53+
"nyc": "^12.0.2",
5254
"prettier": "^1.12.1",
5355
"rollup": "^0.58.2",
5456
"rollup-plugin-babel-minify": "^4.0.0",
5557
"rollup-watch": "^3.2.2",
58+
"tap-nyc": "^1.0.3",
5659
"tape": "^4.9.0"
5760
}
5861
}

shim/src/accessors.js

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ the bug.
2828
// inside each new RootRealm to fix their Object.prototypes too. So don't
2929
// import anything from the outside.
3030

31+
// todo: This function is serialized and evaluated outside of the primal
32+
// realms and it currently can't contain code coverage metrics.
33+
/* istanbul ignore file */
3134
export function repairAccessors() {
3235
const { getPrototypeOf, defineProperties, defineProperty, getOwnPropertyDescriptor } = Object;
3336

shim/src/evaluators.js

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ function createScopedEvaluatorFactory(unsafeRec, constants) {
101101
// back to 'false', so any instances of 'eval' in that string will get the
102102
// safe evaluator.
103103

104+
// todo: This function is serialized and evaluated outside of the primal
105+
// realms and it currently can't contain code coverage metrics.
106+
/* istanbul ignore next */
104107
return unsafeFunction(`
105108
with (arguments[0]) {
106109
${optimizer}

shim/src/functions.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { defineProperty, defineProperties, getPrototypeOf, setPrototypeOf } from
1313
* 4. Replace its prototype property's constructor with itself
1414
* 5. Replace its [[Prototype]] slot with the noop constructor of Function
1515
*/
16+
17+
// todo: This function is serialized and evaluated outside of the primal
18+
// realms and it currently can't contain code coverage metrics.
19+
/* istanbul ignore file */
1620
function repairFunction(unsafeRec, functionName, functionDecl) {
1721
const { unsafeEval, unsafeFunction, unsafeGlobal } = unsafeRec;
1822

shim/src/realmFacade.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// buildChildRealm is immediately turned into a string, and this function is
55
// never referenced again, because it closes over the wrong intrinsics
66

7+
// todo: This function is serialized and evaluated outside of the primal
8+
// realms and it currently can't contain code coverage metrics.
9+
/* istanbul ignore next */
710
function buildChildRealm({ initRootRealm, initCompartment, getRealmGlobal, realmEvaluate }) {
811
// This Object and Reflect are brand new, from a new unsafeRec, so no user
912
// code has been run or had a chance to manipulate them. We extract these

0 commit comments

Comments
 (0)