Skip to content

Commit

Permalink
chore: Modify coverage scripts to reflect decaff changes
Browse files Browse the repository at this point in the history
  • Loading branch information
michalholasek committed Jan 23, 2018
1 parent 74509b1 commit 24725e0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/lib

# Common for .gitignore and .npmignore
src-cov/
lcov/
.DS_Store
coverage/
site/
cov.*
.vagrant
Expand Down
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ before_install:
# Travis CI has only shallow clone of the repository. We need to get the 'master' branch
# so 'conventional-changelog-lint' could compare commits and lint them: marionebl/conventional-changelog-lint#7
- "git remote set-branches origin master && git fetch && git checkout master && git checkout -"
- "npm -g install npm@4"
- "npm -g install npm@5"
install: "npm install --no-optional"
jobs:
include:
- stage: "code/docs/commits quality checks"
node_js: "6"
node_js: "8"
script: "npm run lint"
- stage: "tests"
- stage: "tests & code coverage"
node_js: "6"
script: "npm run test"
script: "npm run test:coverage && npm run coveralls"
- node_js: "8"
script: "npm run test:coverage && npm run coveralls"
- stage: "semantic release"
node_js: "8"
script: " npm run semantic-release || true"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"eslint-plugin-import": "^2.7.0",
"express": "^4.15.2",
"hercule": "^4.0.1",
"jscoverage": "^0.6.0",
"istanbul": "0.4.5",
"lcov-result-merger": "^1.2.0",
"mocha": "^3.0.0",
"mocha-lcov-reporter": "^1.3.0",
Expand Down
42 changes: 13 additions & 29 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
#!/bin/sh
# Runs tests and collects code coverage to ./cov.info file
# Runs tests and collects code coverage to ./coverage/lcov.info file

set -e # aborts as soon as anything returns non-zero exit status
set -e # Aborts as soon as anything returns non-zero exit status


PROJECT_DIR=$(pwd -P)

COVERAGE_FILE="$PROJECT_DIR"/cov.info
COVERAGE_DIR="$PROJECT_DIR"/lcov
INSTRUMENTED_CODE_DIR="$PROJECT_DIR"/src-cov
COVERAGE_FILE="$PROJECT_DIR"/coverage/lcov.info
COVERAGE_DIR="$PROJECT_DIR"/coverage
BIN_DIR="$PROJECT_DIR"/node_modules/.bin


# Cleanup & preparation
rm -rf "$INSTRUMENTED_CODE_DIR" "$COVERAGE_DIR" "$COVERAGE_FILE"
mkdir "$INSTRUMENTED_CODE_DIR" "$COVERAGE_DIR"
rm -rf "$COVERAGE_DIR" "$COVERAGE_FILE"
mkdir "$COVERAGE_DIR"
chmod +x "$PROJECT_DIR"/bin/dredd

# Testing & coverage
istanbul cover ./node_modules/.bin/_mocha -- \
"test/**/*-test.coffee" \
--compilers=coffee:coffee-script/register \
--recursive

# Creating directory with instrumented JS code
"$BIN_DIR"/coffeeCoverage \
--exclude=node_modules,.git,test,scripts \
--path=relative \
"$PROJECT_DIR" "$INSTRUMENTED_CODE_DIR" 1>&2

cp "$PROJECT_DIR"/package.json "$INSTRUMENTED_CODE_DIR"

cp -r "$PROJECT_DIR"/bin "$INSTRUMENTED_CODE_DIR"/bin
chmod +x "$INSTRUMENTED_CODE_DIR"/bin/*

cp -r "$PROJECT_DIR"/scripts "$INSTRUMENTED_CODE_DIR"/scripts
cp -r "$PROJECT_DIR"/docs "$INSTRUMENTED_CODE_DIR"/docs
cp -r "$PROJECT_DIR"/test "$INSTRUMENTED_CODE_DIR"/test

mkdir -p "$INSTRUMENTED_CODE_DIR"/node_modules/.bin
ln -s "$BIN_DIR"/* "$INSTRUMENTED_CODE_DIR"/node_modules/.bin


# Testing
export COVERAGE_DIR
cd "$INSTRUMENTED_CODE_DIR" && npm test
cd ..


Expand All @@ -48,4 +32,4 @@ echo "Coverage saved as '$COVERAGE_FILE'"


# Output & cleanup
rm -rf "$INSTRUMENTED_CODE_DIR" "$COVERAGE_DIR"
rm -rf "$COVERAGE_DIR"
8 changes: 4 additions & 4 deletions scripts/coveralls.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
# Picks up the ./cov.info file and sends the coverage to coveralls.io
# Picks up the ./coverage/lcov.info file and sends the coverage to coveralls.io


# Input validation
if [ ! -f ./cov.info ]; then
(>&2 echo "Coverage file 'cov.info' was not found.")
if [ ! -f ./coverage/lcov.info ]; then
(>&2 echo "Coverage file 'lcov.info' was not found.")
(>&2 echo "First run the test suite as 'npm run test:coverage'.")
exit 1
fi


# Coveralls
cat ./cov.info | ./node_modules/.bin/coveralls
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls

0 comments on commit 24725e0

Please sign in to comment.