Skip to content

Commit

Permalink
Merge pull request #369 from frangio/parallelize-travis
Browse files Browse the repository at this point in the history
Make Travis run tests and coverage in parallel
  • Loading branch information
frangio authored Aug 19, 2017
2 parents 52efe24 + e82fa4e commit 1626c00
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 44 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ node_js:
- "6"
cache:
yarn: true
env:
-
- SOLIDITY_COVERAGE=true
matrix:
fast_finish: true
allow_failures:
- env: SOLIDITY_COVERAGE=true
script:
- yarn test
after_script:
- yarn run coveralls
38 changes: 2 additions & 36 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

# Executes cleanup function at script exit.
trap cleanup EXIT

cleanup() {
# Kill the testrpc instance that we started (if we started one).
if [ -n "$testrpc_pid" ]; then
kill -9 $testrpc_pid
fi
}

testrpc_running() {
nc -z localhost 8555
}

if testrpc_running; then
echo "Using existing testrpc-sc instance"
else
echo "Starting testrpc-sc to generate coverage"
# We define 10 accounts with balance 1M ether, needed for high-value tests.
./node_modules/ethereumjs-testrpc-sc/build/cli.node.js --gasLimit 0xfffffffffff --port 8555 \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" \
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" \
> /dev/null &
testrpc_pid=$!
fi

SOLIDITY_COVERAGE=true ./node_modules/.bin/solidity-coverage
SOLIDITY_COVERAGE=true scripts/test.sh
4 changes: 0 additions & 4 deletions scripts/coveralls.sh

This file was deleted.

29 changes: 27 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

# Exit script as soon as a command fails.
set -o errexit

# Executes cleanup function at script exit.
trap cleanup EXIT

Expand All @@ -10,8 +13,22 @@ cleanup() {
fi
}

if [ "$SOLIDITY_COVERAGE" = true ]; then
testrpc_port=8555
else
testrpc_port=8545
fi

testrpc_running() {
nc -z localhost 8545
nc -z localhost "$testrpc_port"
}

testrpc() {
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$testrpc_port" "$@"
else
node_modules/.bin/testrpc "$@"
fi
}

if testrpc_running; then
Expand All @@ -34,4 +51,12 @@ else
testrpc_pid=$!
fi

node_modules/.bin/truffle test "$@"
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/solidity-coverage

if [ "$CONTINUOUS_INTEGRATION" = true ]; then
cat coverage/lcov.info | node_modules/.bin/coveralls
fi
else
node_modules/.bin/truffle test "$@"
fi

0 comments on commit 1626c00

Please sign in to comment.