diff --git a/.travis.yml b/.travis.yml index d4d30e9..9f144c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,47 @@ # - dmd install: - # dmd - # dub - - DMD_VER=2.064.2 + # We need: + # dub: Bootstrapping + # dmd: Latest version of the frontend + # gdc: Latest (4.9.0 / FE 2.065.0 ATM) + # ldc: Latest (0.13.0 / FE 2.064.0 ATM, no support for shared lib) + + + # Install 'old' dub to bootstrap + - OLD_DUB_VER=0.9.21 + - OLD_DUB=dub-${OLD_DUB_VER}-linux-x86_64 + - wget http://code.dlang.org/files/${OLD_DUB}.tar.gz + - sudo tar -C /usr/local/bin -zxf ${OLD_DUB}.tar.gz + + + # Install DMD (latest frontend) + - DMD_VER=2.065.0 - DMD=dmd_${DMD_VER}-0_amd64.deb - - DUB_VER=0.9.21 - - DUB=dub-${DUB_VER}-linux-x86_64 - - wget http://downloads.dlang.org/releases/2013/${DMD} + - wget http://downloads.dlang.org/releases/2014/${DMD} - sudo dpkg -i ${DMD} || true - sudo apt-get -y update - sudo apt-get -fy install - sudo dpkg -i ${DMD} - - wget http://code.dlang.org/files/${DUB}.tar.gz - - sudo tar -C /usr/local/bin -zxf ${DUB}.tar.gz + + + # Get the latest GDC + - GDC_LATEST_TAR=native_2.065_gcc4.9.0_a8ad6a6678_20140615.tar.xz + - GDC_BASE_URL='http://gdcproject.org/downloads/binaries/x86_64-linux-gnu' + - wget ${GDC_BASE_URL}/${GDC_LATEST_TAR} + - sudo tar xf ${GDC_LATEST_TAR} -C /usr/local/ + - GDC_BIN=/usr/local/x86_64-gdcproject-linux-gnu/bin/gdc + + # Get the latest LDC + - LDC_VER=0.13.0 + - LDC_URL=https://github.com/ldc-developers/ldc/releases/download/v${LDC_VER}/ldc2-${LDC_VER}-linux-x86_64.tar.gz + - wget ${LDC_URL} + - sudo tar xf ldc2-${LDC_VER}-linux-x86_64.tar.gz -C /usr/local/ + - LDC_BIN=/usr/local/ldc2-${LDC_VER}-linux-x86_64/bin/ldc2 script: - - dub test -c library-nonet - - for test in `\ls -1 test/`; do (echo "[INFO] Running test $test"; cd test/$test && dub test && dub run) || break; done + - dub test --compiler=dmd -c library-nonet + - dub test --compiler=${GDC_BIN} -c library-nonet + - dub test --compiler=${LDC_BIN} -c library-nonet + - dub build + - DUB=`pwd`/bin/dub COMPILER=dmd test/run-unittest.sh diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..adf9c15 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,13 @@ +*.a +*.lib +*.so +*.dll + +1-exec-simple/exec-simple +1-staticLib-simple/__test__library__ +2-dynLib-dep/dynlib-dep +2-sourceLib-dep/sourcelib-dep +2-staticLib-dep/staticlib-dep +custom-unittest/custom-unittest +path-subpackage-ref/test +subpackage-ref/test diff --git a/test/1-dynLib-simple/dub.json b/test/1-dynLib-simple/dub.json new file mode 100644 index 0000000..c7747c3 --- /dev/null +++ b/test/1-dynLib-simple/dub.json @@ -0,0 +1,4 @@ +{ + "name": "dynlib-simple", + "targetType": "dynamicLibrary" +} diff --git a/test/1-dynLib-simple/source/dynlib/app.d b/test/1-dynLib-simple/source/dynlib/app.d new file mode 100644 index 0000000..78fbd42 --- /dev/null +++ b/test/1-dynLib-simple/source/dynlib/app.d @@ -0,0 +1,7 @@ +module dynlib.app; +import std.stdio; + +void entry() +{ + writeln(__FUNCTION__); +} diff --git a/test/1-exec-simple/dub.json b/test/1-exec-simple/dub.json new file mode 100644 index 0000000..016c4ea --- /dev/null +++ b/test/1-exec-simple/dub.json @@ -0,0 +1,4 @@ +{ + "name": "exec-simple", + "targetType": "executable" +} diff --git a/test/1-exec-simple/source/app.d b/test/1-exec-simple/source/app.d new file mode 100644 index 0000000..dbab869 --- /dev/null +++ b/test/1-exec-simple/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln(__FUNCTION__); +} diff --git a/test/1-sourceLib-simple/.no_build b/test/1-sourceLib-simple/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/1-sourceLib-simple/.no_build diff --git a/test/1-sourceLib-simple/dub.json b/test/1-sourceLib-simple/dub.json new file mode 100644 index 0000000..0bc0c7b --- /dev/null +++ b/test/1-sourceLib-simple/dub.json @@ -0,0 +1,4 @@ +{ + "name": "sourceLib-simple", + "targetType": "sourceLibrary" +} diff --git a/test/1-sourceLib-simple/source/sourcelib/app.d b/test/1-sourceLib-simple/source/sourcelib/app.d new file mode 100644 index 0000000..87dc60e --- /dev/null +++ b/test/1-sourceLib-simple/source/sourcelib/app.d @@ -0,0 +1,7 @@ +module sourcelib.app; +import std.stdio; + +void entry() +{ + writeln(__FUNCTION__); +} diff --git a/test/1-staticLib-simple/dub.json b/test/1-staticLib-simple/dub.json new file mode 100644 index 0000000..6f01776 --- /dev/null +++ b/test/1-staticLib-simple/dub.json @@ -0,0 +1,4 @@ +{ + "name": "staticlib-simple", + "targetType": "staticLibrary" +} diff --git a/test/1-staticLib-simple/source/staticlib/app.d b/test/1-staticLib-simple/source/staticlib/app.d new file mode 100644 index 0000000..1aac61d --- /dev/null +++ b/test/1-staticLib-simple/source/staticlib/app.d @@ -0,0 +1,7 @@ +module staticlib.app; +import std.stdio; + +void entry() +{ + writeln(__FUNCTION__); +} diff --git a/test/2-dynLib-dep/dub.json b/test/2-dynLib-dep/dub.json new file mode 100644 index 0000000..393810d --- /dev/null +++ b/test/2-dynLib-dep/dub.json @@ -0,0 +1,6 @@ +{ + "name": "dynlib-dep", + "dependencies": { + "dynlib-simple": { "path": "../1-dynLib-simple/" } + } +} diff --git a/test/2-dynLib-dep/source/app.d b/test/2-dynLib-dep/source/app.d new file mode 100644 index 0000000..a316d3a --- /dev/null +++ b/test/2-dynLib-dep/source/app.d @@ -0,0 +1,7 @@ +module app; +import dynlib.app; + +void main() +{ + entry(); +} diff --git a/test/2-sourceLib-dep/dub.json b/test/2-sourceLib-dep/dub.json new file mode 100644 index 0000000..8dde9fb --- /dev/null +++ b/test/2-sourceLib-dep/dub.json @@ -0,0 +1,7 @@ +{ + "name": "sourcelib-dep", + "description": "Testing sourceLibrary dependency.", + "dependencies": { + "sourcelib-simple": { "path": "../1-sourceLib-simple/" } + } +} diff --git a/test/2-sourceLib-dep/source/app.d b/test/2-sourceLib-dep/source/app.d new file mode 100644 index 0000000..8dcae3f --- /dev/null +++ b/test/2-sourceLib-dep/source/app.d @@ -0,0 +1,7 @@ +module app; +import sourcelib.app; + +void main() +{ + entry(); +} diff --git a/test/2-staticLib-dep/dub.json b/test/2-staticLib-dep/dub.json new file mode 100644 index 0000000..754f84f --- /dev/null +++ b/test/2-staticLib-dep/dub.json @@ -0,0 +1,7 @@ +{ + "name": "staticlib-dep", + "description": "Testing staticLibrary dependency.", + "dependencies": { + "staticlib-simple": { "path": "../1-staticLib-simple/" } + } +} diff --git a/test/2-staticLib-dep/source/app.d b/test/2-staticLib-dep/source/app.d new file mode 100644 index 0000000..36aa99b --- /dev/null +++ b/test/2-staticLib-dep/source/app.d @@ -0,0 +1,7 @@ +module app; +import staticlib.app; + +void main() +{ + entry(); +} diff --git a/test/run-unittest.sh b/test/run-unittest.sh new file mode 100755 index 0000000..0581901 --- /dev/null +++ b/test/run-unittest.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +function die() { + echo -e 1>&2 "\033[0;31m"$@"\033[0m" + exit 1 +} + +function log() { + echo -e "\033[0;33m[INFO] "$@"\033[0m" +} + +if [ -z ${DUB} ]; then + die 'Error: Variable $DUB must be defined to run the tests.' +fi + +if [ -z ${COMPILER} ]; then + log '$COMPILER not defined, assuming dmd...' + COMPILER=dmd +fi + +CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) + +for pack in $(ls -d $CURR_DIR/*/); do + # First we build the packages + if [ ! -e $pack/.no_build ]; then # For sourceLibrary + if [ -e $pack/.fail_build ]; then + log "Building $pack, expected failure..." + $DUB build --force --root=$pack --compiler=$COMPILER 2>/dev/null && die "Error: Failure expected, but build passed." + else + log "Building $pack..." + $DUB build --force --root=$pack --compiler=$COMPILER || die "Build failure." + fi + fi + + # We run the ones that are supposed to be runned + if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_run ]; then + log "Running $pack..." + $DUB run --force --root=$pack --compiler=$COMPILER || die "Run failure." + fi + + # Finally, the unittest part + if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_test ]; then + log "Testing $pack..." + $DUB test --force --root=$pack --compiler=$COMPILER || die "Test failure." + fi + +done