From c79c6d76d819d9e8916a6551b7bddb1e24ab522b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Mon, 14 Aug 2017 02:53:27 -0300 Subject: [PATCH 1/2] unify test and coverage scripts --- scripts/coverage.sh | 38 ++------------------------------------ scripts/test.sh | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 70fd3192a17..8a50f77b4f1 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -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 diff --git a/scripts/test.sh b/scripts/test.sh index f55589db1b8..dff991a0b20 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -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 @@ -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 @@ -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 From e82fa4eae03d476b9bf5e98479c1268ceabad1df Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Mon, 14 Aug 2017 02:55:17 -0300 Subject: [PATCH 2/2] parallelize tests and coverage in travis --- .travis.yml | 9 +++++++-- scripts/coveralls.sh | 4 ---- 2 files changed, 7 insertions(+), 6 deletions(-) delete mode 100755 scripts/coveralls.sh diff --git a/.travis.yml b/.travis.yml index af96e468c94..e4af9c60f0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/scripts/coveralls.sh b/scripts/coveralls.sh deleted file mode 100755 index 264fe95213a..00000000000 --- a/scripts/coveralls.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/bash - -yarn run coverage && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js -