From b0a50433840672a2182ebe4b69a9e497d5e05093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Wickstr=C3=B6m?= Date: Sat, 19 Mar 2016 09:05:05 +0100 Subject: [PATCH] Run all tests and lint in Travis build * Export cabal bin dir to PATH * Install hlint in travis * Fallback to using dist dir oden if cli is not built * Install happy and alex on OSX travis build --- .travis.yml | 5 ++++- Makefile | 11 +++++++++++ regression-test/run-regression-tests.sh | 10 +++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7ff2bd..f4078a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,22 +17,25 @@ before_install: - export PATH=/opt/ghc/7.10.1/bin:/opt/cabal/1.22/bin:$PATH - export PATH=/opt/alex/3.1.4/bin:$PATH - export PATH=/opt/happy/1.19.5/bin:$PATH +- export PATH=$HOME/.cabal/bin:$PATH install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ghc cabal-install pcre; fi - travis_retry cabal update - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cabal install alex; cabal install happy; fi +- cabal install hlint - cabal sandbox init - cabal install --enable-tests --only-dependencies script: - cabal configure --enable-tests -- cabal test - export VERSION=branch-$TRAVIS_BRANCH-job-$TRAVIS_JOB_NUMBER - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export VERSION=pull-request-$TRAVIS_PULL_REQUEST-job-$TRAVIS_JOB_NUMBER; fi - if [[ "$TRAVIS_TAG" != "" ]]; then export VERSION=$TRAVIS_TAG; fi - make dist +- make ci-test cache: apt: true directories: diff --git a/Makefile b/Makefile index 1efb408..e8609fe 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,17 @@ $(TMP): test: cabal exec runhaskell -- -isrc -itest test/Spec.hs $(TEST_FLAG) +.PHONY: regression-test +regression-test: + regression-test/run-regression-tests.sh validate + +.PHONY: lint +lint: + hlint src cli + +.PHONY: ci-test +ci-test: test regression-test lint + .PHONY: watch-test watch-test: $(NODEMON) $(NODEMON) --watch src --watch test -e hs --exec 'make test || exit 1' diff --git a/regression-test/run-regression-tests.sh b/regression-test/run-regression-tests.sh index 57ad2a2..15c6a71 100755 --- a/regression-test/run-regression-tests.sh +++ b/regression-test/run-regression-tests.sh @@ -8,7 +8,11 @@ if [ -z $command ]; then fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + ODEN=$DIR/../dist/build/cli/cli +if ! `which $ODEN` ; then + ODEN=$DIR/../dist/oden/bin/oden +fi cd $DIR tests=$(find src -name *.oden) @@ -22,8 +26,8 @@ print_err() { } for test in $tests; do - tmp_oden_path=$(mktemp -d -t oden) - tmp_go_path=$(mktemp -d -t oden_out) + tmp_oden_path=$(mktemp -d -t oden.XXXXXXXXXX) + tmp_go_path=$(mktemp -d -t oden_out.XXXXXXXXXX) tmp_src_file=$tmp_oden_path/$test mkdir -p $(dirname $tmp_src_file) @@ -32,7 +36,7 @@ for test in $tests; do oden_out=$($ODEN -p$tmp_oden_path -o$tmp_go_path build 2>&1) oden_return=$? - go_out_file=$()$(mktemp -t go_out) + go_out_file=$()$(mktemp -t go_out.XXXXXXXXXX) GOPATH=$tmp_go_path go run $(find $tmp_go_path -name *.go) > $go_out_file 2>&1 go_return=$?