diff --git a/.travis.yml b/.travis.yml index cd04032..175b072 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,4 +58,5 @@ - libevent-dev script: + - deactivate # deactivate host compiler - ./travis-ci.sh diff --git a/source/dub/compilers/buildsettings.d b/source/dub/compilers/buildsettings.d index 16de290..3da87b1 100644 --- a/source/dub/compilers/buildsettings.d +++ b/source/dub/compilers/buildsettings.d @@ -108,8 +108,9 @@ void removeOptions(in BuildOption[] value...) { foreach (v; value) this.options &= ~v; } void removeOptions(in BuildOptions value) { this.options &= ~value; } +private: // Adds vals to arr without adding duplicates. - private void add(ref string[] arr, in string[] vals, bool no_duplicates = true) + static void add(ref string[] arr, in string[] vals, bool no_duplicates = true) { if (!no_duplicates) { arr ~= vals; @@ -127,7 +128,16 @@ } } - private void prepend(ref string[] arr, in string[] vals, bool no_duplicates = true) + unittest + { + auto ary = ["-dip1000", "-vgc"]; + BuildSettings.add(ary, ["-dip1000", "-vgc"]); + assert(ary == ["-dip1000", "-vgc"]); + BuildSettings.add(ary, ["-dip1001", "-vgc"], false); + assert(ary == ["-dip1000", "-vgc", "-dip1001", "-vgc"]); + } + + static void prepend(ref string[] arr, in string[] vals, bool no_duplicates = true) { if (!no_duplicates) { arr = vals ~ arr; @@ -145,8 +155,17 @@ } } + unittest + { + auto ary = ["-dip1000", "-vgc"]; + BuildSettings.prepend(ary, ["-dip1000", "-vgc"]); + assert(ary == ["-dip1000", "-vgc"]); + BuildSettings.prepend(ary, ["-dip1001", "-vgc"], false); + assert(ary == ["-dip1001", "-vgc", "-dip1000", "-vgc"]); + } + // add string import files (avoids file name duplicates in addition to path duplicates) - private void addSI(ref string[] arr, in string[] vals) + static void addSI(ref string[] arr, in string[] vals) { bool[string] existing; foreach (v; arr) existing[Path(v).head.toString()] = true; @@ -159,7 +178,16 @@ } } - private void removePaths(ref string[] arr, in string[] vals) + unittest + { + auto ary = ["path/foo.txt"]; + BuildSettings.addSI(ary, ["path2/foo2.txt"]); + assert(ary == ["path/foo.txt", "path2/foo2.txt"]); + BuildSettings.addSI(ary, ["path2/foo.txt"]); // no duplicate basenames + assert(ary == ["path/foo.txt", "path2/foo2.txt"]); + } + + static void removePaths(ref string[] arr, in string[] vals) { bool matches(string s) { @@ -171,7 +199,18 @@ arr = arr.filter!(s => !matches(s))().array(); } - private void remove(ref string[] arr, in string[] vals) + unittest + { + auto ary = ["path1", "root/path1", "root/path2", "root2/path1"]; + BuildSettings.removePaths(ary, ["path1"]); + assert(ary == ["root/path1", "root/path2", "root2/path1"]); + BuildSettings.removePaths(ary, ["*/path1"]); + assert(ary == ["root/path2"]); + BuildSettings.removePaths(ary, ["foo", "bar", "root/path2"]); + assert(ary == []); + } + + static void remove(ref string[] arr, in string[] vals) { bool matches(string s) { @@ -182,6 +221,21 @@ } arr = arr.filter!(s => !matches(s))().array(); } + + unittest + { + import std.string : join; + + auto ary = ["path1", "root/path1", "root/path2", "root2/path1"]; + BuildSettings.remove(ary, ["path1"]); + assert(ary == ["root/path1", "root/path2", "root2/path1"]); + BuildSettings.remove(ary, ["root/path*"]); + assert(ary == ["root/path1", "root/path2", "root2/path1"]); + BuildSettings.removePaths(ary, ["foo", "root/path2", "bar", "root2/path1"]); + assert(ary == ["root/path1"]); + BuildSettings.remove(ary, ["root/path1", "foo"]); + assert(ary == []); + } } enum BuildSetting { diff --git a/test/ddox.sh b/test/ddox.sh index 44f836e..9675ed8 100755 --- a/test/ddox.sh +++ b/test/ddox.sh @@ -2,6 +2,12 @@ . $(dirname "${BASH_SOURCE[0]}")/common.sh +# gdc 4.8.5 not working with ddox due to missing +# std.experimental.allocator.mallocator for libdparse +if [ ${DC} = gdc ]; then + exit 0 +fi + (cd $CURR_DIR/ddox/default && $DUB build -b ddox) grep -qF ddox_project $CURR_DIR/ddox/default/docs/index.html diff --git a/travis-ci.sh b/travis-ci.sh index 8cf47b3..9046bf3 100755 --- a/travis-ci.sh +++ b/travis-ci.sh @@ -2,6 +2,8 @@ set -v -e -o pipefail +source ~/dlang/*/activate # activate host compiler + if [ -z "$FRONTEND" -o "$FRONTEND" \> 2.067.z ]; then vibe_ver=$(jq -r '.versions | .["vibe-d"]' < dub.selections.json) dub fetch vibe-d --version=$vibe_ver # get optional dependency @@ -12,10 +14,21 @@ # library-nonet fails to build with coverage (Issue 13742) dub test --compiler=${DC} -b unittest-cov ./build.sh -cov + + # run tests with different compilers + DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh + deactivate + git clean -dxf -- test + source $(~/dlang/install.sh ldc --activate) + DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh + deactivate + git clean -dxf -- test + source $(~/dlang/install.sh gdc --activate) + DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh else ./build.sh + DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh fi -DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh if [ "$COVERAGE" = true ]; then wget https://codecov.io/bash -O codecov.sh