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

chore(code coverage): enable coverage remapping to source via sourcemap #557

Closed
wants to merge 2 commits into from

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Oct 17, 2015

  • update script enables test coverage remapping to original (es6) source
  • minor update to document, code

This PR introduces remap-istanbul module allows to remap test coverage into original source code instead of transpiled results. (istanbul side discussion is ongoing at gotwarlost/istanbul#212) Due to current build processes, this PR does not resolves remapping issue fully though.

"build_cjs": "rm -rf dist/cjs && babel dist/es6 --out-dir dist/cjs --modules common --sourceMaps --loose all && node lib/copy_dts.js",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --target ES6 -d",
"build_cjs": "rm -rf dist/cjs && babel dist/es6 --out-dir dist/cjs --modules common --source-maps --loose all && node lib/copy_dts.js",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found cjs / es6 modules didn't have sourcemap until now..

@kwonoj
Copy link
Member Author

kwonoj commented Oct 17, 2015

It is expected to see coverage number is decreased with this PR, now coverage is completely recalculated with ES6 output due to remapping. When it comes to original typescript source, I could observe coverage is around ~85%.

@benlesh
Copy link
Member

benlesh commented Oct 17, 2015

This looks great so far. Unsure when I'll get a chance to merge this though. Might be a few days.

@kwonoj
Copy link
Member Author

kwonoj commented Oct 17, 2015

Take your time, PR'll be there when you're back :) If I could find solutions of converting sourcemaps, I'll update PR meanwhile

@benlesh
Copy link
Member

benlesh commented Oct 17, 2015

Also we'll have to research getting coveralls to be more lax until we're out of alpha

@kwonoj
Copy link
Member Author

kwonoj commented Oct 17, 2015

@Blesh I could find this in coverall repo setting, maybe this is way to control? (Seems only repo owner can change those values)

image

@kwonoj kwonoj mentioned this pull request Oct 19, 2015
@kwonoj
Copy link
Member Author

kwonoj commented Oct 20, 2015

PR's updated including one additional commit to close #558, now cover generates multi stage sourcemap pointing to original source. As same as original commit, it is expected to see coverage goes down compare to coverage against commonjs based source codes. You may able to check coverage report at https://coveralls.io/builds/3890453

I was originally tried to suggest move into different build system other than simple npm scripts, but found out that changes will include amount of out-of-scope changes not related with this specific issue. Those can be discussed in further as long term goal, focused to resolve immediate issue first.

@benlesh
Copy link
Member

benlesh commented Oct 26, 2015

Okay, I've temporarily increased thresholds of Coveralls to allow this to merge without breaking Travis. We'll see if it works.

@benlesh
Copy link
Member

benlesh commented Oct 26, 2015

@kwonoj so I pulled down this PR, rebased on master, removed node_modules, reinstalled via npm, and ran npm run build_cover and it runs fine right to the end, and I get an error when it calls:

node lib/stage_sourcemap.js && remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped.json && remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped.lcov -t lcovonly && remap-istanbul -i coverage/coverage.json -o coverage/coverage-remapped -t html

Error:

Error: Cannot find module 'jsonfile'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/blesh/GitHub/blesh/RxJS/lib/stage_sourcemap.js:3:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

I'll look into it, but not for too long, I have a LOT of PRs to catch up on. :)

@kwonoj
Copy link
Member Author

kwonoj commented Oct 26, 2015

Seems I mistakenly miss one of dependencies. I'll try to resolve on my side and update PR.

@benlesh
Copy link
Member

benlesh commented Oct 26, 2015

@kwonoj great! Notify me when you've got it. (Both here and Twitter today, because my GH inbox is dead from last week).

- update script enables test coverage remapping to original (es6) source
- minor update to document, code
@@ -20,4 +20,4 @@ script:
- npm run build_cover

after_script:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- cat ./coverage/coverage-remapped.lcov | ./node_modules/coveralls/bin/coveralls.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis doesn't seem to be running the check now... this line is suspect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm looking those part now. On my forked branch this works, failed here, continuing investigation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems that remap-istanbul isn't writing a coverage-remapped.lcov file at all.

@kwonoj
Copy link
Member Author

kwonoj commented Oct 26, 2015

I will push some dummy commits to analyze logs, will flatten them once issue is resolved. Will notify you @Blesh separately once it's done.

@kwonoj
Copy link
Member Author

kwonoj commented Oct 26, 2015

OK, travis & coveralls both happy. Reason of failures was jsonfile module has unexpected regression on latest 2.2.3 version, pinned down into 2.2.2 as known good. Dummy commits are flattened.

@benlesh
Copy link
Member

benlesh commented Oct 26, 2015

merged with 69aa51d ... thanks for all of that @kwonoj! That was a tricky bit of work you did there.

@benlesh benlesh closed this Oct 26, 2015
@kwonoj kwonoj deleted the chore-sourcemap branch October 26, 2015 20:52
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants