Last active
August 29, 2015 14:13
-
-
Save DinisCruz/a6cb047a496461f6d7f6 to your computer and use it in GitHub Desktop.
scripts to create auto code coverage in Atom Editor
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
#!/bin/bash | |
if [ ! -f ./node_modules/mocha-lcov-reporter/package.json ]; then | |
echo 'Installing coverage dependencies' | |
npm install jscover | |
npm install coffee-coverage | |
npm install mocha-lcov-reporter | |
fi | |
#set -o errexit # Exit on error | |
echo 'Removing cache files' | |
#rm -R .tmCache | |
echo 'Creating instrumented node files' | |
echo ' for CoffeeScript' | |
coffeeCoverage --path relative ./src ./coverage/src | |
coffeeCoverage --path relative ./test ./coverage/test | |
echo 'Running with mocha-lcov-reporter and saving it to coverage' | |
mocha -R mocha-lcov-reporter coverage/test --recursive > ./coverage/lcov.info |
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
## using watcher | |
require 'fluentnode' | |
fs = require 'fs' | |
project_Folder = atom.project.path | |
coverage_file = project_Folder.path_Combine('coverage/lcov.info') | |
watcher_Src =null | |
watcher_Test =null | |
watcher_Cov =null | |
create_Coverage = -> | |
spawn = require('child_process').spawn | |
proc = spawn( 'bin/lcov-code-coverage.sh',['node_modules'],{cwd:project_Folder} ) | |
proc.stdout.on 'data' , (data) -> console.log('stdout: ' + data) | |
proc.stderr.on 'data' , (data) -> console.log('stderr: ' + data) | |
proc.on 'close', (code) -> console.log(' process exited with code ' + code); | |
set_Code_Watcher = -> | |
watch_Folder = (folder)-> | |
fs.watch folder, ()-> | |
console.log "Folder watch on #{folder} triggered, creating code coverage" | |
create_Coverage(); | |
watcher_Src = watch_Folder(project_Folder.path_Combine('src')) | |
watcher_Test = watch_Folder(project_Folder.path_Combine('test')) | |
set_Watchers = (watch_Code)-> | |
if (set_Code_Watcher) | |
set_Code_Watcher() | |
watcher_Cov = fs.watchFile coverage_file, ()-> | |
console.log "lcov file was changed, reloading data" | |
atom.workspaceView.trigger('lcov-info:toggle') | |
"done" | |
close_Watchers = -> | |
watcher_Cov.stop() | |
watcher_Src.stop() | |
watcher_Test.stop() | |
set_Watchers(false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment