diff --git a/test/4-describe-data-1-list.sh b/test/4-describe-data-1-list.sh index a1d9120..aefbf78 100755 --- a/test/4-describe-data-1-list.sh +++ b/test/4-describe-data-1-list.sh @@ -12,7 +12,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=$COMPILER --data-list \ +if ! $DUB describe --compiler=$DC --data-list \ '--data= target-type , target-path , target-name ' \ '--data= working-directory ' \ --data=main-source-file \ @@ -59,8 +59,8 @@ echo "--another-lflag" >> "$expected_file" echo >> "$expected_file" # --data=libs -echo "crypto" >> "$expected_file" -echo "curl" >> "$expected_file" +echo "somelib" >> "$expected_file" +echo "anotherlib" >> "$expected_file" echo >> "$expected_file" # --data=linker-files echo "$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a" >> "$expected_file" diff --git a/test/4-describe-data-2-dmd.sh b/test/4-describe-data-2-dmd.sh index 53964f9..3f30769 100755 --- a/test/4-describe-data-2-dmd.sh +++ b/test/4-describe-data-2-dmd.sh @@ -2,9 +2,9 @@ set -e -o pipefail -if ! dmd --help >/dev/null; then - echo Skipping DMD-centric test on configuration that lacks DMD. - exit +if [ "${DC}" != "dmd" ]; then + echo Skipping DMD-centric test on configuration that lacks DMD. + exit fi cd "$CURR_DIR"/describe-project @@ -17,7 +17,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=dmd \ +if ! $DUB describe --compiler=${DC} \ --data=main-source-file \ --data=dflags,lflags \ --data=libs,linker-files \ @@ -43,8 +43,8 @@ echo -n "-L--some-lflag " >> "$expected_file" echo -n "-L--another-lflag " >> "$expected_file" # --data=libs -echo -n "-L-lcrypto " >> "$expected_file" -echo -n "-L-lcurl " >> "$expected_file" +echo -n "-L-lsomelib " >> "$expected_file" +echo -n "-L-lanotherlib " >> "$expected_file" # --data=linker-files echo -n "'$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a' " >> "$expected_file" echo -n "'$CURR_DIR/describe-project/some.a' " >> "$expected_file" diff --git a/test/4-describe-data-3-zero-delim.sh b/test/4-describe-data-3-zero-delim.sh index 8df3e20..2d6738b 100755 --- a/test/4-describe-data-3-zero-delim.sh +++ b/test/4-describe-data-3-zero-delim.sh @@ -15,7 +15,7 @@ trap cleanup EXIT # Test list-style project data -if ! $DUB describe --compiler=$COMPILER --data-list \ +if ! $DUB describe --compiler=$DC --data-list \ --data=target-type \ --data=target-path \ --data=target-name \ @@ -43,7 +43,7 @@ die 'Printing list-style project data failed!' fi -if ! $DUB describe --compiler=$COMPILER --data-0 --data-list \ +if ! $DUB describe --compiler=$DC --data-0 --data-list \ --data=target-type \ --data=target-path \ --data=target-name \ @@ -76,12 +76,12 @@ fi # Test --import-paths -if ! $DUB describe --compiler=$COMPILER --import-paths \ +if ! $DUB describe --compiler=$DC --import-paths \ > "$temp_file_normal"; then die 'Printing --import-paths failed!' fi -if ! $DUB describe --compiler=$COMPILER --data-0 --import-paths \ +if ! $DUB describe --compiler=$DC --data-0 --import-paths \ | xargs -0 printf "%s\n" > "$temp_file_zero_delim"; then die 'Printing null-delimited --import-paths failed!' fi @@ -91,18 +91,18 @@ fi # DMD-only beyond this point -if ! dmd --help >/dev/null; then - echo Skipping DMD-centric tests on configuration that lacks DMD. - exit +if [ "${DC}" != "dmd" ]; then + echo Skipping DMD-centric tests on configuration that lacks DMD. + exit fi # Test dmd-style --data=versions -if ! $DUB describe --compiler=dmd --data=versions \ +if ! $DUB describe --compiler=$DC --data=versions \ > "$temp_file_normal"; then die 'Printing dmd-style --data=versions failed!' fi -if ! $DUB describe --compiler=dmd --data-0 --data=versions \ +if ! $DUB describe --compiler=$DC --data-0 --data=versions \ | xargs -0 printf "%s " > "$temp_file_zero_delim"; then die 'Printing null-delimited dmd-style --data=versions failed!' fi @@ -112,12 +112,12 @@ fi # Test dmd-style --data=source-files -if ! $DUB describe --compiler=dmd --data=source-files \ +if ! $DUB describe --compiler=$DC --data=source-files \ > "$temp_file_normal"; then die 'Printing dmd-style --data=source-files failed!' fi -if ! $DUB describe --compiler=dmd --data-0 --data=source-files \ +if ! $DUB describe --compiler=$DC --data-0 --data=source-files \ | xargs -0 printf "'%s' " > "$temp_file_zero_delim"; then die 'Printing null-delimited dmd-style --data=source-files failed!' fi diff --git a/test/4-describe-import-paths.sh b/test/4-describe-import-paths.sh index 71822b4..ba03205 100755 --- a/test/4-describe-import-paths.sh +++ b/test/4-describe-import-paths.sh @@ -12,7 +12,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=$COMPILER --import-paths > "$temp_file"; then +if ! $DUB describe --compiler=$DC --import-paths > "$temp_file"; then die 'Printing import paths failed!' fi diff --git a/test/4-describe-json.sh b/test/4-describe-json.sh index cdd2a2b..5641595 100755 --- a/test/4-describe-json.sh +++ b/test/4-describe-json.sh @@ -12,7 +12,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=$COMPILER > "$temp_file"; then +if ! $DUB describe --compiler=$DC > "$temp_file"; then die 'Printing describe JSON failed!' fi diff --git a/test/4-describe-string-import-paths.sh b/test/4-describe-string-import-paths.sh index 772c8c4..aa64979 100755 --- a/test/4-describe-string-import-paths.sh +++ b/test/4-describe-string-import-paths.sh @@ -12,7 +12,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=$COMPILER --string-import-paths > "$temp_file"; then +if ! $DUB describe --compiler=$DC --string-import-paths > "$temp_file"; then die 'Printing string import paths failed!' fi diff --git a/test/describe-dependency-1/dub.json b/test/describe-dependency-1/dub.json index 61f2d9e..89e12ca 100644 --- a/test/describe-dependency-1/dub.json +++ b/test/describe-dependency-1/dub.json @@ -10,7 +10,7 @@ "sourceFiles-windows": ["dep.lib"], "dflags": ["--another-dflag"], "lflags": ["--another-lflag"], - "libs": ["curl"], + "libs": ["anotherlib"], "copyFiles": ["data/*"], "versions": ["anotherVerIdent"], "debugVersions": ["anotherDebugVerIdent"], diff --git a/test/describe-project/dub.json b/test/describe-project/dub.json index 40cdd29..c52d085 100644 --- a/test/describe-project/dub.json +++ b/test/describe-project/dub.json @@ -11,7 +11,7 @@ "sourceFiles-windows": ["./some.lib"], "dflags": ["--some-dflag"], "lflags": ["--some-lflag"], - "libs": ["crypto"], + "libs": ["somelib"], "copyFiles": ["data/dummy.dat"], "versions": ["someVerIdent"], "debugVersions": ["someDebugVerIdent"], diff --git a/test/issue346-redundant-flags.sh b/test/issue346-redundant-flags.sh index acb1f54..3ee9ade 100755 --- a/test/issue346-redundant-flags.sh +++ b/test/issue346-redundant-flags.sh @@ -1,4 +1,4 @@ #!/bin/sh cd ${CURR_DIR}/issue346-redundant-flags -${DUB} build --bare --force --compiler=${COMPILER} -a x86 main | grep -e "-m32 -m32" 2>&1 && exit 1 || exit 0 +${DUB} build --bare --force --compiler=${DC} -a x86 main | grep -e "-m32 -m32" 2>&1 && exit 1 || exit 0 diff --git a/test/issue564-invalid-upgrade-dependency.sh b/test/issue564-invalid-upgrade-dependency.sh index 3de9aa1..a1af6bd 100755 --- a/test/issue564-invalid-upgrade-dependency.sh +++ b/test/issue564-invalid-upgrade-dependency.sh @@ -4,4 +4,4 @@ rm -rf a-1.0.0/.dub rm -rf a-1.1.0/.dub rm -rf main/.dub -${DUB} build --bare --compiler=${COMPILER} main || exit 1 +${DUB} build --bare --compiler=${DC} main || exit 1 diff --git a/test/issue586-subpack-dep.sh b/test/issue586-subpack-dep.sh index efd42ce..fe0ad5f 100755 --- a/test/issue586-subpack-dep.sh +++ b/test/issue586-subpack-dep.sh @@ -4,5 +4,5 @@ rm -rf a/.dub rm -rf a/b/.dub rm -rf main/.dub -${DUB} build --bare --compiler=${COMPILER} main || exit 1 -${DUB} run --bare --compiler=${COMPILER} main || exit 1 +${DUB} build --bare --compiler=${DC} main || exit 1 +${DUB} run --bare --compiler=${DC} main || exit 1 diff --git a/test/issue613-dynlib-pic.sh b/test/issue613-dynlib-pic.sh index 57d1c82..d7e90b7 100755 --- a/test/issue613-dynlib-pic.sh +++ b/test/issue613-dynlib-pic.sh @@ -2,9 +2,9 @@ cd ${CURR_DIR}/issue613-dynlib-pic rm -rf .dub -if [ "${COMPILER}" = "dmd" ]; then - ${DUB} build --compiler=${COMPILER} || exit 1 +if [ "${DC}" = "dmd" ]; then + ${DUB} build --compiler=${DC} || exit 1 else - echo "Skipping shared library test for ${COMPILER}..." + echo "Skipping shared library test for ${DC}..." fi diff --git a/test/issue616-describe-vs-generate-commands.sh b/test/issue616-describe-vs-generate-commands.sh index eefe296..8f85c09 100755 --- a/test/issue616-describe-vs-generate-commands.sh +++ b/test/issue616-describe-vs-generate-commands.sh @@ -11,7 +11,7 @@ trap cleanup EXIT -if ! $DUB describe --compiler=$COMPILER --data-list --data=target-name \ +if ! $DUB describe --compiler=$DC --data-list --data=target-name \ > "$temp_file" 2>&1; then die 'Printing project data failed!' fi diff --git a/test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh b/test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh index b678840..84468cd 100755 --- a/test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh +++ b/test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh @@ -7,4 +7,4 @@ echo preGenerateCommands: DUB_PACKAGES_USED=$DUB_PACKAGES_USED >&2 export dub_issue616=true -$DUB describe --compiler=$COMPILER --data-list --data=import-paths >&2 +$DUB describe --compiler=$DC --data-list --data=import-paths >&2 diff --git a/test/run-unittest.sh b/test/run-unittest.sh index ccd0831..f092fd9 100755 --- a/test/run-unittest.sh +++ b/test/run-unittest.sh @@ -1,25 +1,29 @@ #!/bin/bash -function die() { - echo -e 1>&2 "\033[0;31m"$@"\033[0m" - exit 1 -} - -export -f die - function log() { echo -e "\033[0;33m[INFO] "$@"\033[0m" } +function logError() { + echo -e 1>&2 "\033[0;31m"$@"\033[0m" + any_errors=1 +} + +function die() { + logError "$@" + exit 1 +} + export -f log +export -f die 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 +if [ -z ${DC} ]; then + log '$DC not defined, assuming dmd...' + DC=dmd fi CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) @@ -27,7 +31,7 @@ for script in $(ls $CURR_DIR/*.sh); do if [ "$script" = "$(readlink -f ${BASH_SOURCE[0]})" ]; then continue; fi log "Running $script..." - DUB=$DUB COMPILER=$COMPILER CURR_DIR="$CURR_DIR" $script || die "Script failure." + DUB=$DUB DC=$DC CURR_DIR="$CURR_DIR" $script || logError "Script failure." done for pack in $(ls -d $CURR_DIR/*/); do @@ -35,23 +39,24 @@ 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." + $DUB build --force --root=$pack --compiler=$DC 2>/dev/null && logError "Error: Failure expected, but build passed." else log "Building $pack..." - $DUB build --force --root=$pack --compiler=$COMPILER || die "Build failure." + $DUB build --force --root=$pack --compiler=$DC || logError "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." + $DUB run --force --root=$pack --compiler=$DC || logError "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." + $DUB test --force --root=$pack --compiler=$DC || logError "Test failure." fi - done + +exit $any_errors diff --git a/travis-ci.sh b/travis-ci.sh index 3f750fb..6fcff5e 100755 --- a/travis-ci.sh +++ b/travis-ci.sh @@ -14,7 +14,7 @@ else ./build.sh fi -DUB=`pwd`/bin/dub COMPILER=${DC} test/run-unittest.sh +DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh if [ "$COVERAGE" = true ]; then dub fetch doveralls --version=~master