Skip to content

Commit

Permalink
Run all tests and lint in Travis build
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
owickstrom committed Mar 21, 2016
1 parent 4c746cf commit b0a5043
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 7 additions & 3 deletions regression-test/run-regression-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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=$?

Expand Down

0 comments on commit b0a5043

Please sign in to comment.