diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ad9b767e8b..b2ea60486d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,6 +74,9 @@ jobs: - { dc: ldc-master, do_test: true } # Test on ARM64 - { os: macOS-14, dc: ldc-latest, do_test: true } + # ice when building tests: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119817 + - { os: ubuntu-24.04, dc: gdc-13, do_test: false } + - { os: ubuntu-24.04, dc: gdc-14, do_test: true } exclude: # Error with those versions: # ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in [.../dub.o]; address=0x0 points to section(2) with no content in '[...]/osx/lib/libphobos2.a[3177](config_a68_4c3.o)' @@ -96,14 +99,29 @@ jobs: - name: '[Linux] Install dependencies' if: runner.os == 'Linux' run: | - sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev netcat + sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev netcat-openbsd # Compiler to test with - name: Prepare compiler - uses: dlang-community/setup-dlang@v1 + uses: dlang-community/setup-dlang@v2 with: compiler: ${{ matrix.dc }} + - name: Set environment variables + shell: bash + run: | + for name in DC DMD; do + var=${!name} + var=$(basename "${var}") + var=${var%.exe} # strip the extension + export "${name}=${var}" + tee -a ${GITHUB_ENV} <<<"${name}=${var}" + done + + if [[ ${{ matrix.dc }} == gdc-13 ]]; then + tee -a ${GITHUB_ENV} <<<"DFLAGS=-Wno-error" + fi + # Checkout the repository - name: Checkout uses: actions/checkout@v4 @@ -115,7 +133,6 @@ jobs: run: | dub build --compiler=${{ env.DC }} if [[ ${{ matrix.do_test }} == 'true' ]]; then - dub run --compiler=${{ env.DC }} --single test/issue2051_running_unittests_from_dub_single_file_packages_fails.d ./scripts/ci/ci.sh fi @@ -127,19 +144,7 @@ jobs: dub build --compiler=${{ env.DC }} if [[ ${{ matrix.do_test }} == 'true' ]]; then dub test --compiler=${{ env.DC }} - dub run --compiler=${{ env.DC }} --single test/issue2051_running_unittests_from_dub_single_file_packages_fails.d - dub --single test/run-unittest.d - - # FIXME: DMD fails a few tests on Windows; remove them for now - if [[ '${{ matrix.dc }}' = dmd* ]]; then - # DLL support is lacking - rm -rf test/{1-dynLib-simple,2-dynLib-dep,2-dynLib-with-staticLib-dep} - # Unicode in paths too - rm -rf test/issue130-unicode-СНА* - # ImportC probably requires set-up MSVC environment variables - rm -rf test/use-c-sources - fi - test/run-unittest.sh + dub run --root test/run_unittest -- -v fi shell: bash diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 1ca99412e5..286d06afbf 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -7,7 +7,7 @@ ARG DCBIN # Build dub (and install tests dependencies in the process) WORKDIR /root/build/ -RUN apk add --no-cache bash build-base curl curl-dev dtools dub git grep rsync $DCPKG +RUN apk add --no-cache bash build-base curl curl-dev dtools dub git grep rsync lld $DCPKG ADD . /root/build/ RUN dub test --compiler=$DCBIN && dub build --compiler=$DCBIN @@ -20,4 +20,4 @@ ENV DC=$DCBIN # Finally, just run the test-suite WORKDIR /root/build/test/ -ENTRYPOINT [ "/root/build/test/run-unittest.sh" ] +ENTRYPOINT [ "/root/build/bin/dub", "--root", "run_unittest", "--" ] diff --git a/scripts/ci/ci.sh b/scripts/ci/ci.sh index bccfd811e7..bc77d70514 100755 --- a/scripts/ci/ci.sh +++ b/scripts/ci/ci.sh @@ -2,21 +2,36 @@ set -v -e -o pipefail -vibe_ver=$(jq -r '.versions | .["vibe-d"]' < dub.selections.json) -dub fetch vibe-d@$vibe_ver # get optional dependency -dub test --compiler=${DC} -c library-nonet +testLibraryNonet=1 +if [[ ${DC} =~ gdc|gdmd ]]; then + # ICE with gdc-14 + testLibraryNonet= +fi + +if [[ ${testLibraryNonet} ]]; then + vibe_ver=$(jq -r '.versions | .["vibe-d"]' < dub.selections.json) + dub fetch vibe-d@$vibe_ver # get optional dependency + dub test --compiler=${DC} -c library-nonet --build=unittest +fi export DMD="$(command -v $DMD)" -./build.d -preview=in -w -g -debug +"${DMD}" -run build.d -preview=in -w -g -debug + +if [[ ${testLibraryNoNet} ]]; then + dub test --compiler=${DC} -b unittest-cov +fi if [ "$COVERAGE" = true ]; then # library-nonet fails to build with coverage (Issue 13742) - dub test --compiler=${DC} -b unittest-cov - ./build.d -cov + "${DMD}" -run build.d -cov else - dub test --compiler=${DC} -b unittest-cov - ./build.d + "${DMD}" -run build.d fi -DUB=`pwd`/bin/dub DC=${DC} dub --single ./test/run-unittest.d -DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh + +# force the creation of the coverage dir +bin/dub --version + +# let the runner add the needed flags, in the case of gdmd +unset DFLAGS +DC=${DMD} dub run --root test/run_unittest -- -v diff --git a/test/.gitignore b/test/.gitignore index cfe8d612fc..85976cab59 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -2,68 +2,15 @@ *.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 -subpackage-common-with-sourcefile-globbing/mypackage* -version-spec/**/CMakeLists.txt -version-spec/**/foo.cmake -version-spec/**/foo - -/test_registry -/issue_2051_running_unittests_from_dub_single_file_packages_fails /run-unittest - test.log -custom-source-main-bug487/custom-source-main-bug487 -3-copyFiles/bin/ -ignore-hidden-1/ignore-hidden-1 -ignore-hidden-2/ignore-hidden-2 -expected-import-path-output -expected-string-import-path-output -expected-describe-data-1-list-output -expected-describe-data-2-dmd-output -expected-issue616-output -describe-project/dummy.dat -describe-project/dummy-dep1.dat -*/main/main -*/*test-library -*/*test-application -*/exec-simple -issue1474/ext/fortytwo.d -issue2452/ext/fortytwo.d - -cov-ctfe/test -issue1003-check-empty-ld-flags/issue1003-empty-ld-flags -issue1053-extra-files-visuald/LICENSE.txt -issue1053-extra-files-visuald/README.txt -issue1053-extra-files-visuald/extra_files.sln -issue1117-extra-dependency-files/test -issue1396-pre-post-run-commands/test -issue1396-pre-post-run-commands/test.txt -issue1477-subpackage-visuald-paths/library_subpackage_a.sln -issue1477-subpackage-visuald-paths/sub/subpackage_a/subpackage_a.sln -issue1504-envvar-in-path/test -issue1773-lint/report.json -issue2085-target-none-visuald/root.sln -issue2086-copyfiles-subpackage-targetpath/sub/sub -issue2086-copyfiles-subpackage-targetpath/sub/to_be_deployed.txt -issue2262-exact-cached-version-match/testproj -issue361-optional-deps/cmp.tmp -issue838-custom-cache-paths/test -issue97-targettype-none/a/issue97-targettype-none_a -issue97-targettype-none/b/issue97-targettype-none_b -issue990-download-optional-selected/b -output-1504.txt -version-filters-diamond/version-filters-diamond -version-filters-none/version-filters-none -version-filters-source-dep/version-filters-source-dep -version-filters/version-filters -version-spec/newfoo/foo-test-application -version-spec/oldfoo/foo-test-application +*/* +!*/dub.json +!*/dub.sdl +!*/package.json +!*/run.d +!*/run.sh +!*/source +!*/.gitignore +!*/test.config +!extra/* diff --git a/test/0-init-fail-json.script.d b/test/0-init-fail-json.script.d deleted file mode 100644 index d62938536b..0000000000 --- a/test/0-init-fail-json.script.d +++ /dev/null @@ -1,36 +0,0 @@ -/+ dub.sdl: - name "0-init-fail-json" - dependency "common" path="./common" - +/ - -module _0_init_fail_json; - -import std.file : exists, remove; -import std.path : buildPath; -import std.process : environment, spawnProcess, wait; - -import common; - -int main() -{ - enum packname = "0-init-fail-pack"; - enum deps = "logger PACKAGE_DONT_EXIST"; // would be very unlucky if it does exist... - - auto dub = environment.get("DUB"); - if (!dub.length) - die(`Environment variable "DUB" must be defined to run the tests.`); - - //** if $$DUB init -n $packname $deps -f json 2>/dev/null; then - if (!spawnProcess([dub, "init", "-n", packname, deps, "-f", "json"]).wait) - die("Init with unknown non-existing dependency expected to fail"); - - //** if [ -e $packname/dub.json ]; then # package is there, it should have failed - const filepath = buildPath(packname, "dub.json"); - if (filepath.exists) - { - remove(packname); - die(filepath ~ " was not created"); - } - - return 0; -} diff --git a/test/0-init-fail-json/dub.sdl b/test/0-init-fail-json/dub.sdl new file mode 100644 index 0000000000..66dff5fd4a --- /dev/null +++ b/test/0-init-fail-json/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-fail-json" +dependency "common" path="../common" diff --git a/test/0-init-fail-json/source/app.d b/test/0-init-fail-json/source/app.d new file mode 100644 index 0000000000..3879a868aa --- /dev/null +++ b/test/0-init-fail-json/source/app.d @@ -0,0 +1,21 @@ +import std.file : exists, remove; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "0-init-fail-pack"; + immutable deps = ["logger", "PACKAGE_DONT_EXIST"]; // would be very unlucky if it does exist... + + if (!spawnProcess([dub, "init", "-n", packname] ~ deps ~ [ "-f", "json"]).wait) + die("Init with unknown non-existing dependency expected to fail"); + + const filepath = buildPath(packname, "dub.json"); + if (filepath.exists) + { + remove(packname); + die(filepath, " was not created"); + } +} diff --git a/test/0-init-fail.sh b/test/0-init-fail.sh deleted file mode 100755 index c440a57818..0000000000 --- a/test/0-init-fail.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-fail-pack" -deps="logger PACKAGE_DONT_EXIST" # would be very unlucky if it does exist... - -if $DUB init -n $packname $deps 2>/dev/null; then - die $LINENO 'Init with unknown non-existing dependency expected to fail' -fi - -function cleanup { - rm -rf $packname -} - -if [ -e $packname/dub.sdl ]; then # package is there, it should have failed - cleanup - die $LINENO "$packname/dub.sdl was not created" -fi diff --git a/test/0-init-fail/dub.sdl b/test/0-init-fail/dub.sdl new file mode 100644 index 0000000000..465201c13c --- /dev/null +++ b/test/0-init-fail/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-fail" +dependency "common" path="../common" diff --git a/test/0-init-fail/source/app.d b/test/0-init-fail/source/app.d new file mode 100644 index 0000000000..dfe8c7a1a3 --- /dev/null +++ b/test/0-init-fail/source/app.d @@ -0,0 +1,21 @@ +import std.file : exists, remove; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "0-init-fail-pack"; + immutable deps = ["logger", "PACKAGE_DONT_EXIST"]; // would be very unlucky if it does exist... + + if (!spawnProcess([dub, "init", "-n", packname] ~ deps).wait) + die("Init with unknown non-existing dependency expected to fail"); + + const filepath = buildPath(packname, "dub.sdl"); + if (filepath.exists) + { + remove(packname); + die(filepath ~ " was not created"); + } +} diff --git a/test/0-init-interactive.sh b/test/0-init-interactive.sh deleted file mode 100755 index b46b5cd33e..0000000000 --- a/test/0-init-interactive.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-interactive" - -function cleanup { - rm -rf $packname -} - -function runTest { - local inp=$1 - local comp=$2 - local dub_ext=${comp##*.} - local outp=$(echo -e $inp | $DUB init $packname) - if [ ! -e $packname/dub.$dub_ext ]; then # it failed - cleanup - die $LINENO "No dub.$dub_ext file has been generated for test $comp with input '$inp'. Output: $outp" - fi - if ! diff $packname/dub.$dub_ext "$CURR_DIR"/$comp; then - cleanup - die $LINENO "Contents of generated dub.$dub_ext does not match $comp" - fi - cleanup -} - -# sdl package format -runTest '1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl -# select package format out of bounds -runTest '3\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl -# select package format not numeric, but in list -runTest 'sdl\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl -# selected value not numeric and not in list -runTest 'sdlf\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl -# default name -runTest '1\n\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.default_name.dub.sdl -# json package format -runTest '2\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.json -# default package format -runTest '\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.json -# select license -runTest '1\ntest\ndesc\nauthor\n6\n3\ncopy\n\n' 0-init-interactive.license_gpl3.dub.sdl -# select license (with description) -runTest '1\ntest\ndesc\nauthor\n9\n3\ncopy\n\n' 0-init-interactive.license_mpl2.dub.sdl -# select license out of bounds -runTest '1\ntest\ndesc\nauthor\n21\n6\n3\ncopy\n\n' 0-init-interactive.license_gpl3.dub.sdl -# default license -runTest '1\ntest\ndesc\nauthor\n\ncopy\n\n' 0-init-interactive.license_proprietary.dub.sdl diff --git a/test/0-init-interactive/.gitignore b/test/0-init-interactive/.gitignore new file mode 100644 index 0000000000..4f2f404e33 --- /dev/null +++ b/test/0-init-interactive/.gitignore @@ -0,0 +1,2 @@ +!/exp +!/exp/* \ No newline at end of file diff --git a/test/0-init-interactive/dub.sdl b/test/0-init-interactive/dub.sdl new file mode 100644 index 0000000000..ccd2866ae8 --- /dev/null +++ b/test/0-init-interactive/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-interactive" +dependency "common" path="../common" diff --git a/test/0-init-interactive.default_name.dub.sdl b/test/0-init-interactive/exp/default_name.dub.sdl similarity index 72% rename from test/0-init-interactive.default_name.dub.sdl rename to test/0-init-interactive/exp/default_name.dub.sdl index 7b8f8ba0fd..34f3c864f1 100644 --- a/test/0-init-interactive.default_name.dub.sdl +++ b/test/0-init-interactive/exp/default_name.dub.sdl @@ -1,4 +1,4 @@ -name "0-init-interactive" +name "new-package" description "desc" authors "author" copyright "copy" diff --git a/test/0-init-interactive.dub.json b/test/0-init-interactive/exp/dub.json similarity index 100% rename from test/0-init-interactive.dub.json rename to test/0-init-interactive/exp/dub.json diff --git a/test/0-init-interactive.dub.sdl b/test/0-init-interactive/exp/dub.sdl similarity index 100% rename from test/0-init-interactive.dub.sdl rename to test/0-init-interactive/exp/dub.sdl diff --git a/test/0-init-interactive.license_gpl3.dub.sdl b/test/0-init-interactive/exp/license_gpl3.dub.sdl similarity index 100% rename from test/0-init-interactive.license_gpl3.dub.sdl rename to test/0-init-interactive/exp/license_gpl3.dub.sdl diff --git a/test/0-init-interactive.license_mpl2.dub.sdl b/test/0-init-interactive/exp/license_mpl2.dub.sdl similarity index 100% rename from test/0-init-interactive.license_mpl2.dub.sdl rename to test/0-init-interactive/exp/license_mpl2.dub.sdl diff --git a/test/0-init-interactive.license_proprietary.dub.sdl b/test/0-init-interactive/exp/license_proprietary.dub.sdl similarity index 100% rename from test/0-init-interactive.license_proprietary.dub.sdl rename to test/0-init-interactive/exp/license_proprietary.dub.sdl diff --git a/test/0-init-interactive/source/app.d b/test/0-init-interactive/source/app.d new file mode 100644 index 0000000000..740e2b9f4b --- /dev/null +++ b/test/0-init-interactive/source/app.d @@ -0,0 +1,63 @@ +import common; + +void main() +{ + runTest("1\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.sdl"); + runTest("3\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.sdl"); + runTest("sdl\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.sdl"); + runTest("sdlf\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.sdl"); + runTest("1\n\ndesc\nauthor\ngpl\ncopy\n\n", "default_name.dub.sdl"); + runTest("2\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.json"); + runTest("\ntest\ndesc\nauthor\ngpl\ncopy\n\n", "dub.json"); + runTest("1\ntest\ndesc\nauthor\n6\n3\ncopy\n\n", "license_gpl3.dub.sdl"); + runTest("1\ntest\ndesc\nauthor\n9\n3\ncopy\n\n", "license_mpl2.dub.sdl"); + runTest("1\ntest\ndesc\nauthor\n21\n6\n3\ncopy\n\n", "license_gpl3.dub.sdl"); + runTest("1\ntest\ndesc\nauthor\n\ncopy\n\n", "license_proprietary.dub.sdl"); +} + +void runTest(string input, string expectedPath) { + import std.array; + import std.algorithm; + import std.range; + import std.process; + import std.file; + import std.path; + import std.string; + + immutable test = baseName(expectedPath); + immutable dub_ext = expectedPath[expectedPath.lastIndexOf(".") + 1 .. $]; + + const dir = "new-package"; + + if (dir.exists) rmdirRecurse(dir); + auto pipes = pipeProcess([dub, "init", dir], + Redirect.stdin | Redirect.stdout | Redirect.stderrToStdout); + scope(success) rmdirRecurse(dir); + + immutable escapedInput = format("%(%s%)", [input]); + pipes.stdin.writeln(input); + pipes.stdin.close(); + if (pipes.pid.wait != 0) { + die("Dub failed to generate init file for " ~ escapedInput); + } + + scope(failure) { + logError("You can find the generated files in ", absolutePath(dir)); + } + + if (!exists(dir ~ "/dub." ~ dub_ext)) { + logError("No dub." ~ dub_ext ~ " file has been generated for test " ~ test); + logError("with input " ~ escapedInput ~ ". Output:"); + foreach (line; pipes.stdout.byLine) + logError(line); + die("No dub." ~ dub_ext ~ " file has been found"); + } + + immutable got = readText(dir ~ "/dub." ~ dub_ext).replace("\r\n", "\n"); + immutable expPath = "exp/" ~ expectedPath; + immutable exp = expPath.readText.replace("\r\n", "\n"); + + if (got != exp) { + die("Contents of generated dub." ~ dub_ext ~ " does not match " ~ expPath); + } +} diff --git a/test/0-init-multi-json.sh b/test/0-init-multi-json.sh deleted file mode 100755 index 239c419cb3..0000000000 --- a/test/0-init-multi-json.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-multi-pack" -deps="openssl logger" -type="vibe.d" - -$DUB init -n $packname $deps --type=$type -f json - -function cleanup { - rm -rf $packname -} - -if [ ! -e $packname/dub.json ]; then - die $LINENO '$packname/dub.json not created' -else # check if resulting dub.json has all dependencies in tow - deps="$deps vibe-d"; - IFS=" " read -a arr <<< "$deps" - for ele in "${arr[@]}" - do - if [ `grep -c "$ele" $packname/dub.json` -ne 1 ]; then #something went wrong - cleanup - die $LINENO "$ele not in $packname/dub.json" - fi - done - cleanup -fi diff --git a/test/0-init-multi-json/dub.sdl b/test/0-init-multi-json/dub.sdl new file mode 100644 index 0000000000..6de210c108 --- /dev/null +++ b/test/0-init-multi-json/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-multi-json" +dependency "common" path="../common" diff --git a/test/0-init-multi-json/source/app.d b/test/0-init-multi-json/source/app.d new file mode 100644 index 0000000000..8d1a828f7b --- /dev/null +++ b/test/0-init-multi-json/source/app.d @@ -0,0 +1,27 @@ +import std.file : exists, readText, rmdirRecurse; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "test-package"; + immutable deps = ["openssl", "logger"]; + enum type = "vibe.d"; + + if(packname.exists) rmdirRecurse(packname); + spawnProcess([dub, "init", "-n", packname ] ~ deps ~ [ "--type", type, "-f", "json"]).wait; + + const filepath = buildPath(packname, "dub.json"); + if (!filepath.exists) + die("dub.json not created"); + + immutable got = readText(filepath); + foreach (dep; deps ~ type) { + import std.algorithm; + if (got.count(dep) != 1) { + die(dep, " not in " ~ filepath); + } + } +} diff --git a/test/0-init-multi.sh b/test/0-init-multi.sh deleted file mode 100755 index 8432b969c1..0000000000 --- a/test/0-init-multi.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-multi-pack" -deps="openssl logger" -type="vibe.d" - -$DUB init -n $packname $deps --type=$type --format sdl - -function cleanup { - rm -rf $packname -} - -if [ ! -e $packname/dub.sdl ]; then - cleanup - die $LINENO 'No dub.sdl file has been generated.' -else # check if resulting dub.sdl has all dependencies in tow - deps="$deps vibe-d"; - IFS=" " read -a arr <<< "$deps" - for ele in "${arr[@]}" - do - if [ `grep -c "$ele" $packname/dub.sdl` -ne 1 ]; then #something went wrong - cleanup - die $LINENO "$ele not in $packname/dub.sdl" - fi - done - cleanup -fi diff --git a/test/0-init-multi/dub.sdl b/test/0-init-multi/dub.sdl new file mode 100644 index 0000000000..57395d2e1e --- /dev/null +++ b/test/0-init-multi/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-multi" +dependency "common" path="../common" diff --git a/test/0-init-multi/source/app.d b/test/0-init-multi/source/app.d new file mode 100644 index 0000000000..faf4a4206e --- /dev/null +++ b/test/0-init-multi/source/app.d @@ -0,0 +1,27 @@ +import std.file : exists, readText, rmdirRecurse; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "test-package"; + immutable deps = ["openssl", "logger"]; + enum type = "vibe.d"; + + if(packname.exists) rmdirRecurse(packname); + spawnProcess([dub, "init", "-n", packname ] ~ deps ~ [ "--type", type, "-f", "sdl"]).wait; + + const filepath = buildPath(packname, "dub.sdl"); + if (!filepath.exists) + die("dub.sdl not created"); + + immutable got = readText(filepath); + foreach (dep; deps ~ type) { + import std.algorithm; + if (got.count(dep) != 1) { + die(dep, " not in " ~ filepath); + } + } +} diff --git a/test/0-init-simple-json.sh b/test/0-init-simple-json.sh deleted file mode 100755 index 2a7ec8a0cc..0000000000 --- a/test/0-init-simple-json.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-simple-pack" - -$DUB init -n $packname -f json - -function cleanup { - rm -rf $packname -} - -if [ ! -e $packname/dub.json ]; then - cleanup - die $LINENO 'No dub.json file has been generated.' -fi -cleanup diff --git a/test/0-init-simple-json/dub.sdl b/test/0-init-simple-json/dub.sdl new file mode 100644 index 0000000000..205bf62051 --- /dev/null +++ b/test/0-init-simple-json/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-simple-json" +dependency "common" path="../common" diff --git a/test/0-init-simple-json/source/app.d b/test/0-init-simple-json/source/app.d new file mode 100644 index 0000000000..de0d500d2e --- /dev/null +++ b/test/0-init-simple-json/source/app.d @@ -0,0 +1,17 @@ +import std.file : exists, readText, rmdirRecurse; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "test-package"; + + if(packname.exists) rmdirRecurse(packname); + spawnProcess([dub, "init", "-n", packname, "-f", "json"]).wait; + + const filepath = buildPath(packname, "dub.json"); + if (!filepath.exists) + die("dub.json not created"); +} diff --git a/test/0-init-simple.sh b/test/0-init-simple.sh deleted file mode 100755 index f4fee2eba6..0000000000 --- a/test/0-init-simple.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-simple-pack" - -$DUB init -n $packname --format sdl - -function cleanup { - rm -rf $packname -} - -if [ ! -e $packname/dub.sdl ]; then # it failed - cleanup - die $LINENO 'No dub.sdl file has been generated.' -fi -cleanup diff --git a/test/0-init-simple/dub.sdl b/test/0-init-simple/dub.sdl new file mode 100644 index 0000000000..b353c56ece --- /dev/null +++ b/test/0-init-simple/dub.sdl @@ -0,0 +1,2 @@ +name "0-init-simple" +dependency "common" path="../common" diff --git a/test/0-init-simple/source/app.d b/test/0-init-simple/source/app.d new file mode 100644 index 0000000000..61fc953fcc --- /dev/null +++ b/test/0-init-simple/source/app.d @@ -0,0 +1,17 @@ +import std.file : exists, readText, rmdirRecurse; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +void main() +{ + enum packname = "test-package"; + + if(packname.exists) rmdirRecurse(packname); + spawnProcess([dub, "init", "-n", packname, "--format", "sdl"]).wait; + + const filepath = buildPath(packname, "dub.sdl"); + if (!filepath.exists) + die("dub.sdl not created"); +} diff --git a/test/1-dynLib-simple/test.config b/test/1-dynLib-simple/test.config new file mode 100644 index 0000000000..32efffa32d --- /dev/null +++ b/test/1-dynLib-simple/test.config @@ -0,0 +1 @@ +dub_command = build diff --git a/test/1-exec-simple-package-json/package.json b/test/1-exec-simple-package-json/package.json index 016c4eab5d..df62fb877a 100644 --- a/test/1-exec-simple-package-json/package.json +++ b/test/1-exec-simple-package-json/package.json @@ -1,4 +1,4 @@ { - "name": "exec-simple", + "name": "exec-simple-package-json", "targetType": "executable" } diff --git a/test/1-staticLib-simple/test.config b/test/1-staticLib-simple/test.config new file mode 100644 index 0000000000..5c654c4cdf --- /dev/null +++ b/test/1-staticLib-simple/test.config @@ -0,0 +1 @@ +dub_command = [build, test] diff --git a/test/2-dynLib-dep/.no_build_windows b/test/2-dynLib-dep/.no_build_windows deleted file mode 100644 index d55a120400..0000000000 --- a/test/2-dynLib-dep/.no_build_windows +++ /dev/null @@ -1 +0,0 @@ -# workaround for Issue 23177 diff --git a/test/2-dynLib-dep/test.config b/test/2-dynLib-dep/test.config new file mode 100644 index 0000000000..f82959d6c3 --- /dev/null +++ b/test/2-dynLib-dep/test.config @@ -0,0 +1,4 @@ +os = [linux, osx] +# https://github.com/dlang/dmd/issues/20120 +# transfered from https://issues.dlang.org/show_bug.cgi?id=23177 +locks = [ 1-dynLib-simple ] diff --git a/test/2-dynLib-with-staticLib-dep/test.config b/test/2-dynLib-with-staticLib-dep/test.config new file mode 100644 index 0000000000..f068942f9e --- /dev/null +++ b/test/2-dynLib-with-staticLib-dep/test.config @@ -0,0 +1,2 @@ +locks = [ 1-staticLib-simple ] +dub_command = build \ No newline at end of file diff --git a/test/2-sourceLib-dep/dub.json b/test/2-sourceLib-dep/dub.json index 8dde9fb3ec..626ac600fa 100644 --- a/test/2-sourceLib-dep/dub.json +++ b/test/2-sourceLib-dep/dub.json @@ -2,6 +2,6 @@ "name": "sourcelib-dep", "description": "Testing sourceLibrary dependency.", "dependencies": { - "sourcelib-simple": { "path": "../1-sourceLib-simple/" } + "sourcelib-simple": { "path": "../extra/1-sourceLib-simple/" } } } diff --git a/test/2-staticLib-dep/test.config b/test/2-staticLib-dep/test.config new file mode 100644 index 0000000000..d1819fad0a --- /dev/null +++ b/test/2-staticLib-dep/test.config @@ -0,0 +1 @@ +locks = [ 1-staticLib-simple ] \ No newline at end of file diff --git a/test/3-copyFiles/.gitignore b/test/3-copyFiles/.gitignore new file mode 100644 index 0000000000..c210b953f0 --- /dev/null +++ b/test/3-copyFiles/.gitignore @@ -0,0 +1,2 @@ +!/data +!/data/** diff --git a/test/4-describe-data-1-list.sh b/test/4-describe-data-1-list.sh deleted file mode 100755 index 934243e11b..0000000000 --- a/test/4-describe-data-1-list.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/describe-project - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC --filter-versions \ - --data-list \ - '--data= target-type , target-path , target-name ' \ - '--data= working-directory ' \ - --data=main-source-file \ - '--data=dflags,lflags' \ - '--data=libs, linker-files' \ - '--data=source-files, copy-files' \ - '--data=versions, debug-versions' \ - --data=import-paths \ - --data=string-import-paths \ - --data=import-files \ - --data=string-import-files \ - --data=pre-generate-commands \ - --data=post-generate-commands \ - --data=pre-build-commands \ - --data=post-build-commands \ - '--data=requirements, options' \ - --data=default-config \ - --data=configs \ - --data=default-build \ - --data=builds \ - > "$temp_file"; then - die $LINENO 'Printing project data failed!' -fi - -# Create the expected output path file to compare against. -expected_file="$CURR_DIR/expected-describe-data-1-list-output" -# --data=target-type -echo "executable" > "$expected_file" -echo >> "$expected_file" -# --data=target-path -echo "$CURR_DIR/describe-project/" >> "$expected_file" -echo >> "$expected_file" -# --data=target-name -echo "describe-project" >> "$expected_file" -echo >> "$expected_file" -# --data=working-directory -echo "$CURR_DIR/describe-project/" >> "$expected_file" -echo >> "$expected_file" -# --data=main-source-file -echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=dflags -echo "--some-dflag" >> "$expected_file" -echo "--another-dflag" >> "$expected_file" -echo >> "$expected_file" -# --data=lflags -echo "--some-lflag" >> "$expected_file" -echo "--another-lflag" >> "$expected_file" -echo >> "$expected_file" -# --data=libs -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" -echo "$CURR_DIR/describe-project/some.a" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/dep.a" >> "$expected_file" -echo >> "$expected_file" -# --data=source-files -echo "$CURR_DIR/describe-project/src/dummy.d" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/source/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=copy-files -echo "$CURR_DIR/describe-project/data/dummy.dat" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/data/*" >> "$expected_file" -echo >> "$expected_file" -# --data=versions -echo "someVerIdent" >> "$expected_file" -echo "anotherVerIdent" >> "$expected_file" -echo "Have_describe_dependency_3" >> "$expected_file" -echo >> "$expected_file" -# --data=debug-versions -echo "someDebugVerIdent" >> "$expected_file" -echo "anotherDebugVerIdent" >> "$expected_file" -echo >> "$expected_file" -# --data=import-paths -echo "$CURR_DIR/describe-project/src/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-1/source/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-2/some-path/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-3/dep3-source/" >> "$expected_file" -echo >> "$expected_file" -# --data=string-import-paths -echo "$CURR_DIR/describe-project/views/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/" >> "$expected_file" -echo "$CURR_DIR/describe-dependency-3/dep3-string-import-path/" >> "$expected_file" -echo >> "$expected_file" -# --data=import-files -echo "$CURR_DIR/describe-dependency-2/some-path/dummy.d" >> "$expected_file" -echo >> "$expected_file" -# --data=string-import-files -echo "$CURR_DIR/describe-project/views/dummy.d" >> "$expected_file" -#echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/dummy.d" >> "$expected_file" # This is missing from result, is that a bug? -echo >> "$expected_file" -# --data=pre-generate-commands -echo "./do-preGenerateCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-preGenerateCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=post-generate-commands -echo "./do-postGenerateCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-postGenerateCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=pre-build-commands -echo "./do-preBuildCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-preBuildCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=post-build-commands -echo "./do-postBuildCommands.sh" >> "$expected_file" -echo "../describe-dependency-1/dependency-postBuildCommands.sh" >> "$expected_file" -echo >> "$expected_file" -# --data=requirements -echo "allowWarnings" >> "$expected_file" -echo "disallowInlining" >> "$expected_file" -echo "requireContracts" >> "$expected_file" -echo >> "$expected_file" -# --data=options -echo "debugMode" >> "$expected_file" -# releaseMode is not included, even though it's specified, because the requireContracts requirement drops it -echo "debugInfo" >> "$expected_file" -echo "stackStomping" >> "$expected_file" -echo "warnings" >> "$expected_file" -echo >> "$expected_file" -# --data=default-config -echo "my-project-config" >> "$expected_file" -echo >> "$expected_file" -# --data=configs -echo "my-project-config" >> "$expected_file" -echo >> "$expected_file" -# --data=default-build -echo "debug" >> "$expected_file" -echo >> "$expected_file" -# --data=builds -echo "debug" >> "$expected_file" -echo "plain" >> "$expected_file" -echo "release" >> "$expected_file" -echo "release-debug" >> "$expected_file" -echo "release-nobounds" >> "$expected_file" -echo "unittest" >> "$expected_file" -echo "profile" >> "$expected_file" -echo "profile-gc" >> "$expected_file" -echo "docs" >> "$expected_file" -echo "ddox" >> "$expected_file" -echo "cov" >> "$expected_file" -echo "cov-ctfe" >> "$expected_file" -echo "unittest-cov" >> "$expected_file" -echo "unittest-cov-ctfe" >> "$expected_file" -echo "syntax" >> "$expected_file" -# echo >> "$expected_file" - -if ! diff "$expected_file" "$temp_file"; then - echo "Result:" - cat "$temp_file" - die $LINENO 'The project data did not match the expected output!' -fi - diff --git a/test/4-describe-data-1-list/dub.json b/test/4-describe-data-1-list/dub.json new file mode 100644 index 0000000000..fa3421e584 --- /dev/null +++ b/test/4-describe-data-1-list/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-data-1", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-data-1-list/source/app.d b/test/4-describe-data-1-list/source/app.d new file mode 100644 index 0000000000..30f6a293f5 --- /dev/null +++ b/test/4-describe-data-1-list/source/app.d @@ -0,0 +1,193 @@ +import std.stdio; +import std.process; +import std.path; + +import common; +import describe_test_utils; + +void main() +{ + environment.remove("DFLAGS"); + + immutable cmd = [ + dub, + "describe", + "--filter-versions", + "--data-list", + "--data= target-type , target-path , target-name", + "--data= working-directory ", + "--data=main-source-file", + "--data=dflags,lflags", + "--data=libs, linker-files", + "--data=source-files, copy-files", + "--data=versions, debug-versions", + "--data=import-paths", + "--data=string-import-paths", + "--data=import-files", + "--data=string-import-files", + "--data=pre-generate-commands", + "--data=post-generate-commands", + "--data=pre-build-commands", + "--data=post-build-commands", + "--data=requirements, options", + "--data=default-config", + "--data=configs", + "--data=default-build", + "--data=builds", + ]; + + import std.file; + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto pipes = pipeProcess(cmd, Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (pipes.pid.wait() != 0) + die("Printing project data failed"); + + auto expected = [ + // --data=target-type + "executable", "", + // --data=target-path + describeDir.myBuildPath("project", ""), "", + // --data=target-name + "describe-project", "", + // --data=working-directory + describeDir.myBuildPath("project", ""), "", + // --data=main-source-file + describeDir.myBuildPath("project", "src", "dummy.d"), "", + // --data=dflags + "--some-dflag", + "--another-dflag", + "", + // --data=lflags + "--some-lflag", + "--another-lflag", + "", + // --data=libs + "somelib", + "anotherlib", + "", + // --data=linker-files + describeDir.myBuildPath("dependency-3", "describe-dependency-3".libName), + describeDir.myBuildPath("project", "some" ~ libSuffix), + describeDir.myBuildPath("dependency-1", "dep" ~ libSuffix), + "", + // --data=source-files + describeDir.myBuildPath("project", "src", "dummy.d"), + describeDir.myBuildPath("dependency-1", "source", "dummy.d"), + "", + // --data=copy-files + describeDir.myBuildPath("project", "data", "dummy.dat"), + describeDir.myBuildPath("dependency-1", "data", "*"), + "", + // --data=versions + "someVerIdent", + "anotherVerIdent", + "Have_describe_dependency_3", + "", + // --data=debug-versions + "someDebugVerIdent", + "anotherDebugVerIdent", + "", + // --data=import-paths + describeDir.myBuildPath("project", "src", ""), + describeDir.myBuildPath("dependency-1", "source", ""), + describeDir.myBuildPath("dependency-2", "some-path", ""), + describeDir.myBuildPath("dependency-3", "dep3-source", ""), + "", + // --data=string-import-paths + describeDir.myBuildPath("project", "views", ""), + describeDir.myBuildPath("dependency-2", "some-extra-string-import-path", ""), + describeDir.myBuildPath("dependency-3", "dep3-string-import-path", ""), + "", + // --data=import-files + describeDir.myBuildPath("dependency-2", "some-path", "dummy.d"), + "", + // --data=string-import-files + describeDir.myBuildPath("project", "views", "dummy.d"), + //describeDir.myBuildPath("dependency-2", "some-extra-string-import-path", "dummy.d"), // This is missing from result, is that a bug? + "", + ]; + + version(Posix) + expected ~= [ + // --data=pre-generate-commands + "./do-preGenerateCommands.sh", + "../dependency-1/dependency-preGenerateCommands.sh", + "", + // --data=post-generate-commands + "./do-postGenerateCommands.sh", + "../dependency-1/dependency-postGenerateCommands.sh", + "", + // --data=pre-build-commands + "./do-preBuildCommands.sh", + "../dependency-1/dependency-preBuildCommands.sh", + "", + // --data=post-build-commands + "./do-postBuildCommands.sh", + "../dependency-1/dependency-postBuildCommands.sh", + "", + ]; + else + expected ~= [ + // --data=pre-generate-commands + "", + "", + // --data=post-generate-commands + "", + "", + // --data=pre-build-commands + "", + "", + // --data=post-build-commands + "", + "", + ]; + + expected ~= [ + // --data=requirements + "allowWarnings", + "disallowInlining", + "requireContracts", + "", + // --data=options + "debugMode", + // releaseMode is not included, even though it's specified, because the requireContracts requirement, + "debugInfo", + "stackStomping", + "warnings", + "", + // --data=default-config + "my-project-config", + "", + // --data=configs + "my-project-config", + "", + // --data=default-build + "debug", + "", + // --data=builds + "debug", + "plain", + "release", + "release-debug", + "release-nobounds", + "unittest", + "profile", + "profile-gc", + "docs", + "ddox", + "cov", + "cov-ctfe", + "unittest-cov", + "unittest-cov-ctfe", + "syntax", + ]; + + import std.array; + import std.algorithm; + const got = pipes.stdout.byLineCopy.map!fixWindowsCR.array; + if (equal(got, expected)) return; + + printDifference(got, expected); + die("Dub describe output differs"); +} diff --git a/test/4-describe-data-1-list/test.config b/test/4-describe-data-1-list/test.config new file mode 100644 index 0000000000..884ffbdf6e --- /dev/null +++ b/test/4-describe-data-1-list/test.config @@ -0,0 +1 @@ +locks = 4-describe diff --git a/test/4-describe-data-2-dmd.sh b/test/4-describe-data-2-dmd.sh deleted file mode 100755 index 46e25f76d3..0000000000 --- a/test/4-describe-data-2-dmd.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if [ "${DC}" != "dmd" ]; then - echo Skipping DMD-centric test on configuration that lacks DMD. - exit -fi - -cd "$CURR_DIR"/describe-project - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC --filter-versions \ - --data=main-source-file \ - --data=dflags,lflags \ - --data=libs,linker-files \ - --data=source-files \ - --data=versions \ - --data=debug-versions \ - --data=import-paths \ - --data=string-import-paths \ - --data=import-files \ - --data=options \ - > "$temp_file"; then - die $LINENO 'Printing project data failed!' -fi - -# Create the expected output path file to compare against. -expected_file="$CURR_DIR/expected-describe-data-2-dmd-output" - -# check if escaping is required -. "$CURR_DIR/4-describe-data-check-escape" - -# --data=main-source-file -echo -n "$(escaped "$CURR_DIR/describe-project/src/dummy.d") " > "$expected_file" -# --data=dflags -echo -n "--some-dflag " >> "$expected_file" -echo -n "--another-dflag " >> "$expected_file" -# --data=lflags -echo -n "-L--some-lflag " >> "$expected_file" -echo -n "-L--another-lflag " >> "$expected_file" -# --data=libs -echo -n "-L-lsomelib " >> "$expected_file" -echo -n "-L-lanotherlib " >> "$expected_file" -# --data=linker-files -echo -n "$(escaped "$CURR_DIR/describe-dependency-3/libdescribe-dependency-3.a") " >> "$expected_file" -echo -n "$(escaped "$CURR_DIR/describe-project/some.a") " >> "$expected_file" -echo -n "$(escaped "$CURR_DIR/describe-dependency-1/dep.a") " >> "$expected_file" -# --data=source-files -echo -n "$(escaped "$CURR_DIR/describe-project/src/dummy.d") " >> "$expected_file" -echo -n "$(escaped "$CURR_DIR/describe-dependency-1/source/dummy.d") " >> "$expected_file" -# --data=versions -echo -n "-version=someVerIdent " >> "$expected_file" -echo -n "-version=anotherVerIdent " >> "$expected_file" -echo -n "-version=Have_describe_dependency_3 " >> "$expected_file" -# --data=debug-versions -echo -n "-debug=someDebugVerIdent " >> "$expected_file" -echo -n "-debug=anotherDebugVerIdent " >> "$expected_file" -# --data=import-paths -echo -n "$(escaped "-I$CURR_DIR/describe-project/src/") " >> "$expected_file" -echo -n "$(escaped "-I$CURR_DIR/describe-dependency-1/source/") " >> "$expected_file" -echo -n "$(escaped "-I$CURR_DIR/describe-dependency-2/some-path/") " >> "$expected_file" -echo -n "$(escaped "-I$CURR_DIR/describe-dependency-3/dep3-source/") " >> "$expected_file" -# --data=string-import-paths -echo -n "$(escaped "-J$CURR_DIR/describe-project/views/") " >> "$expected_file" -echo -n "$(escaped "-J$CURR_DIR/describe-dependency-2/some-extra-string-import-path/") " >> "$expected_file" -echo -n "$(escaped "-J$CURR_DIR/describe-dependency-3/dep3-string-import-path/") " >> "$expected_file" -# --data=import-files -echo -n "$(escaped "$CURR_DIR/describe-dependency-2/some-path/dummy.d") " >> "$expected_file" -# --data=options -echo -n "-debug " >> "$expected_file" -# releaseMode is not included, even though it's specified, because the requireContracts requirement drops it -echo -n "-g " >> "$expected_file" -echo -n "-gx " >> "$expected_file" -echo -n "-wi" >> "$expected_file" -echo "" >> "$expected_file" - -if ! diff "$expected_file" "$temp_file"; then - die $LINENO 'The project data did not match the expected output!' -fi - diff --git a/test/4-describe-data-2-dmd/dub.json b/test/4-describe-data-2-dmd/dub.json new file mode 100644 index 0000000000..1b657b903e --- /dev/null +++ b/test/4-describe-data-2-dmd/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-data-2", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-data-2-dmd/source/app.d b/test/4-describe-data-2-dmd/source/app.d new file mode 100644 index 0000000000..16add47c96 --- /dev/null +++ b/test/4-describe-data-2-dmd/source/app.d @@ -0,0 +1,106 @@ +import std.algorithm; +import std.array; +import std.file; +import std.path; +import std.process; +import std.range; +import std.stdio; + +import common; +import describe_test_utils; + +void main() +{ + if (!environment["DC"].baseName.canFind("dmd")) skip("need dmd like compiler"); + + environment.remove("DFLAGS"); + immutable cmd = [ + dub, + "describe", + "--filter-versions", + "--data=main-source-file", + "--data=dflags,lflags", + "--data=libs,linker-files", + "--data=source-files", + "--data=versions", + "--data=debug-versions", + "--data=import-paths", + "--data=string-import-paths", + "--data=import-files", + "--data=options", + ]; + + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto pipes = pipeProcess(cmd, Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (pipes.pid.wait() != 0) + die("Printing project data failed"); + + auto expectedArray = [ + // --data=main-source-file + describeDir.myBuildPath("project", "src", "dummy.d").escape, + // --data=dflags + "--some-dflag", + "--another-dflag", + // --data=lflags + "-L--some-lflag", + "-L--another-lflag", + ]; + + version(Posix) + expectedArray ~= [ + // --data=libs + "-L-lsomelib", + "-L-lanotherlib", + ]; + else + expectedArray ~= [ + // --data=libs + "-Lsomelib.lib", + "-Lanotherlib.lib", + ]; + + expectedArray ~= [ + // --data=linker-files + describeDir.myBuildPath("dependency-3", "describe-dependency-3".libName).escape, + describeDir.myBuildPath("project", "some" ~ libSuffix).escape, + describeDir.myBuildPath("dependency-1", "dep" ~ libSuffix).escape, + // --data=source-files + describeDir.myBuildPath("project", "src", "dummy.d").escape, + describeDir.myBuildPath("dependency-1", "source", "dummy.d").escape, + // --data=versions + "-version=someVerIdent", + "-version=anotherVerIdent", + "-version=Have_describe_dependency_3", + // --data=debug-versions + "-debug=someDebugVerIdent", + "-debug=anotherDebugVerIdent", + // --data=import-paths + escape("-I" ~ describeDir.myBuildPath("project", "src", "")), + escape("-I" ~ describeDir.myBuildPath("dependency-1", "source", "")), + escape("-I" ~ describeDir.myBuildPath("dependency-2", "some-path", "")), + escape("-I" ~ describeDir.myBuildPath("dependency-3", "dep3-source", "")), + // --data=string-import-paths + escape("-J" ~ describeDir.myBuildPath("project", "views", "")), + escape("-J" ~ describeDir.myBuildPath("dependency-2", "some-extra-string-import-path", "")), + escape("-J" ~ describeDir.myBuildPath("dependency-3", "dep3-string-import-path", "")), + // --data=import-files + escape(describeDir.myBuildPath("dependency-2", "some-path", "dummy.d")), + // --data=options + "-debug", + // releaseMode is not included, even though it's specified, because the requireContracts requirement drops it + "-g", + "-gx", + "-wi", + ]; + immutable expected = expectedArray.join(" "); + + const got = pipes.stdout.byLineCopy.map!fixWindowsCR.array; + + if (equal(got, [ expected ])) return; + + copy(got, File("dub-output.txt", "w").lockingTextWriter); + std.file.write("expected-output.txt", expected); + + die("Dub output didn't match. Check dub-output.txt and expected-output.txt for details"); +} diff --git a/test/4-describe-data-2-dmd/test.config b/test/4-describe-data-2-dmd/test.config new file mode 100644 index 0000000000..884ffbdf6e --- /dev/null +++ b/test/4-describe-data-2-dmd/test.config @@ -0,0 +1 @@ +locks = 4-describe diff --git a/test/4-describe-data-3-zero-delim.sh b/test/4-describe-data-3-zero-delim.sh deleted file mode 100755 index e36aeb36ea..0000000000 --- a/test/4-describe-data-3-zero-delim.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/describe-project - -temp_file_normal=$(mktemp $(basename $0).XXXXXX) -temp_file_zero_delim=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file_normal - rm $temp_file_zero_delim -} - -trap cleanup EXIT - -# Test list-style project data -if ! $DUB describe --compiler=$DC --data-list \ - --data=target-type \ - --data=target-path \ - --data=target-name \ - --data=working-directory \ - --data=main-source-file \ - --data=dflags \ - --data=lflags \ - --data=libs \ - --data=linker-files \ - --data=source-files \ - --data=copy-files \ - --data=versions \ - --data=debug-versions \ - --data=import-paths \ - --data=string-import-paths \ - --data=import-files \ - --data=string-import-files \ - --data=pre-generate-commands \ - --data=post-generate-commands \ - --data=pre-build-commands \ - --data=post-build-commands \ - --data=requirements \ - --data=options \ - > "$temp_file_normal"; then - die $LINENO 'Printing list-style project data failed!' -fi - -if ! $DUB describe --compiler=$DC --data-0 --data-list \ - --data=target-type \ - --data=target-path \ - --data=target-name \ - --data=working-directory \ - --data=main-source-file \ - --data=dflags \ - --data=lflags \ - --data=libs \ - --data=linker-files \ - --data=source-files \ - --data=copy-files \ - --data=versions \ - --data=debug-versions \ - --data=import-paths \ - --data=string-import-paths \ - --data=import-files \ - --data=string-import-files \ - --data=pre-generate-commands \ - --data=post-generate-commands \ - --data=pre-build-commands \ - --data=post-build-commands \ - --data=requirements \ - --data=options \ - | xargs -0 printf "%s\n" > "$temp_file_zero_delim"; then - die $LINENO 'Printing null-delimited list-style project data failed!' -fi - -if ! diff -b -B "$temp_file_normal" "$temp_file_zero_delim"; then - die $LINENO 'The null-delimited list-style project data did not match the expected output!' -fi - -# Test --import-paths -if ! $DUB describe --compiler=$DC --import-paths \ - > "$temp_file_normal"; then - die $LINENO 'Printing --import-paths failed!' -fi - -if ! $DUB describe --compiler=$DC --data-0 --import-paths \ - | xargs -0 printf "%s\n" > "$temp_file_zero_delim"; then - die $LINENO 'Printing null-delimited --import-paths failed!' -fi - -if ! diff -b -B "$temp_file_normal" "$temp_file_zero_delim"; then - die $LINENO 'The null-delimited --import-paths data did not match the expected output!' -fi - -# DMD-only beyond this point -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=$DC --data=versions \ - > "$temp_file_normal"; then - die $LINENO 'Printing dmd-style --data=versions failed!' -fi - -if ! $DUB describe --compiler=$DC --data-0 --data=versions \ - | xargs -0 printf "%s " > "$temp_file_zero_delim"; then - die $LINENO 'Printing null-delimited dmd-style --data=versions failed!' -fi - -if ! diff -b -B "$temp_file_normal" "$temp_file_zero_delim"; then - die $LINENO 'The null-delimited dmd-style --data=versions did not match the expected output!' -fi - -# check if escaping is required -. "$CURR_DIR/4-describe-data-check-escape" - -# Test dmd-style --data=source-files -if ! $DUB describe --compiler=$DC --data=source-files \ - > "$temp_file_normal"; then - die $LINENO 'Printing dmd-style --data=source-files failed!' -fi - -if ! $DUB describe --compiler=$DC --data-0 --data=source-files \ - | xargs -0 printf "$(escaped "%s") " > "$temp_file_zero_delim"; then - die $LINENO 'Printing null-delimited dmd-style --data=source-files failed!' -fi - -if ! diff -b -B "$temp_file_normal" "$temp_file_zero_delim"; then - die $LINENO 'The null-delimited dmd-style --data=source-files did not match the expected output!' -fi diff --git a/test/4-describe-data-3-zero-delim/dub.json b/test/4-describe-data-3-zero-delim/dub.json new file mode 100644 index 0000000000..247f4c250b --- /dev/null +++ b/test/4-describe-data-3-zero-delim/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-data-3", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-data-3-zero-delim/source/app.d b/test/4-describe-data-3-zero-delim/source/app.d new file mode 100644 index 0000000000..e9ae31ecf3 --- /dev/null +++ b/test/4-describe-data-3-zero-delim/source/app.d @@ -0,0 +1,81 @@ +import std.algorithm; +import std.array; +import std.file; +import std.path; +import std.process; +import std.range; +import std.stdio; + +import common; +import describe_test_utils; + +void main() +{ + runTestCase([ + "--data-list", + "--data=target-type", + "--data=target-path", + "--data=target-name", + "--data=working-directory", + "--data=main-source-file", + "--data=dflags", + "--data=lflags", + "--data=libs", + "--data=linker-files", + "--data=source-files", + "--data=copy-files", + "--data=versions", + "--data=debug-versions", + "--data=import-paths", + "--data=string-import-paths", + "--data=import-files", + "--data=string-import-files", + "--data=pre-generate-commands", + "--data=post-generate-commands", + "--data=pre-build-commands", + "--data=post-build-commands", + "--data=requirements", + "--data=options", + ]); + + runTestCase([ "--import-paths" ]); + + if (!environment.get("DC").baseName.canFind("dmd")) { + log("Some tests were skipped because DC is not dmd-like"); + return; + } + + runTestCase([ "--data=versions" ], lines => [ lines.join(' ') ]); + + runTestCase([ "--data=source-files" ], lines => [ lines.map!escape.join(' ') ]); + + runTestCase([ "--data=source-files" ], lines => [ lines.map!escape.join(' ') ]); +} + +void runTestCase(string[] arguments, const(char[][]) delegate(const char[][]) mapper = a => a) { + const cmd = [dub, "describe"] ~ arguments; + + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto listStyle = pipeProcess(cmd, Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (listStyle.pid.wait() != 0) + die("Printing list-style project data failed"); + auto zeroStyle = pipeProcess(cmd ~ "--data-0", Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (zeroStyle.pid.wait() != 0) + die("Printing null-delimited list-style project data failed"); + + const listOutput = listStyle.stdout.byLineCopy.map!fixWindowsCR.array; + const preZeroOutput = zeroStyle.stdout.byLineCopy(No.keepTerminator, '\0').array; + const zeroOutput = mapper(preZeroOutput); + + if (!equal(listOutput, zeroOutput)) { + File("list-style.txt", "w").writef("%(%(%c%)\n%)", listOutput); + File("zero-style.txt", "w").writef("%(%(%c%)\n%)", zeroOutput); + + printDifference(listOutput, zeroOutput); + logError("The null-delimited list-style project data did not match the expected output!"); + logError("Check list-style.txt and zero-style.txt"); + die("Dub null-delimited data did not match expected output"); + } +} diff --git a/test/4-describe-data-3-zero-delim/test.config b/test/4-describe-data-3-zero-delim/test.config new file mode 100644 index 0000000000..95ddd5c12d --- /dev/null +++ b/test/4-describe-data-3-zero-delim/test.config @@ -0,0 +1,2 @@ +locks = 4-describe + diff --git a/test/4-describe-data-check-escape b/test/4-describe-data-check-escape deleted file mode 100644 index 8f3794723e..0000000000 --- a/test/4-describe-data-check-escape +++ /dev/null @@ -1,19 +0,0 @@ -dmd_ver=$($DC --version | grep -Eo "v2\.[0-9][0-9][0-9].[0-9]") -dmd_minor=$(echo $dmd_ver | grep -Eo "[0-9][0-9][0-9]") -dmd_micro=${dmd_ver: -1} - -if [[ $dmd_minor$dmd_micro < 1022 || "$CURR_DIR" =~ [[:space:]] ]]; then - echo "Expecting escaped paths" - escape=1 -else - echo "Not expecting escaped paths" - escape=0 -fi - -function escaped { - if [ $escape -eq 1 ]; then - echo -n "'$1'" - else - echo -n "$1" - fi -} diff --git a/test/4-describe-import-paths.sh b/test/4-describe-import-paths.sh deleted file mode 100755 index 201a633e29..0000000000 --- a/test/4-describe-import-paths.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/describe-project - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC --import-paths > "$temp_file"; then - die $LINENO 'Printing import paths failed!' -fi - -# Create the expected output path file to compare against. -echo "$CURR_DIR/describe-project/src/" > "$CURR_DIR/expected-import-path-output" -echo "$CURR_DIR/describe-dependency-1/source/" >> "$CURR_DIR/expected-import-path-output" -echo "$CURR_DIR/describe-dependency-2/some-path/" >> "$CURR_DIR/expected-import-path-output" -echo "$CURR_DIR/describe-dependency-3/dep3-source/" >> "$CURR_DIR/expected-import-path-output" - -if ! diff "$CURR_DIR"/expected-import-path-output "$temp_file"; then - die $LINENO 'The import paths did not match the expected output!' -fi - diff --git a/test/4-describe-import-paths/dub.json b/test/4-describe-import-paths/dub.json new file mode 100644 index 0000000000..b9bba06dc1 --- /dev/null +++ b/test/4-describe-import-paths/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-import-paths", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-import-paths/source/app.d b/test/4-describe-import-paths/source/app.d new file mode 100644 index 0000000000..4b3529b575 --- /dev/null +++ b/test/4-describe-import-paths/source/app.d @@ -0,0 +1,32 @@ +import std.array; +import std.algorithm; +import std.path; +import std.file; +import std.stdio; +import std.process; + +import describe_test_utils; +import common; + +void main() +{ + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto pipes = pipeProcess([dub, "describe", "--import-paths"], + Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (pipes.pid.wait() != 0) + die("Printing import paths failed"); + + immutable expected = [ + describeDir.myBuildPath("project", "src", ""), + describeDir.myBuildPath("dependency-1", "source", ""), + describeDir.myBuildPath("dependency-2", "some-path", ""), + describeDir.myBuildPath("dependency-3", "dep3-source", ""), + ]; + + const got = pipes.stdout.byLineCopy.map!fixWindowsCR.array; + if (equal(got, expected)) return; + + printDifference(got, expected); + die("The import paths did not match the expected output!"); +} diff --git a/test/4-describe-import-paths/test.config b/test/4-describe-import-paths/test.config new file mode 100644 index 0000000000..95ddd5c12d --- /dev/null +++ b/test/4-describe-import-paths/test.config @@ -0,0 +1,2 @@ +locks = 4-describe + diff --git a/test/4-describe-json.sh b/test/4-describe-json.sh deleted file mode 100755 index e22bb7154d..0000000000 --- a/test/4-describe-json.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/describe-project - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC > "$temp_file"; then - die $LINENO 'Printing describe JSON failed!' -fi - diff --git a/test/4-describe-json/dub.json b/test/4-describe-json/dub.json new file mode 100644 index 0000000000..06d9c775d9 --- /dev/null +++ b/test/4-describe-json/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-json", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-json/source/app.d b/test/4-describe-json/source/app.d new file mode 100644 index 0000000000..cb23e6e1df --- /dev/null +++ b/test/4-describe-json/source/app.d @@ -0,0 +1,26 @@ +import std.algorithm; +import std.array; +import std.file; +import std.json; +import std.path; +import std.process; + +import common; + +void main() +{ + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto p = execute( + [dub, "describe"], null, Config.stderrPassThrough, ulong.max, describeDir.buildPath("project")); + + if (p.status != 0) + die("Printing describe JSON failed"); + + const got = p.output; + try { + parseJSON(got); + } catch (JSONException e) { + write("dub-output.txt", got); + die("Dub output was not in JSON format. Check dub-output.txt"); + } +} diff --git a/test/4-describe-json/test.config b/test/4-describe-json/test.config new file mode 100644 index 0000000000..95ddd5c12d --- /dev/null +++ b/test/4-describe-json/test.config @@ -0,0 +1,2 @@ +locks = 4-describe + diff --git a/test/4-describe-string-import-paths.sh b/test/4-describe-string-import-paths.sh deleted file mode 100755 index 89545d531c..0000000000 --- a/test/4-describe-string-import-paths.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/describe-project - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC --string-import-paths > "$temp_file"; then - die $LINENO 'Printing string import paths failed!' -fi - -# Create the expected output path file to compare against. -echo "$CURR_DIR/describe-project/views/" > "$CURR_DIR/expected-string-import-path-output" -echo "$CURR_DIR/describe-dependency-2/some-extra-string-import-path/" >> "$CURR_DIR/expected-string-import-path-output" -echo "$CURR_DIR/describe-dependency-3/dep3-string-import-path/" >> "$CURR_DIR/expected-string-import-path-output" - -if ! diff "$CURR_DIR"/expected-string-import-path-output "$temp_file"; then - die $LINENO 'The string import paths did not match the expected output!' -fi - diff --git a/test/4-describe-string-import-paths/dub.json b/test/4-describe-string-import-paths/dub.json new file mode 100644 index 0000000000..5a62bfe333 --- /dev/null +++ b/test/4-describe-string-import-paths/dub.json @@ -0,0 +1,12 @@ +{ + "name": "describe-string-import-paths", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "describe-test-utils": { + "path": "../extra/4-describe/test-utils" + } + } +} diff --git a/test/4-describe-string-import-paths/source/app.d b/test/4-describe-string-import-paths/source/app.d new file mode 100644 index 0000000000..568163bc8e --- /dev/null +++ b/test/4-describe-string-import-paths/source/app.d @@ -0,0 +1,31 @@ +import std.array; +import std.algorithm; +import std.path; +import std.file; +import std.stdio; +import std.process; + +import describe_test_utils; +import common; + +void main() +{ + immutable describeDir = buildNormalizedPath(getcwd(), "../extra/4-describe"); + auto pipes = pipeProcess([dub, "describe", "--string-import-paths"], + Redirect.all, null, Config.none, + describeDir.buildPath("project")); + if (pipes.pid.wait() != 0) + die("Printing import paths failed"); + + immutable expected = [ + describeDir.myBuildPath("project", "views", ""), + describeDir.myBuildPath("dependency-2", "some-extra-string-import-path", ""), + describeDir.myBuildPath("dependency-3", "dep3-string-import-path", ""), + ]; + + const got = pipes.stdout.byLineCopy.map!fixWindowsCR.array; + if (equal(got, expected)) return; + + printDifference(got, expected); + die("The string import paths did not match the expected output!"); +} diff --git a/test/4-describe-string-import-paths/test.config b/test/4-describe-string-import-paths/test.config new file mode 100644 index 0000000000..95ddd5c12d --- /dev/null +++ b/test/4-describe-string-import-paths/test.config @@ -0,0 +1,2 @@ +locks = 4-describe + diff --git a/test/5-convert-stdout.sh b/test/5-convert-stdout.sh deleted file mode 100755 index ae7b491d95..0000000000 --- a/test/5-convert-stdout.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/1-exec-simple - -EXPECTED="name \"exec-simple\" -targetType \"executable\"" - -RESULT=`${DUB} convert -s -f sdl` - -if [ ! -f dub.json ]; then - die $LINENO 'Package recipe got modified!' -fi - -if [ -f dub.sdl ]; then - die $LINENO 'An SDL recipe got written.' -fi - -if [ "$RESULT" != "$EXPECTED" ]; then - die $LINENO 'Unexpected SDLang output.' -fi diff --git a/test/5-convert-stdout/.gitignore b/test/5-convert-stdout/.gitignore new file mode 100644 index 0000000000..1eb6f3dfe4 --- /dev/null +++ b/test/5-convert-stdout/.gitignore @@ -0,0 +1 @@ +!/sample diff --git a/test/5-convert-stdout/dub.json b/test/5-convert-stdout/dub.json new file mode 100644 index 0000000000..e75ea9fd42 --- /dev/null +++ b/test/5-convert-stdout/dub.json @@ -0,0 +1,9 @@ +{ + "name": "5-convert-stdout", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/5-convert-stdout/sample/dub.json b/test/5-convert-stdout/sample/dub.json new file mode 100644 index 0000000000..9d4f510fe5 --- /dev/null +++ b/test/5-convert-stdout/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "sample-test", + "targetType": "executable" +} diff --git a/test/5-convert-stdout/source/app.d b/test/5-convert-stdout/source/app.d new file mode 100644 index 0000000000..517fabf471 --- /dev/null +++ b/test/5-convert-stdout/source/app.d @@ -0,0 +1,31 @@ +import common; + +import std.algorithm; +import std.array; +import std.file; +import std.process; +import std.stdio : File; +import std.string; + +void main() +{ + chdir("sample"); + + auto pipes = teeProcess([dub, "convert", "-s", "-f", "sdl"], Redirect.stdout); + if (pipes.wait != 0) + die("Dub failed to run"); + + if (!exists("dub.json")) + die("Package recipe got modified!"); + if (exists("dub.sdl")) + die("An SDL recipe got written"); + + immutable expected = [ + `name "sample-test"`, + `targetType "executable"`, + ]; + const got = pipes.stdoutLines; + + if (!equal(got, expected)) + die("Unexpected SDLang output"); +} diff --git a/test/5-convert.sh b/test/5-convert.sh deleted file mode 100755 index 5cdbaa91de..0000000000 --- a/test/5-convert.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/5-convert - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} -trap cleanup EXIT - -cp dub.sdl dub.sdl.ref - -$DUB convert -f json - -if [ -f "dub.sdl" ]; then die $LINENO 'Old recipe file not removed.'; fi -if [ ! -f "dub.json" ]; then die $LINENO 'New recipe file not created.'; fi - -$DUB convert -f sdl - -if [ -f "dub.json" ]; then die $LINENO 'Old recipe file not removed.'; fi -if [ ! -f "dub.sdl" ]; then die $LINENO 'New recipe file not created.'; fi - -if ! diff "dub.sdl" "dub.sdl.ref"; then - die $LINENO 'The project data did not match the expected output!' -fi - -rm dub.sdl.ref - diff --git a/test/5-convert/.gitignore b/test/5-convert/.gitignore new file mode 100644 index 0000000000..765ccab5f8 --- /dev/null +++ b/test/5-convert/.gitignore @@ -0,0 +1,3 @@ +/sample/* +!/sample/ +!/sample/dub.sdl diff --git a/test/5-convert/.no_build b/test/5-convert/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/5-convert/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/5-convert/dub.json b/test/5-convert/dub.json new file mode 100644 index 0000000000..0fdb39ee81 --- /dev/null +++ b/test/5-convert/dub.json @@ -0,0 +1,9 @@ +{ + "name": "5-convert", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/5-convert/dub.sdl b/test/5-convert/sample/dub.sdl similarity index 100% rename from test/5-convert/dub.sdl rename to test/5-convert/sample/dub.sdl diff --git a/test/5-convert/source/app.d b/test/5-convert/source/app.d new file mode 100644 index 0000000000..5330b8f277 --- /dev/null +++ b/test/5-convert/source/app.d @@ -0,0 +1,41 @@ +import common; + +import std.algorithm; +import std.array; +import std.file; +import std.process; +import std.stdio : File; +import std.string; + +void main() +{ + chdir("sample"); + copy("dub.sdl", "dub.sdl.ref"); + scope(exit) rename("dub.sdl.ref", "dub.sdl"); + + spawnProcess([dub, "convert", "-f", "json"]).wait; + + if (exists("dub.sdl")) + die("Old recipe file not removed"); + if (!exists("dub.json")) + die("New recipe file not created"); + + spawnProcess([dub, "convert", "-f", "sdl"]).wait; + + if (exists("dub.json")) + die("Old recipe file not removed"); + if (!exists("dub.sdl")) + die("New recipe file not created"); + + auto orig = File("dub.sdl.ref"); + auto ne = File("dub.sdl"); + + const got = orig.byLineCopy.map!chomp.array; + const expected = ne.byLineCopy.map!chomp.array; + + if (!equal(got, expected)) { + copy("dub.sdl.ref", "dub.sdl.expected"); + copy("dub.sdl", "dub.sdl.got"); + die("The project data did not match the expected output! Check dub.sdl.*"); + } +} diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000000..e3a424809c --- /dev/null +++ b/test/README.md @@ -0,0 +1,305 @@ +# For test writers + +The short version of the process is: + +1. Make a new directory under test +2. (optionally) write a test.config if you need +3. Invoke `dub` in your code with any arguments/paths you need and check the generated files or output; or anything else you need to test. + +Feel free to peek at other tests for inspiration. + +# For test runners + +Run: +``` +DC= ./bin/dub run --root test/run_unittest -- +``` + +Where: +- `` is replaced by your desired D compiler. + The supported variants are: + - `dmd` + - `ldc2` + - `ldmd2` + - `gdmd` (only very recent of the `gdmd` script work, the underlying `gdc` can be older) + + `gdc` is not supported. + +- `` + Can contain the switches: + - `-j` for how many tests to run in parallel + - `-v` in order to show the full output of each test to the console, rather than only *starting* and *finished* lines. The full output is still saved to the `test.log` file so you can safely pass this switch and still have the full output available in case of a failure. + - `--color[=]` To turn on/off color output for log lines and the dub invocations. Note that this leads to color output being saved in the `test.log` file + + You can also pass any amount of glob patterns in order to select which tests to run. + It is an error not to select any tests so if you misspell the pattern the runner will complain. + +As an example, the following invocation: +``` +DC=/usr/bin/dmd-2.111 ./bin/dub run --root test/run_unittest -- -j4 --color=false -v '1-exec-*' +``` +runs the all the tests that match `1-exec-*` (currently those are `1-exec-simple` and `1-exec-simple-package-json`), without color but with full output, with 4 threads. + +# Advanced test writing + +## The `test.config` file + +A summary of all the settings: +``` +# Test requirements +os = [linux, windows, osx] +dc_backend = [gdc, dmd, ldc] +dlang_fe_version_min = 2108 + +# CLI switches passed to dub when running the test +dub_command = build +dub_config = myconfig +dub_build_type = mybuild +extra_dub_args = [ --, -my-app-flag-1 ] + +# Synchronization +locks = [ 1-dynLib-simple ] +must_be_run_alone = true + +# Misc +expect_nonzero = false +``` + +The syntax is very basic: +- empty or whitespace-only lines are ignored +- comments start with `#` and can only be placed at the start of a line +- Other lines are treated as `key = value` assignments. + +The value can be an array denoted by the `[` and `]` characters, with elements separated by commas. +The value can also be a simple string. +Quotes are not supported, nor can you span an array multiple lines. + +The accepted keys are the members of the `TestConfig` struct in [test_config.d](/test/run_unittest/source/run_unittest/test_config.d) + +The accepted values for each setting are based on their D type: +- `enum` accepts any of the names of the `enum`'s members +- `string` accepts any value +- `bool` accept only `true` and `false` + +Arrays accept any number of their element's type. + +As a shorthand, if an array contains only one element, you can skip writing the `[]` around the value. +For example, the following two lines are equivalent: +``` +os = windows +os = [ windows ] +``` + +What follows are detailed descriptions for each setting key: + +#### `os` + +Restricts the test to only run on selected platforms. + +For example: +``` +os = [linux, osx] +``` +will only run the test of `Linux` and `MacOS` platforms. + +### `dc_backend` + +Required that the compiler backend be one of the listed values. + +For example: +``` +dc_backend = [dmd, ldc] +``` +will only run the test with `dmd`, `ldc2`, or `ldmd2`, but not with `gdmd`. + +If you need to disallow `ldc2` but not `ldmd2` then you will need to do so pragmatically inside your test code. +The `common.skip` helper function can be used for this purpose. + +### `dlang_fe_version_min` + +Restrict the compiler frontend version to be higher or equal to the passed value. +The frontend version is the version of the `dmd` code each compiler contains. +For example `gdmd-14` has a FE version of `2.108`. + +Example: +``` +dlang_fe_version_min = 2101 +``` + +Use this setting if you are testing a new feature of the compiler, otherwise try to make your test work with older compilers by not using very recent language features. + +### `dub_command` + +This selects how to run your test. +Possible values are: +- `build` +- `test` +- `run` + +Each value translates to a `dub build`, `dub test`, or, `dub run` invocation. + +This setting is an array so you can pass multiple of the above values, in case you need the test to be built multiple times. + +The default value is `run`. + +For example: +``` +dub_command = build +``` +will not run your test, it will only call `dub build` and interpret a zero exit status as success. + +### `dub_config` + +This selects the package configuration (the `--config` dub switch). + +By default, no value is selected and the switch is not passed to dub. + +For example: +``` +dub_config = myconfig +``` +will run your test with `dub run --config myconfig` + +### `dub_build_type` + +Similarly to `dub_config`, this selects what is passed to the `--build` switch. + +By default, no value is passed. + +For example: +``` +dub_build_type = release +``` +will result in your test being run as `dub run --build release` + +### `extra_dub_args` + +This is a catch-all setting for any specific switches you want to pass to dub. + +For example: +``` +extra_dub_args = [ --, --my-switch ] +``` +will run the test as `dub run -- --my-switch`. + +### `locks` + +This setting is used to prevent tests that use the same resource/dependency from running at the same time. +While the runner tries to isolate each test by passing a specific `DUB_HOME` directory in order to avoid concurrent build of the same (named) package this is not always possible. + +For example, if three tests depend on the same library in `extra/` those could not be run at the same time. +In that scenario, each of those three tests would need to have a `locks` setting with the same value, say `locks = extra/mydep`. +The value doesn't matter, so long as it matches between the three `test.config` files. +Do try, however, to use a self-explanatory name, in order to make it obvious why the tests can't be run in parallel. + +As a special case, the runner always adds the directory name of the test to the `locks` setting to facilitate the few cases in which a test depends on another test. + +For example, if you had two tests `1-lib` and `2-exec-dep-lib`, with `2-exec-dep-lib` having a dependency in its `dub.json` for `1-lib` then you can solve this with a single `test.config`. +It would be placed in the `2-exec-dep-lib` directory and contain: +``` +locks = [ 1-lib ] +``` + +### `must_be_run_alone` + +Similarly to `locks` this setting controls how a test is scheduled with regards to other tests. +It accepts only a `true` or `false` value and, if the value is `true`, like the name suggests, the test will only be run if no other tests are being run. + +It stands to reason that you should only use this setting as a last resort, in case the functionality you are testing actively interferes with the test setup. +An example of such an operation may involve renaming the `dub` executable back and forth. + +Example: +``` +must_be_run_alone = true +``` + +### `expect_nonzero` + +This setting controls the default behavior of deciding the test success/failure based on its exit status. +Normally a zero exit status means that the test completed successfully and a non-zero status means that something failed. +You can switch this behavior with this boolean setting and require that your test exits with a non-zero status in order to be declared successful. + +Note that it is still possible to explicitly fail a test by printing a `[FAIL]: ` line in the output of your program (which is what the `common.die` helper does). +In such a case the test is still marked as a failure, even if `expect_nonzero` is set to `true`. + +Example: +``` +expect_nonzero = true +``` + +## General guarantees + +- `DUB` exists in the environment +- `DC` exists in the environment +- Your test program's working directory is its test folder +- `DUB_HOME` being set and pointing to a test-specific directory. + This allows you to freely build/fetch/remove packages without affecting the user's setup or interfere with other tests. +- `CURR_DIR` exists in the environment and point to the [test](/test) directory + +## General requirements + +### Try to respect `DFLAGS` + +Try to respect the `DFLAGS` environment variable and not overwrite it, as it is meant for users to pass arguments possibly required by their setup. + +If you test fails with any `DFLAGS` then it is acceptable to delete its value. + +### Don't overwrite `etc/dub/settings.json` + +This path, relative to the root of this repository, is meant for users to control `dub` settings. + +### Avoid short names for packages + +Don't have top-level packages (i.e. directly inside [test](/test)) with short or common names. +If two test have the same name (for example `test`) they risk being built at the same time and trigger race conditions between compiler processes. +Use names like `issue1202-test` and `issue1404-test`. + +Note that it is fine to use names such as `test` when generating or building packages from inside your test, since at that point the test will have a separate `DUB_HOME` which will be local to your test so no conflicts can arise. + +## Other notes + +### Output format + +The test runner picks up lines that start with: +- `[INFO]: ` +- `[WARN]: ` +- `[ERROR]: ` +- `[FAIL]: ` +- `[SKIP]: ` + +and either prints them with possible color or it marks the test as failed or skipped. + +The `common` package provides convenience wrappers for these but you're free to print them directly if its easier. + +`[FAIL]:` and `[SKIP]:` use the remaining portion of the line to tell the user why the test was skipped so try to print something meaningful. + +### Directory structure + +The common pattern is that each test is a folder inside `/test/`. +If your test needs some static files they are usually placed inside `sample/`. +If your test dynamically generated some data it is usually placed in a local `test/` subdirectory (for example `/test/custom-unittest/test`). +A `dub` subdirectory inside each test directory is also generated and `DUB_HOME` is set to point to it when the test is run. + +### .gitignore usage + +The default policy is black-list all, white-list as needed. +Try to follow this when you unmask your test's files, which you probably have to do when adding anything other that a `dub.json` and a `source/` directory. + +### cleaning up garbage files + +It's fine if your tests leave temporary files laying around in git-ignored paths. +You don't have to explicitly clean up everything as the user is entrusted to run `git clean -fdx` if they want to get rid of all the junk. + +It is, however, important to perform all the necessary cleanup at the start of your test. +You can't assume that a previous invocation completed successfully or unsuccessfully so try to always start with a clean environment and manually reset all generated files or directories. + +# Advanced test running + +You can configure setting with either the `DFLAGS` environment variable or the `etc/dub/settings.json` file (relative to the root of this repository) + +If you change `DFLAGS` take a note that `gdmd` may fail to build some tests unless you pass it `-q,-Wno-error -allinst`, so be sure to also include these flags. + +The `dub/settings.json` file can be used to configure custom package registries which would allow you to run (some of) the tests without internet access. +It can also give you control of all the tests' inputs. +However, a few tests do fail without internet access and which packages would need to be manually downloaded is not clearly stated. +With some hacking it can be done but if you rely on this functionality feel free to open an issue if you want the situation to improve. diff --git a/test/cache-generated-test-config.sh b/test/cache-generated-test-config.sh deleted file mode 100755 index b3e17210a6..0000000000 --- a/test/cache-generated-test-config.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/cache-generated-test-config -rm -rf $HOME/.dub/cache/cache-generated-test-config/ -DUB_CODE_CACHE_PATH="$HOME/.dub/cache/cache-generated-test-config/~master/code/" - -## default test -${DUB} test --compiler=${DC} - -STAT="stat -c '%Y'" -[[ "$OSTYPE" == "darwin"* ]] && STAT="stat -f '%m' -t '%Y'" - -EXECUTABLE_TIME="$(${STAT} cache-generated-test-config-test-library)" -[ -z "$EXECUTABLE_TIME" ] && die $LINENO 'no EXECUTABLE_TIME was found' -MAIN_TIME="$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*/dub_test_root.d)")" -[ -z "$MAIN_TIME" ] && die $LINENO 'no MAIN_TIME was found' - -${DUB} test --compiler=${DC} -MAIN_FILES_COUNT=$(ls $DUB_CODE_CACHE_PATH/*/dub_test_root.d | wc -l) - -[ $MAIN_FILES_COUNT -ne 1 ] && die $LINENO 'DUB generated more then one main file' -[ "$EXECUTABLE_TIME" != "$(${STAT} cache-generated-test-config-test-library)" ] && die $LINENO 'The executable has been rebuilt' -[ "$MAIN_TIME" != "$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*/dub_test_root.d | head -n1)")" ] && die $LINENO 'The test main file has been rebuilt' - -## test with empty DFLAGS environment variable -DFLAGS="" ${DUB} test --compiler=${DC} - -STAT="stat -c '%Y'" -[[ "$OSTYPE" == "darwin"* ]] && STAT="stat -f '%m' -t '%Y'" - -EXECUTABLE_TIME="$(${STAT} cache-generated-test-config-test-library)" -[ -z "$EXECUTABLE_TIME" ] && die $LINENO 'no EXECUTABLE_TIME was found' -MAIN_TIME="$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d)")" -[ -z "$MAIN_TIME" ] && die $LINENO 'no MAIN_TIME was found' - -DFLAGS="" ${DUB} test --compiler=${DC} -MAIN_FILES_COUNT=$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d | wc -l) - -[ $MAIN_FILES_COUNT -ne 1 ] && die $LINENO 'DUB generated more then one main file' -[ "$EXECUTABLE_TIME" != "$(${STAT} cache-generated-test-config-test-library)" ] && die $LINENO 'The executable has been rebuilt' -[ "$MAIN_TIME" != "$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d | head -n1)")" ] && die $LINENO 'The test main file has been rebuilt' - -## test with DFLAGS environment variable -DFLAGS="-g" ${DUB} test --compiler=${DC} - -STAT="stat -c '%Y'" -[[ "$OSTYPE" == "darwin"* ]] && STAT="stat -f '%m' -t '%Y'" - -EXECUTABLE_TIME="$(${STAT} cache-generated-test-config-test-library)" -[ -z "$EXECUTABLE_TIME" ] && die $LINENO 'no EXECUTABLE_TIME was found' -MAIN_TIME="$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d)")" -[ -z "$MAIN_TIME" ] && die $LINENO 'no MAIN_TIME was found' - -DFLAGS="-g" ${DUB} test --compiler=${DC} -MAIN_FILES_COUNT=$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d | wc -l) - -[ $MAIN_FILES_COUNT -ne 1 ] && die $LINENO 'DUB generated more then one main file' -[ "$EXECUTABLE_TIME" != "$(${STAT} cache-generated-test-config-test-library)" ] && die $LINENO 'The executable has been rebuilt' -[ "$MAIN_TIME" != "$(${STAT} "$(ls $DUB_CODE_CACHE_PATH/*-\$DFLAGS-*/dub_test_root.d | head -n1)")" ] && die $LINENO 'The test main file has been rebuilt' - - - -exit 0 diff --git a/test/cache-generated-test-config/.gitignore b/test/cache-generated-test-config/.gitignore new file mode 100644 index 0000000000..3f9c95ebb7 --- /dev/null +++ b/test/cache-generated-test-config/.gitignore @@ -0,0 +1,4 @@ +/sample/* +!/sample +!/sample/dub.sdl +!/sample/source diff --git a/test/cache-generated-test-config/.no_run b/test/cache-generated-test-config/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/cache-generated-test-config/.no_test b/test/cache-generated-test-config/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/cache-generated-test-config/dub.json b/test/cache-generated-test-config/dub.json new file mode 100644 index 0000000000..1a6ce1eba7 --- /dev/null +++ b/test/cache-generated-test-config/dub.json @@ -0,0 +1,9 @@ +{ + "name": "cache-generated-test-config", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/cache-generated-test-config/dub.sdl b/test/cache-generated-test-config/sample/dub.sdl similarity index 100% rename from test/cache-generated-test-config/dub.sdl rename to test/cache-generated-test-config/sample/dub.sdl diff --git a/test/cache-generated-test-config/source/test.d b/test/cache-generated-test-config/sample/source/test.d similarity index 100% rename from test/cache-generated-test-config/source/test.d rename to test/cache-generated-test-config/sample/source/test.d diff --git a/test/cache-generated-test-config/source/app.d b/test/cache-generated-test-config/source/app.d new file mode 100644 index 0000000000..f7af6b90f8 --- /dev/null +++ b/test/cache-generated-test-config/source/app.d @@ -0,0 +1,73 @@ +import common; + +import std.algorithm; +import std.path; +import std.array; +import std.datetime.systime; +import std.file; +import std.process; +import std.stdio : File; + +void main() +{ + chdir("sample"); + if (dubCodeCachePath.exists) dubCodeCachePath.rmdirRecurse; + string[string] env; + + runTestCase(env, "*dub_test_root.d"); + + env["DFLAGS"] = ""; + runTestCase(env, "*DFLAGS*dub_test_root.d"); + + env["DFLAGS"] = "-g"; + runTestCase(env, "*DFLAGS*dub_test_root.d"); +} + +immutable string dubCodeCachePath; +shared static this() { + dubCodeCachePath = dubHome ~ "/cache/cache-generated-test-config/~master/code/"; +} +immutable executableName = "cache-generated-test-config-test-library" ~ DotExe; + +SysTime mainTime, executableTime; + +void runTestCase(const string[string] env, string pattern) { + invokeDubTest(env); + updateTimes(pattern); + + invokeDubTest(env); + checkTimesDidntChange(pattern); +} + +void invokeDubTest(const string[string] env) { + if (spawnProcess([dub, "test"], env).wait != 0) + die("Dub test failed"); +} + +void updateTimes(string pattern) { + executableTime = executableName.timeLastModified; + mainTime = getMainTime(pattern); +} + +void checkTimesDidntChange(string pattern) { + if (executableTime != executableName.timeLastModified) + die("The executable has been rebuilt"); + + if (mainTime != getMainTime(pattern)) + die("The test main file has been rebuilt"); +} + +SysTime getMainTime(string pattern) { + const files = dubCodeCachePath + .dirEntries(SpanMode.depth) + .map!(e => e.name) + .filter!(name => name.globMatch(pattern)) + .array; + + if (files.length == 0) + die("Dub did not generate a source file"); + if (files.length > 1) + die("Dub generated more than one main file"); + + return files[0].timeLastModified; +} diff --git a/test/colored-output.sh b/test/colored-output.sh deleted file mode 100755 index 71380ffd95..0000000000 --- a/test/colored-output.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/1-exec-simple - -# Test that --color=never disables colors correctly -printf "Expecting 0: " -${DUB} build --color=never --compiler=${DC} 2>&1 | { ! \grep $'^\x1b\[' -c; } - -# Test that --color=auto detects no TTY correctly -printf "Expecting 0: " -${DUB} build --color=auto --compiler=${DC} 2>&1 | { ! \grep $'^\x1b\[' -c; } - -# Test that no --color= has same behaviour as --color=auto -printf "Expecting 0: " -${DUB} build --compiler=${DC} 2>&1 | { ! \grep $'^\x1b\[' -c; } - -# Test that --color=always enables colors in any case -printf "Expecting non-0: " -${DUB} build --color=always --compiler=${DC} 2>&1 | \grep $'^\x1b\[' -c - -# Test forwarding to dmd flag -color - -# Test that --color=always set dmd flag -color -printf "Expecting non-0: " -${DUB} build -v --color=always --compiler=${DC} -f 2>&1 | \grep '\-color' -c - -# Test that --color=never set no dmd flag -printf "Expecting 0: " -${DUB} build -v --color=never --compiler=${DC} -f 2>&1 | { ! \grep '\-color' -c; } - -# Test that --color=auto set no dmd flag -printf "Expecting 0: " -${DUB} build -v --color=auto --compiler=${DC} -f 2>&1 | { ! \grep '\-color' -c; } diff --git a/test/colored-output/.gitignore b/test/colored-output/.gitignore new file mode 100644 index 0000000000..3f9c95ebb7 --- /dev/null +++ b/test/colored-output/.gitignore @@ -0,0 +1,4 @@ +/sample/* +!/sample +!/sample/dub.sdl +!/sample/source diff --git a/test/colored-output/dub.json b/test/colored-output/dub.json new file mode 100644 index 0000000000..f268ed62c0 --- /dev/null +++ b/test/colored-output/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-colored-output", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/colored-output/sample/dub.sdl b/test/colored-output/sample/dub.sdl new file mode 100644 index 0000000000..79ce4de1b4 --- /dev/null +++ b/test/colored-output/sample/dub.sdl @@ -0,0 +1 @@ +name "test-colored-output-sample" diff --git a/test/1-dynLib-simple/.no_build_gdc b/test/colored-output/sample/source/lib.d similarity index 100% rename from test/1-dynLib-simple/.no_build_gdc rename to test/colored-output/sample/source/lib.d diff --git a/test/colored-output/source/app.d b/test/colored-output/source/app.d new file mode 100644 index 0000000000..6a1e4a6032 --- /dev/null +++ b/test/colored-output/source/app.d @@ -0,0 +1,40 @@ +import common; + +import std.algorithm; +import std.path; +import std.array; +import std.datetime.systime; +import std.file; +import std.process; +import std.stdio : File; + +void main() +{ + chdir("sample"); + immutable colorEscape = "\033["; + immutable colorSwitch = environment["DC"].baseName.canFind("ldc") ? + " -enable-color " : " -color "; + + runTestCase(["--color=never"], false, colorEscape); + runTestCase(["--color=auto"], false, colorEscape); + runTestCase([], false, colorEscape); + runTestCase(["--color=always"], true, colorEscape); + + runTestCase(["--force", "-v", "--color=never"], false, colorSwitch); + runTestCase(["--force", "-v", "--color=auto"], false, colorSwitch); + runTestCase(["--force", "-v", "--color=always"], true, colorSwitch); +} + +void runTestCase(string[] args, bool expectToFind, string outputMatch) { + auto p = teeProcess([dub, "build"] ~ args, Redirect.stdout | Redirect.stderrToStdout); + p.wait; + + immutable found = p.stdout.canFind(outputMatch); + if (found == expectToFind) return; + + if (found) { + die("Got color output but didn't expect it"); + } else { + die("Didn't get color output but expected it"); + } +} diff --git a/test/colored-output/test.config b/test/colored-output/test.config new file mode 100644 index 0000000000..413a332b7a --- /dev/null +++ b/test/colored-output/test.config @@ -0,0 +1,5 @@ +# gdmd doesn't (yet) support --color +dc_backend = [dmd, ldc] +# windows color output is more complicated than escape sequences that +# can be grep'ed for in the output. +os = [linux, osx] \ No newline at end of file diff --git a/test/common.sh b/test/common.sh deleted file mode 100644 index 054f00739c..0000000000 --- a/test/common.sh +++ /dev/null @@ -1,58 +0,0 @@ -SOURCE_FILE=$_ - -set -ueEo pipefail - -function log() { - echo -e "\033[0;33m[INFO] $@\033[0m" - echo "[INFO] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log -} - -# lineno[, msg] -function die() { - local line=$1 - local msg=${2:-command failed} - local supplemental=${3:-} - echo "[ERROR] $SOURCE_FILE:$1 $msg" | tee -a $(dirname "${BASH_SOURCE[0]}")/test.log | cat 1>&2 - if [ ! -z "$supplemental" ]; then - echo "$supplemental" | >&2 sed 's|^| |g' - fi - exit 1 -} -trap 'die $LINENO' ERR - -# Get a random port for the test to use -# This isn't foolproof but should fail less than handcrafted approaches -function getRandomPort() { - # Get the PID of this script as a way to get a random port, - # and make sure the value is > 1024, as ports < 1024 are priviledged - # and require root priviledges. - # We also need to make sure the value is not > ushort.max - PORT=$(($$ % 65536)) - if [ $PORT -le 1024 ]; then - PORT=$(($PORT + 1025)) - fi - echo $PORT -} - -# Emulate GNU readlink's behavior on non-GNU readlink (e.g. MacOSX / BSD's) -# Credit to https://stackoverflow.com/a/1116890 -function gnureadlink() { - TARGET_FILE=$1 - - cd `dirname $TARGET_FILE` - TARGET_FILE=`basename $TARGET_FILE` - - # Iterate down a (possible) chain of symlinks - while [ -L "$TARGET_FILE" ] - do - TARGET_FILE=`readlink $TARGET_FILE` - cd `dirname $TARGET_FILE` - TARGET_FILE=`basename $TARGET_FILE` - done - - # Compute the canonicalized name by finding the physical path - # for the directory we're in and appending the target file. - PHYS_DIR=`pwd -P` - RESULT=$PHYS_DIR/$TARGET_FILE - echo $RESULT -} diff --git a/test/common/.no_build b/test/common/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/common/.no_run b/test/common/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/common/.no_test b/test/common/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/common/dub.json b/test/common/dub.json new file mode 100644 index 0000000000..f0da51915d --- /dev/null +++ b/test/common/dub.json @@ -0,0 +1,5 @@ +{ + "name": "common", + "license": "MIT", + "targetType": "sourceLibrary" +} diff --git a/test/common/dub.sdl b/test/common/dub.sdl deleted file mode 100644 index 07cd17547c..0000000000 --- a/test/common/dub.sdl +++ /dev/null @@ -1,6 +0,0 @@ -name "common" -description "Utility package for test suite" -authors "drug007" -copyright "The D language Foundation" -license "BSL-1.0" -targetType "sourceLibrary" diff --git a/test/common/source/common.d b/test/common/source/common.d index 796a05958d..db73c5e12a 100644 --- a/test/common/source/common.d +++ b/test/common/source/common.d @@ -1,40 +1,142 @@ module common; -import std.conv : text; -import std.stdio : File, stdout, stderr; - -/// Name of the log file -enum logFile = "test.log"; - -/// has true if some test fails -bool any_errors = false; - -/// prints (non error) message to standard output and log file -void log(Args...)(Args args) - if (Args.length) -{ - const str = text("[INFO] ", args); - version(Windows) stdout.writeln(str); - else stdout.writeln("\033[0;33m", str, "\033[0m"); - stdout.flush; - File(logFile, "a").writeln(str); -} - -/// prints error message to standard error stream and log file -/// and set any_errors var to true value to indicate that some -/// test fails -void logError(Args...)(Args args) -{ - const str = text("[ERROR] ", args); - version(Windows) stderr.writeln(str); - else stderr.writeln("\033[0;31m", str, "\033[0m"); - stderr.flush; - File(logFile, "a").writeln(str); - any_errors = true; -} - -void die(Args...)(Args args) -{ - stderr.writeln(args); - throw new Exception("Test failed"); +import core.stdc.stdio; +import std.parallelism; +import std.process; +import std.stdio : File; +import std.string; + +void log (const(char)[][] args...) { + printImpl("INFO", args); +} + +void logError (const(char)[][] args...) { + printImpl("ERROR", args); +} + +void die (const(char)[][] args...) { + printImpl("FAIL", args); + throw new Exception("test failed"); +} + +void skip (const(char)[][] args...) { + printImpl("SKIP", args); + throw new Exception("test skipped"); +} + +version(Posix) +immutable DotExe = ""; +else +immutable DotExe = ".exe"; + +immutable string dub; +immutable string dubHome; + +shared static this() { + import std.file; + import std.path; + dub = environment["DUB"]; + dubHome = getcwd.buildPath("dub"); + environment["DUB_HOME"] = dubHome; +} + +struct ProcessT { + string stdout(){ + if (stdoutTask is null) + throw new Exception("Trying to access stdout but it wasn't redirected"); + return stdoutTask.yieldForce; + } + string stderr(){ + if (stderrTask is null) + throw new Exception("Trying to access stderr but it wasn't redirected"); + return stderrTask.yieldForce; + } + string[] stdoutLines() { + return stdout.splitLines(); + } + string[] stderrLines() { + return stderr.splitLines(); + } + File stdin() { return p.stdin; } + + int wait() { + return p.pid.wait; + } + + Pid pid() { return p.pid; } + + this(ProcessPipes p, Redirect redirect, bool quiet = false) { + this.p = p; + this.redirect = redirect; + this.quiet = quiet; + + if (redirect & Redirect.stdout) { + this.stdoutTask = task!linesImpl(p.stdout, quiet); + this.stdoutTask.executeInNewThread(); + } + if (redirect & Redirect.stderr) { + this.stderrTask = task!linesImpl(p.stderr, quiet); + this.stderrTask.executeInNewThread(); + } + } + + ~this() { + if (stdoutTask) + stdoutTask.yieldForce; + if (stderrTask) + stderrTask.yieldForce; + } + + ProcessPipes p; +private: + Task!(linesImpl, File, bool)* stdoutTask; + Task!(linesImpl, File, bool)* stderrTask; + + Redirect redirect; + bool quiet; + bool stdoutDone; + bool stderrDone; + + static string linesImpl(File file, bool quiet) { + import std.typecons; + + string result; + foreach (line; file.byLine(Yes.keepTerminator)) { + if (!quiet) + log(line.chomp); + result ~= line; + } + file.close(); + return result; + } +} + +ProcessT teeProcess( + const string[] args, + Redirect redirect = Redirect.all, + const string[string] env = null, + Config config = Config.none, + const char[] workDir = null, +) { + return ProcessT(pipeProcess(args, redirect, env, config, workDir), redirect); +} + +ProcessT teeProcessQuiet( + const string[] args, + Redirect redirect = Redirect.all, + const string[string] env = null, + Config config = Config.none, + const char[] workDir = null, +) { + return ProcessT(pipeProcess(args, redirect, env, config, workDir), redirect, true); +} + +private: + +void printImpl (string header, const(char)[][] args...) { + printf("[%.*s]: ", cast(int)header.length, header.ptr); + foreach (arg; args) + printf("%.*s", cast(int)arg.length, arg.ptr); + fputc('\n', stdout); + fflush(stdout); } diff --git a/test/cov-ctfe.sh b/test/cov-ctfe.sh deleted file mode 100755 index 5b733c467f..0000000000 --- a/test/cov-ctfe.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -DIR=$(dirname "${BASH_SOURCE[0]}") -. "$DIR"/common.sh -"$DUB" run --root "$DIR"/cov-ctfe --build=cov-ctfe diff --git a/test/cov-ctfe/.gitignore b/test/cov-ctfe/.gitignore new file mode 100644 index 0000000000..9da79f2040 --- /dev/null +++ b/test/cov-ctfe/.gitignore @@ -0,0 +1 @@ +!/test.d \ No newline at end of file diff --git a/test/cov-ctfe/.no_build b/test/cov-ctfe/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/cov-ctfe/.no_run b/test/cov-ctfe/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/cov-ctfe/.no_test b/test/cov-ctfe/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/cov-ctfe/dub.sdl b/test/cov-ctfe/dub.sdl index 51da6664e9..1d64346f80 100644 --- a/test/cov-ctfe/dub.sdl +++ b/test/cov-ctfe/dub.sdl @@ -1,4 +1,4 @@ -name "test" +name "cov-ctfe" version "1.0.0" targetType "executable" dflags "-cov=100" diff --git a/test/cov-ctfe/test.config b/test/cov-ctfe/test.config new file mode 100644 index 0000000000..d29672e166 --- /dev/null +++ b/test/cov-ctfe/test.config @@ -0,0 +1,2 @@ +dub_build_type = cov-ctfe +dc_backend = [dmd, ldc] diff --git a/test/custom-source-main-bug487/.gitignore b/test/custom-source-main-bug487/.gitignore index 433d26664a..7f8f1a3404 100644 --- a/test/custom-source-main-bug487/.gitignore +++ b/test/custom-source-main-bug487/.gitignore @@ -1,5 +1 @@ -.dub -docs.json -__dummy.html -*.o -*.obj +!/mysrc \ No newline at end of file diff --git a/test/custom-source-main-bug487/.no_run b/test/custom-source-main-bug487/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/custom-source-main-bug487/.no_test b/test/custom-source-main-bug487/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/custom-source-main-bug487/test.config b/test/custom-source-main-bug487/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/custom-source-main-bug487/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/custom-unittest/.gitignore b/test/custom-unittest/.gitignore new file mode 100644 index 0000000000..03c5ae8c49 --- /dev/null +++ b/test/custom-unittest/.gitignore @@ -0,0 +1 @@ +!/test \ No newline at end of file diff --git a/test/custom-unittest/test.config b/test/custom-unittest/test.config new file mode 100644 index 0000000000..685e6fc694 --- /dev/null +++ b/test/custom-unittest/test.config @@ -0,0 +1 @@ +dub_command = [run, test] \ No newline at end of file diff --git a/test/d-versions.sh b/test/d-versions.sh deleted file mode 100755 index f9e7da821a..0000000000 --- a/test/d-versions.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/d-versions -${DUB} build --d-version=FromCli1 --d-version=FromCli2 diff --git a/test/d-versions/.gitignore b/test/d-versions/.gitignore index d4b51c642d..ecae94ed7e 100644 --- a/test/d-versions/.gitignore +++ b/test/d-versions/.gitignore @@ -1 +1,4 @@ -d-versions +/sample/* +!/sample/ +!/sample/source +!/sample/dub.sdl \ No newline at end of file diff --git a/test/d-versions/.no_build b/test/d-versions/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/d-versions/.no_run b/test/d-versions/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/d-versions/.no_test b/test/d-versions/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/d-versions/dub.json b/test/d-versions/dub.json new file mode 100644 index 0000000000..93ab6ea051 --- /dev/null +++ b/test/d-versions/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-d-versions", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/d-versions/dub.sdl b/test/d-versions/sample/dub.sdl similarity index 100% rename from test/d-versions/dub.sdl rename to test/d-versions/sample/dub.sdl diff --git a/test/d-versions/sample/source/app.d b/test/d-versions/sample/source/app.d new file mode 100644 index 0000000000..d9bd605a91 --- /dev/null +++ b/test/d-versions/sample/source/app.d @@ -0,0 +1,16 @@ +version (FromCli1) + enum has1 = true; +else + enum has1 = false; + +version (FromCli2) + enum has2 = true; +else + enum has2 = false; + +static assert(has1); +static assert(has2); + +void main() +{ +} diff --git a/test/d-versions/source/app.d b/test/d-versions/source/app.d index d9bd605a91..dd3d6aef6d 100644 --- a/test/d-versions/source/app.d +++ b/test/d-versions/source/app.d @@ -1,16 +1,11 @@ -version (FromCli1) - enum has1 = true; -else - enum has1 = false; +import common; -version (FromCli2) - enum has2 = true; -else - enum has2 = false; +import std.file; +import std.path; +import std.process; -static assert(has1); -static assert(has2); - -void main() -{ +void main () { + auto p = spawnProcess([dub, "build", "--d-version=FromCli1", "--d-version=FromCli2"], null, Config.none, "sample"); + if (p.wait != 0) + die("dub build failed"); } diff --git a/test/dc-env.sh b/test/dc-env.sh deleted file mode 100755 index e5ea3bc436..0000000000 --- a/test/dc-env.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue2012-dc-env - -$DUB app.d ${DC} diff --git a/test/ddox.sh b/test/ddox.sh deleted file mode 100755 index 9675ed8eec..0000000000 --- a/test/ddox.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -. $(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 - -$DUB add-local $CURR_DIR/ddox/custom-tool -(cd $CURR_DIR/ddox/custom && $DUB build -b ddox) -grep -qF custom-tool $CURR_DIR/ddox/custom/docs/custom_tool_output -diff $CURR_DIR/ddox/custom-tool/public/copied $CURR_DIR/ddox/custom/docs/copied -$DUB remove-local $CURR_DIR/ddox/custom-tool diff --git a/test/ddox.sh.min_frontend b/test/ddox.sh.min_frontend deleted file mode 100644 index 0443faedaa..0000000000 --- a/test/ddox.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.072 diff --git a/test/ddox/.gitignore b/test/ddox/.gitignore new file mode 100644 index 0000000000..674200f4f9 --- /dev/null +++ b/test/ddox/.gitignore @@ -0,0 +1,17 @@ +/** + +!/.gitignore +!/source/ +!/source/*.d +!/dub.json + +!/custom +!/custom-tool +!/default + +!/*/dub.sdl +!/*/source +!/*/source/*.d + +!/custom-tool/public/ +!/custom-tool/public/copied diff --git a/test/ddox/.no_build b/test/ddox/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ddox/custom-tool/.gitignore b/test/ddox/custom-tool/.gitignore deleted file mode 100644 index 3dc7018631..0000000000 --- a/test/ddox/custom-tool/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.dub -docs.json -__dummy.html -*.o -*.obj -custom-tool diff --git a/test/ddox/custom/.gitignore b/test/ddox/custom/.gitignore deleted file mode 100644 index 7bd19a763a..0000000000 --- a/test/ddox/custom/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.dub -docs -docs.json -__dummy.html -*.o -*.obj diff --git a/test/ddox/default/.gitignore b/test/ddox/default/.gitignore deleted file mode 100644 index 7bd19a763a..0000000000 --- a/test/ddox/default/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.dub -docs -docs.json -__dummy.html -*.o -*.obj diff --git a/test/ddox/dub.json b/test/ddox/dub.json new file mode 100644 index 0000000000..dce829ac39 --- /dev/null +++ b/test/ddox/dub.json @@ -0,0 +1,8 @@ +{ + "name": "test-ddox", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/ddox/source/app.d b/test/ddox/source/app.d new file mode 100644 index 0000000000..1dac8cdc1e --- /dev/null +++ b/test/ddox/source/app.d @@ -0,0 +1,39 @@ +import common; + +import std.algorithm; +import std.process; +import std.file; +import std.path; + +void main () { + auto p = spawnProcess([dub, "build", "--build=ddox"], null, Config.none, "default"); + if (p.wait != 0) + die("Dub default ddox build failed"); + + assertContains("default/docs/index.html", "ddox_project"); + + p = spawnProcess([dub, "add-local", "custom-tool"]); + if (p.wait != 0) + die("Dub add-local failed"); + + p = spawnProcess([dub, "build", "--build=ddox"], null, Config.none, "custom"); + if (p.wait != 0) + die("Dub build ddox failed with custom tool"); + + assertContains("custom/docs/custom_tool_output", "custom-tool"); + + { + immutable expected = readText("custom-tool/public/copied"); + immutable got = readText("custom/docs/copied"); + if (expected != got) + die("The 2 'copied' files dont' match"); + } +} + +void assertContains(string path, string content) { + if (!exists(path)) + die("ddox run did not create: ", path); + + if (!readText(path).canFind(content)) + die(path, " does not contain '", content, "'"); +} diff --git a/test/depen-build-settings/.gitignore b/test/depen-build-settings/.gitignore index 3dfd42f421..75d6e216d0 100644 --- a/test/depen-build-settings/.gitignore +++ b/test/depen-build-settings/.gitignore @@ -1,4 +1,9 @@ -depend.json -depend2.json -depen-build-settings.json -depen-build-settings +!/depend +!/depend/dub.json +!/depend/source/* + +!/depend/depend2/ +!/depend/depend2/dub.json +!/depend/depend2/source/* + +!/dub.selections.json diff --git a/test/depen-build-settings/.no_build_dmd b/test/depen-build-settings/.no_build_dmd deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/depen-build-settings/.no_build_gdc b/test/depen-build-settings/.no_build_gdc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/depen-build-settings/.no_test b/test/depen-build-settings/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/depen-build-settings/test.config b/test/depen-build-settings/test.config new file mode 100644 index 0000000000..a0eae07d09 --- /dev/null +++ b/test/depen-build-settings/test.config @@ -0,0 +1 @@ +dc_backend = [ldc] diff --git a/test/describe-dependency-1/.no_build b/test/describe-dependency-1/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/describe-dependency-1/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/describe-dependency-2/.no_build b/test/describe-dependency-2/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/describe-dependency-2/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/describe-dependency-3/.no_build b/test/describe-dependency-3/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/describe-dependency-3/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/describe-project/.no_build b/test/describe-project/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/describe-project/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/dest-directory.sh b/test/dest-directory.sh deleted file mode 100755 index 6bc872f89f..0000000000 --- a/test/dest-directory.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/dest-directory -rm -rf .dub -rm -rf testout/ - -${DUB} build --dest=testout/ -if ! [ -d testout/ ]; then - die $LINENO 'Failed to stage into testout/' -fi \ No newline at end of file diff --git a/test/dest-directory/.gitignore b/test/dest-directory/.gitignore new file mode 100644 index 0000000000..30156a6aae --- /dev/null +++ b/test/dest-directory/.gitignore @@ -0,0 +1,4 @@ +/sample/* +!/sample +!/sample/dub.sdl +!/sample/source \ No newline at end of file diff --git a/test/dest-directory/.no_build b/test/dest-directory/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dest-directory/.no_run b/test/dest-directory/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dest-directory/dub.json b/test/dest-directory/dub.json new file mode 100644 index 0000000000..c8b38874d4 --- /dev/null +++ b/test/dest-directory/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-dest-directory", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/dest-directory/dub.sdl b/test/dest-directory/sample/dub.sdl similarity index 100% rename from test/dest-directory/dub.sdl rename to test/dest-directory/sample/dub.sdl diff --git a/test/dest-directory/sample/source/app.d b/test/dest-directory/sample/source/app.d new file mode 100644 index 0000000000..919810306a --- /dev/null +++ b/test/dest-directory/sample/source/app.d @@ -0,0 +1,3 @@ +void main() +{ +} diff --git a/test/dest-directory/source/app.d b/test/dest-directory/source/app.d index 919810306a..fc2f241bc1 100644 --- a/test/dest-directory/source/app.d +++ b/test/dest-directory/source/app.d @@ -1,3 +1,26 @@ -void main() -{ +import common; + +import std.file; +import std.path; +import std.process; + +void rmrf(string path) { + if (exists(path)) rmdirRecurse(path); +} + +void main () { + chdir("sample"); + + rmrf(".dub"); + rmrf("testout"); + + auto p = spawnProcess([dub, "build", "--dest=testout"]); + if (p.wait != 0) + die("Dub build failed"); + + immutable expected = "testout"; + if (!exists(expected)) + die("Dub didn't create the directory ", expected); + if (!isDir(expected)) + die("Dub created ", expected, " but it isn't a directory"); } diff --git a/test/dpath-variable.sh b/test/dpath-variable.sh deleted file mode 100755 index db4ac1dc6c..0000000000 --- a/test/dpath-variable.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -export DPATH="${CURR_DIR}/dpath-variable/dpath" -rm -rf "$DPATH" -cd "${CURR_DIR}/dpath-variable" -"${DUB}" upgrade - -if [[ ! -f "$DPATH/dub/packages/gitcompatibledubpackage/1.0.1/gitcompatibledubpackage/dub.json" ]]; then - die $LINENO 'Did not get dependencies installed into $DPATH.' -fi - -# just for making this shell script easier to write, copy the variable -DPATH_ALIAS="$DPATH" -# unset the variable so DUB doesn't pick it up though -unset DPATH -rm -rf "$DPATH_ALIAS" -echo '{"dubHome":"'"$DPATH_ALIAS"/dub2'"}' > "${CURR_DIR}/dpath-variable/dub.settings.json" - -function cleanup { - rm "${CURR_DIR}/dpath-variable/dub.settings.json" -} -trap cleanup EXIT - -"${DUB}" upgrade - -if [[ ! -f "$DPATH_ALIAS/dub2/packages/gitcompatibledubpackage/1.0.1/gitcompatibledubpackage/dub.json" ]]; then - die $LINENO 'Did not get dependencies installed into dubHome (set from config).' -fi diff --git a/test/dpath-variable/.gitignore b/test/dpath-variable/.gitignore index 9cfa21edc5..bff974fe5a 100644 --- a/test/dpath-variable/.gitignore +++ b/test/dpath-variable/.gitignore @@ -1 +1,4 @@ -dpath +/sample/* +!/sample/ +!/sample/dub.json/ +!/sample/source \ No newline at end of file diff --git a/test/dpath-variable/dub.json b/test/dpath-variable/dub.json index 0d25e304bd..9c1ee5401a 100644 --- a/test/dpath-variable/dub.json +++ b/test/dpath-variable/dub.json @@ -1,6 +1,9 @@ { - "name": "dpath-variable", + "name": "test-dpath-variable", + "targetType": "executable", "dependencies": { - "gitcompatibledubpackage": "1.0.1" + "common": { + "path": "../common" + } } } diff --git a/test/dpath-variable/sample/dub.json b/test/dpath-variable/sample/dub.json new file mode 100644 index 0000000000..0d25e304bd --- /dev/null +++ b/test/dpath-variable/sample/dub.json @@ -0,0 +1,6 @@ +{ + "name": "dpath-variable", + "dependencies": { + "gitcompatibledubpackage": "1.0.1" + } +} diff --git a/test/dpath-variable/sample/source/app.d b/test/dpath-variable/sample/source/app.d new file mode 100644 index 0000000000..919810306a --- /dev/null +++ b/test/dpath-variable/sample/source/app.d @@ -0,0 +1,3 @@ +void main() +{ +} diff --git a/test/dpath-variable/source/app.d b/test/dpath-variable/source/app.d index 919810306a..830b691f60 100644 --- a/test/dpath-variable/source/app.d +++ b/test/dpath-variable/source/app.d @@ -1,3 +1,32 @@ -void main() -{ +import common; + +import std.file; +import std.process; +import std.path; +import std.stdio; + +void main () { + chdir("sample"); + environment.remove("DUB_HOME"); + + immutable dpath = getcwd().buildPath("dpath"); + if (dpath.exists) dpath.rmdirRecurse; + + auto p = spawnProcess([dub, "upgrade"], ["DPATH": dpath]); + if (p.wait != 0) + die("Dub upgrade failed"); + + if (!exists(dpath.buildPath("dub/packages/gitcompatibledubpackage/1.0.1/gitcompatibledubpackage/dub.json"))) + die("Did not get dependencies installed into $DPATH"); + + import std.json; + immutable jsonPath = JSONValue(dpath.buildPath("dub2")); + File("dub.settings.json", "w").writefln(`{ "dubHome": %s }`, jsonPath); + + p = spawnProcess([dub, "upgrade"]); + if (p.wait != 0) + die("Dub upgrade failed"); + + if (!exists(dpath.buildPath("dub2/packages/gitcompatibledubpackage/1.0.1/gitcompatibledubpackage/dub.json"))) + die("Did not get dependencies installed into dubHome (set from config)"); } diff --git a/test/dub-as-a-library-cwd.sh b/test/dub-as-a-library-cwd.sh deleted file mode 100755 index e0faea2cc5..0000000000 --- a/test/dub-as-a-library-cwd.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -$DUB --root="$CURR_DIR/dub-as-a-library-cwd" diff --git a/test/dub-as-a-library-cwd/.gitignore b/test/dub-as-a-library-cwd/.gitignore index 9a2c0e86b4..70538d4cef 100644 --- a/test/dub-as-a-library-cwd/.gitignore +++ b/test/dub-as-a-library-cwd/.gitignore @@ -1 +1,5 @@ -/dub-as-a-library-cwd +/sample/* +!/sample/ +!/sample/source +!/sample/dub.json +!/sample/subproject diff --git a/test/dub-as-a-library-cwd/.no_test b/test/dub-as-a-library-cwd/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dub-as-a-library-cwd/dub.json b/test/dub-as-a-library-cwd/dub.json index 958f419329..a6ef2cb4d5 100644 --- a/test/dub-as-a-library-cwd/dub.json +++ b/test/dub-as-a-library-cwd/dub.json @@ -1,9 +1,9 @@ { - "name": "dub-as-a-library-cwd", - "workingDirectory": ".", + "name": "test-dub-as-a-library-cwd", + "targetType": "executable", "dependencies": { - "dub": { - "path": "../.." + "common": { + "path": "../common" } } } diff --git a/test/dub-as-a-library-cwd/sample/dub.json b/test/dub-as-a-library-cwd/sample/dub.json new file mode 100644 index 0000000000..cb49357c6b --- /dev/null +++ b/test/dub-as-a-library-cwd/sample/dub.json @@ -0,0 +1,9 @@ +{ + "name": "dub-as-a-library-cwd", + "workingDirectory": ".", + "dependencies": { + "dub": { + "path": "../../../" + } + } +} diff --git a/test/dub-as-a-library-cwd/sample/source/app.d b/test/dub-as-a-library-cwd/sample/source/app.d new file mode 100644 index 0000000000..2063702e71 --- /dev/null +++ b/test/dub-as-a-library-cwd/sample/source/app.d @@ -0,0 +1,50 @@ +import dub.compilers.buildsettings; +import dub.compilers.compiler; +import dub.dub; +import dub.generators.generator; +import dub.internal.vibecompat.inet.path; +import std.algorithm; +import std.file; +import std.path; +import std.stdio; + +void main() +{ + auto project = buildNormalizedPath(getcwd, "subproject"); + chdir(buildNormalizedPath(getcwd, "..")); + + bool found; + + auto dub = new Dub(project, null, SkipPackageSuppliers.none); + dub.packageManager.getOrLoadPackage(NativePath(project)); + dub.loadPackage(); + dub.project.validate(); + + GeneratorSettings gs; + gs.buildType = "debug"; + gs.config = "application"; + gs.compiler = getCompiler(dub.defaultCompiler); + gs.run = false; + gs.force = true; + gs.tempBuild = true; + gs.platform = gs.compiler.determinePlatform(gs.buildSettings, + dub.defaultCompiler, dub.defaultArchitecture); + + gs.compileCallback = (status, output) { + writeln(output); + found = output.canFind("FIND_THIS_STRING"); + if (!found) { + writeln("[ERROR]: Did not find the requiring string!"); + writeln("Exit status: ", status); + writeln("Output:"); + writeln(output); + writeln("[FAIL]: Could not find the requiring string"); + } + }; + + stderr.writeln("Checking if building works from a library in a different cwd:"); + dub.generateProject("build", gs); + stderr.writeln("Success: ", found); + + assert(found); +} diff --git a/test/dub-as-a-library-cwd/subproject/dub.sdl b/test/dub-as-a-library-cwd/sample/subproject/dub.sdl similarity index 100% rename from test/dub-as-a-library-cwd/subproject/dub.sdl rename to test/dub-as-a-library-cwd/sample/subproject/dub.sdl diff --git a/test/dub-as-a-library-cwd/subproject/source/app.d b/test/dub-as-a-library-cwd/sample/subproject/source/app.d similarity index 100% rename from test/dub-as-a-library-cwd/subproject/source/app.d rename to test/dub-as-a-library-cwd/sample/subproject/source/app.d diff --git a/test/dub-as-a-library-cwd/source/app.d b/test/dub-as-a-library-cwd/source/app.d index 446c361a39..822027fb5e 100644 --- a/test/dub-as-a-library-cwd/source/app.d +++ b/test/dub-as-a-library-cwd/source/app.d @@ -1,45 +1,8 @@ -import dub.compilers.buildsettings; -import dub.compilers.compiler; -import dub.dub; -import dub.generators.generator; -import dub.internal.vibecompat.inet.path; -import std.algorithm; -import std.file; -import std.path; -import std.stdio; +import common; -void main(string[] args) -{ - auto project = buildNormalizedPath(getcwd, "subproject"); - chdir(buildNormalizedPath(getcwd, "..")); +import std.process; - bool found; - - auto dub = new Dub(project, null, SkipPackageSuppliers.none); - dub.packageManager.getOrLoadPackage(NativePath(project)); - dub.loadPackage(); - dub.project.validate(); - - GeneratorSettings gs; - gs.buildType = "debug"; - gs.config = "application"; - gs.compiler = getCompiler(dub.defaultCompiler); - gs.run = false; - gs.force = true; - gs.tempBuild = true; - gs.platform = gs.compiler.determinePlatform(gs.buildSettings, - dub.defaultCompiler, dub.defaultArchitecture); - - gs.compileCallback = (status, output) { - found = output.canFind("FIND_THIS_STRING"); - if (!found) - stderr.writeln("Did not find required string!\nExit status:", - status, "\n\nOutput:\n", output); - }; - - stderr.writeln("Checking if building works from a library in a different cwd:"); - dub.generateProject("build", gs); - stderr.writeln("Success: ", found); - - assert(found); +void main () { + if (spawnProcess([dub, "--root=sample"]).wait != 0) + die("Dub --root failed"); } diff --git a/test/dub-custom-root-2/.gitignore b/test/dub-custom-root-2/.gitignore deleted file mode 100644 index 2278645278..0000000000 --- a/test/dub-custom-root-2/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.dub -docs.json -__dummy.html -*.o -*.obj -/target-exe diff --git a/test/dub-custom-root-2/.no_run b/test/dub-custom-root-2/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dub-custom-root-2/.no_test b/test/dub-custom-root-2/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dub-custom-root-2/source/app.d b/test/dub-custom-root-2/source/app.d deleted file mode 100644 index 5d07423ae0..0000000000 --- a/test/dub-custom-root-2/source/app.d +++ /dev/null @@ -1,12 +0,0 @@ -import std.file; -import std.path; -import std.stdio; -import std.string; - -void main() -{ - // run me from test/ with dub --root=dub-custom-root - string cwd = getcwd.chomp("/"); - assert(cwd.endsWith("test/dub-custom-root-2/source"), cwd); - writeln("ok"); -} diff --git a/test/dub-custom-root.sh b/test/dub-custom-root.sh deleted file mode 100755 index f7e52ca03a..0000000000 --- a/test/dub-custom-root.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -pushd "$CURR_DIR" - -$DUB --root=dub-custom-root - -$DUB --root=dub-custom-root-2 - -popd diff --git a/test/dub-custom-root/.gitignore b/test/dub-custom-root/.gitignore index 2278645278..2bd6def578 100644 --- a/test/dub-custom-root/.gitignore +++ b/test/dub-custom-root/.gitignore @@ -1,6 +1,9 @@ -.dub -docs.json -__dummy.html -*.o -*.obj -/target-exe +/custom-root/* +!/custom-root/ +!/custom-root/dub.json +!/custom-root/source/ + +/custom-root-2/* +!/custom-root-2/ +!/custom-root-2/dub.json +!/custom-root-2/source/ \ No newline at end of file diff --git a/test/dub-custom-root/.no_run b/test/dub-custom-root/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dub-custom-root/.no_test b/test/dub-custom-root/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dub-custom-root-2/dub.json b/test/dub-custom-root/custom-root-2/dub.json similarity index 100% rename from test/dub-custom-root-2/dub.json rename to test/dub-custom-root/custom-root-2/dub.json diff --git a/test/dub-custom-root/custom-root-2/source/app.d b/test/dub-custom-root/custom-root-2/source/app.d new file mode 100644 index 0000000000..531fa164ea --- /dev/null +++ b/test/dub-custom-root/custom-root-2/source/app.d @@ -0,0 +1,12 @@ +import std.file; +import std.path; +import std.stdio; +import std.string; + +void main() +{ + // run me from test/dub-custom-root with dub --root=custom-root-2 + string cwd = getcwd; + immutable expected = buildPath("test", "dub-custom-root", "custom-root-2", "source"); + assert(cwd.endsWith(expected), cwd); +} diff --git a/test/dub-custom-root/custom-root/dub.json b/test/dub-custom-root/custom-root/dub.json new file mode 100644 index 0000000000..172c135532 --- /dev/null +++ b/test/dub-custom-root/custom-root/dub.json @@ -0,0 +1,3 @@ +{ + "name": "target-exe" +} diff --git a/test/dub-custom-root/custom-root/source/app.d b/test/dub-custom-root/custom-root/source/app.d new file mode 100644 index 0000000000..2c2eb4f7d7 --- /dev/null +++ b/test/dub-custom-root/custom-root/source/app.d @@ -0,0 +1,9 @@ +import std.file; +import std.path; +import std.stdio; + +void main() +{ + // run me from test/dub-custom-root with dub --root=custom-root + assert(getcwd.baseName == "dub-custom-root", getcwd); +} diff --git a/test/dub-custom-root/dub.json b/test/dub-custom-root/dub.json index 172c135532..becb33e1b7 100644 --- a/test/dub-custom-root/dub.json +++ b/test/dub-custom-root/dub.json @@ -1,3 +1,9 @@ { - "name": "target-exe" + "name": "dub-custom-root", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/dub-custom-root/source/app.d b/test/dub-custom-root/source/app.d index 612dfe01dc..757be42a43 100644 --- a/test/dub-custom-root/source/app.d +++ b/test/dub-custom-root/source/app.d @@ -1,10 +1,13 @@ -import std.file; -import std.path; -import std.stdio; +import common; -void main() -{ - // run me from test/ with dub --root=test/dub-custom-root - assert(getcwd.baseName == "test", getcwd); - writeln("ok"); +import std.process; + +void main () { + auto p = spawnProcess([dub, "--root=custom-root"]); + if (p.wait != 0) + die("dub --root=custom-root failed"); + + p = spawnProcess([dub, "--root=custom-root-2"]); + if (p.wait != 0) + die("dub --root=custom-root-2 failed"); } diff --git a/test/dub_test_root.sh b/test/dub_test_root.sh deleted file mode 100755 index 7c0f50b678..0000000000 --- a/test/dub_test_root.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# Make sure the auto-generated 'dub_test_root' module is importable for -# non-all-at-once compilations too. - -set -euo pipefail - -TMPDIR=$(mktemp -d "$(basename "$0").XXXXXX") - -pushd "$TMPDIR" -function cleanup { - popd - rm -rf "$TMPDIR" -} -trap cleanup EXIT - - -echo 'name "foo"' > dub.sdl - -mkdir -p source -echo 'import dub_test_root : allModules;' > source/foo.d - -$DUB test --build-mode=singleFile diff --git a/test/dub_test_root/dub.json b/test/dub_test_root/dub.json new file mode 100644 index 0000000000..51aef37bd9 --- /dev/null +++ b/test/dub_test_root/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-dub_test_root", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/dub_test_root/source/app.d b/test/dub_test_root/source/app.d new file mode 100644 index 0000000000..a5c8b1fba9 --- /dev/null +++ b/test/dub_test_root/source/app.d @@ -0,0 +1,23 @@ +import common; + +import std.file; +import std.path; +import std.process; + +void main () { + immutable dub = environment["DUB"]; + + immutable tmpDir = "tmp"; + if (tmpDir.exists) tmpDir.rmdirRecurse(); + + tmpDir.mkdir; + chdir(tmpDir); + "dub.sdl".write(`name "foo"`); + + "source".mkdir; + "source/foo.d".write(q{import dub_test_root : allModules;}); + + auto p = spawnProcess([dub, "test", "--build-mode=singleFile"]); + if (p.wait != 0) + die("Dub test failed"); +} diff --git a/test/dustmite-no-redirect-test/.no_build b/test/dustmite-no-redirect-test/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/dustmite-no-redirect.sh b/test/dustmite-no-redirect.sh deleted file mode 100755 index 30c6b9c308..0000000000 --- a/test/dustmite-no-redirect.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -if ! command -v dustmite &> /dev/null -then - echo "Skipping test because dustmite is not installed!" - exit 0 -fi - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -DM_TEST="$CURR_DIR/dustmite-no-redirect-test/project" -DM_TMP="$DM_TEST-dusting" -EXPECTED="This text should be shown!" -LOG="$DM_TEST.log" - -rm -rf $DM_TMP $DM_TMP.* - -$DUB --root=$DM_TEST dustmite --no-redirect --program-status=1 $DM_TMP &> $LOG || true - -if ! grep -q "$EXPECTED" "$LOG" -then - cat $LOG - die $LINENO "Diff between expected and actual output" -fi - -rm -rf $DM_TMP $DM_TMP.* $LOG diff --git a/test/dustmite-no-redirect/.gitignore b/test/dustmite-no-redirect/.gitignore new file mode 100644 index 0000000000..60ec48da42 --- /dev/null +++ b/test/dustmite-no-redirect/.gitignore @@ -0,0 +1,4 @@ +/sample/* +!/sample +!/sample/source +!/sample/dub.json \ No newline at end of file diff --git a/test/dustmite-no-redirect/dub.json b/test/dustmite-no-redirect/dub.json new file mode 100644 index 0000000000..02229783a9 --- /dev/null +++ b/test/dustmite-no-redirect/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-dustmite-no-redirect", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/dustmite-no-redirect-test/project/dub.json b/test/dustmite-no-redirect/sample/dub.json similarity index 100% rename from test/dustmite-no-redirect-test/project/dub.json rename to test/dustmite-no-redirect/sample/dub.json diff --git a/test/dustmite-no-redirect-test/project/source/app.d b/test/dustmite-no-redirect/sample/source/app.d similarity index 100% rename from test/dustmite-no-redirect-test/project/source/app.d rename to test/dustmite-no-redirect/sample/source/app.d diff --git a/test/dustmite-no-redirect/source/app.d b/test/dustmite-no-redirect/source/app.d new file mode 100644 index 0000000000..4e1b97a39d --- /dev/null +++ b/test/dustmite-no-redirect/source/app.d @@ -0,0 +1,36 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + // are DFLAGS unquoted? + environment.remove("DFLAGS"); + + bool doSkip = false; + try { + if (!execute("dustmite").status != 0) + doSkip = true; + } catch (ProcessException) + doSkip = true; + + if (doSkip) + skip("dustmite not found in $PATH"); + + immutable testDir = "sample"; + immutable tmpDir = "sample-dusting"; + immutable expected = "This text should be shown!"; + + dirEntries(".", tmpDir ~ "*", SpanMode.shallow) + .each!rmdirRecurse; + + auto p = execute([dub, "--root=" ~ testDir, "dustmite", "--no-redirect", "--program-status=1", tmpDir]); + + if (!p.output.canFind(expected)) { + writeln(p.output); + die("Diff between expected and actual output"); + } +} diff --git a/test/environment-variables.script.d b/test/environment-variables.script.d deleted file mode 100644 index 347f696822..0000000000 --- a/test/environment-variables.script.d +++ /dev/null @@ -1,88 +0,0 @@ -/+ dub.json: { - "name": "environment_variables" -} +/ -module environment_variables; -import std; - -void main() -{ - auto currDir = environment.get("CURR_DIR", __FILE_FULL_PATH__.dirName()); - // preGenerateCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.preGenerateEnvironments < root.preGenerateEnvironments - // preBuildCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments < deppkg.preBuildEnvironments < root.preBuildEnvironments - // Build tools uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments - // postBuildCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments < deppkg.postBuildEnvironments < root.postBuildEnvironments - // postGenerateCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.postGenerateEnvironments < root.postGenerateEnvironments - // preRunCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments < deppkg.preRunEnvironments < root.preRunEnvironments - // User application uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments - // postRunCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments < deppkg.postRunEnvironments < root.postRunEnvironments - - // Test cases covers: - // preGenerateCommands [in root] - // priority check: system.environments < settings.environments - // priority check: settings.environments < deppkg.environments - // priority check: deppkg.environments < root.environments - // priority check: root.environments < deppkg.preGenerateEnvironments - // priority check: deppkg.preGenerateEnvironments < root.preGenerateEnvironments - // postGenerateCommands [in root] - // expantion check: deppkg.VAR4 - // preBuildCommands [in deppkg] - // root.environments < deppkg.buildEnvironments - // deppkg.buildEnvironments < root.buildEnvironments - // root.buildEnvironments < deppkg.postBuildEnvironments - // deppkg.preBuildEnvironments < root.preBuildEnvironments - // postBuildCommands [in deppkg] - // expantion check: deppkg.VAR4 - // preRunCommands [in deppkg][in root] - // expantion check: deppkg.VAR4 - // Application run - // expantion check: root.VAR1 - // expantion check: settings.VAR2 - // expantion check: root.VAR3 - // expantion check: deppkg.VAR4 - // expantion check: system.VAR5 - // expantion check: system.SYSENVVAREXPCHECK - // postRunCommands [in deppkg][in root] - // expantion check: deppkg.VAR4 - auto res = execute([environment.get("DUB", "dub"), "run", "-f"], [ - "PRIORITYCHECK_SYS_SET": "system.PRIORITYCHECK_SYS_SET", - "SYSENVVAREXPCHECK": "system.SYSENVVAREXPCHECK", - "VAR5": "system.VAR5" - ], Config.none, size_t.max, currDir.buildPath("environment-variables")); - scope (failure) - writeln("environment-variables test failed... Testing stdout is:\n-----\n", res.output); - - // preGenerateCommands [in root] - assert(res.output.canFind("root.preGenerate: setting.PRIORITYCHECK_SYS_SET"), "preGenerate environment variables priority check is failed."); - assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_SET_DEP"), "preGenerate environment variables priority check is failed."); - assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_DEP_ROOT"), "preGenerate environment variables priority check is failed."); - assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_ROOT_DEPSPEC"), "preGenerate environment variables priority check is failed."); - assert(res.output.canFind("root.preGenerate: root.PRIORITYCHECK_DEPSPEC_ROOTSPEC"), "preGenerate environment variables priority check is failed."); - - // postGenerateCommands [in root] - assert(res.output.canFind("root.postGenerate: deppkg.VAR4", "postGenerate environment variables expantion check is failed.")); - - // preBuildCommands [in deppkg] - assert(res.output.canFind("deppkg.preBuild: deppkg.PRIORITYCHECK_ROOT_DEPBLDSPEC"), "preBuild environment variables priority check is failed."); - assert(res.output.canFind("deppkg.preBuild: root.PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC"), "preBuild environment variables priority check is failed."); - assert(res.output.canFind("deppkg.preBuild: deppkg.PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC"), "preBuild environment variables priority check is failed."); - assert(res.output.canFind("deppkg.preBuild: root.PRIORITYCHECK_DEPSPEC_ROOTSPEC"), "preBuild environment variables priority check is failed."); - - // postBuildCommands [in deppkg] - assert(res.output.canFind("deppkg.postBuild: deppkg.VAR4"), "postBuild environment variables expantion check is failed."); - - // preRunCommands [in deppkg][in root] - assert(!res.output.canFind("deppkg.preRun: deppkg.VAR4"), "preRun that is defined dependent library does not call."); - assert(res.output.canFind("root.preRun: deppkg.VAR4"), "preRun environment variables expantion check is failed."); - - // Application run - assert(res.output.canFind("app.run: root.VAR1"), "run environment variables expantion check is failed."); - assert(res.output.canFind("app.run: settings.VAR2"), "run environment variables expantion check is failed."); - assert(res.output.canFind("app.run: root.VAR3"), "run environment variables expantion check is failed."); - assert(res.output.canFind("app.run: deppkg.VAR4"), "run environment variables expantion check is failed."); - assert(res.output.canFind("app.run: system.VAR5"), "run environment variables expantion check is failed."); - assert(res.output.canFind("app.run: system.SYSENVVAREXPCHECK"), "run environment variables expantion check is failed."); - - // postRunCommands [in deppkg][in root] - assert(!res.output.canFind("deppkg.postRun: deppkg.VAR4"), "postRunCommands that is defined dependent library does not call."); - assert(res.output.canFind("root.postRun: deppkg.VAR4"), "postRun environment variables expantion check is failed."); -} diff --git a/test/environment-variables/.gitignore b/test/environment-variables/.gitignore index 58891a280a..a5fb3feade 100644 --- a/test/environment-variables/.gitignore +++ b/test/environment-variables/.gitignore @@ -1,12 +1,11 @@ -* -!.no_build -!.no_test -!.no_run -!dub.json -!dub.settings.json -!source -!source/app.d -!deppkg -!deppkg/dub.json -!deppkg/source/deppkg/foo.d +/sample/* +!/sample +!/sample/dub.json +!/sample/dub.settings.json +!/sample/source/ + +!/sample/deppkg/ +!/sample/deppkg/dub.json +!/sample/deppkg/source/ +!/sample/deppkg/dub.settings.json \ No newline at end of file diff --git a/test/environment-variables/.no_build b/test/environment-variables/.no_build deleted file mode 100644 index d3f5a12faa..0000000000 --- a/test/environment-variables/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/environment-variables/.no_run b/test/environment-variables/.no_run deleted file mode 100644 index d3f5a12faa..0000000000 --- a/test/environment-variables/.no_run +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/environment-variables/.no_test b/test/environment-variables/.no_test deleted file mode 100644 index d3f5a12faa..0000000000 --- a/test/environment-variables/.no_test +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/environment-variables/dub.json b/test/environment-variables/dub.json index ceab672d32..77cbf489a8 100644 --- a/test/environment-variables/dub.json +++ b/test/environment-variables/dub.json @@ -1,56 +1,9 @@ { - "name": "environment-variables", + "name": "test-environment-variables", + "targetType": "executable", "dependencies": { - "deppkg": {"path": "deppkg"} - }, - - "environments": { - "ENVIRONMENTS": "root.environments", - "VAR1": "root.VAR1", - "VAR3": "root.VAR3", - "PRIORITYCHECK_DEP_ROOT": "root.PRIORITYCHECK_DEP_ROOT", - "PRIORITYCHECK_ROOT_DEPSPEC": "root.PRIORITYCHECK_ROOT_DEPSPEC", - "PRIORITYCHECK_ROOT_DEPBLDSPEC": "root.PRIORITYCHECK_ROOT_DEPBLDSPEC" - }, - "buildEnvironments": { - "BUILD_ENVIRONMENTS": "root.buildEnvironments", - "PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC": "root.PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC" - }, - "runEnvironments": { - "RUN_ENVIRONMENTS": "root.runEnvironments" - }, - "preGenerateEnvironments": { - "PRE_GENERATE_ENVIRONMENTS": "root.preGenerateEnvironments", - "PRIORITYCHECK_DEPSPEC_ROOTSPEC": "root.PRIORITYCHECK_DEPSPEC_ROOTSPEC" - }, - "postGenerateEnvironments": { - "POST_GENERATE_ENVIRONMENTS": "root.postGenerateEnvironments" - }, - "preBuildEnvironments": { - "PRE_BUILD_ENVIRONMENTS": "root.preBuildEnvironments", - "PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC": "root.PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC", - "PRIORITYCHECK_DEPSPEC_ROOTSPEC": "root.PRIORITYCHECK_DEPSPEC_ROOTSPEC" - }, - "postBuildEnvironments": { - "POST_BUILD_ENVIRONMENTS": "root.postBuildEnvironments" - }, - "preRunEnvironments": { - "PRE_RUN_ENVIRONMENTS": "root.preRunEnvironments" - }, - "postRunEnvironments": { - "POST_RUN_ENVIRONMENTS": "root.postRunEnvironments" - }, - - "preGenerateCommands": [ - "echo root.preGenerate: $PRIORITYCHECK_SYS_SET", - "echo root.preGenerate: $PRIORITYCHECK_SET_DEP", - "echo root.preGenerate: $PRIORITYCHECK_DEP_ROOT", - "echo root.preGenerate: $PRIORITYCHECK_ROOT_DEPSPEC", - "echo root.preGenerate: $PRIORITYCHECK_DEPSPEC_ROOTSPEC" - ], - "postGenerateCommands": ["echo root.postGenerate: $VAR4"], - "preBuildCommands": ["echo root.preBuild: $VAR4"], - "postBuildCommands": ["echo root.postBuild: $VAR4"], - "preRunCommands": ["echo root.preRun: $VAR4"], - "postRunCommands": ["echo root.postRun: $VAR4"] + "common": { + "path": "../common" + } + } } diff --git a/test/environment-variables/deppkg/dub.json b/test/environment-variables/sample/deppkg/dub.json similarity index 96% rename from test/environment-variables/deppkg/dub.json rename to test/environment-variables/sample/deppkg/dub.json index 10e9fc843a..8eb399ab4c 100644 --- a/test/environment-variables/deppkg/dub.json +++ b/test/environment-variables/sample/deppkg/dub.json @@ -1,7 +1,7 @@ { - "name": "deppkg", + "name": "environment-variables-deppkg", "targetType": "library", - + "environments": { "VAR1": "deppkg.VAR1", "VAR3": "deppkg.VAR3", @@ -21,7 +21,7 @@ "PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC": "deppkg.PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC", "PRIORITYCHECK_DEPSPEC_ROOTSPEC": "deppkg.PRIORITYCHECK_DEPSPEC_ROOTSPEC" }, - + "preBuildCommands": [ "echo deppkg.preBuild: $PRIORITYCHECK_ROOT_DEPBLDSPEC", "echo deppkg.preBuild: $PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC", diff --git a/test/environment-variables/deppkg/source/deppkg/foo.d b/test/environment-variables/sample/deppkg/source/deppkg/foo.d similarity index 100% rename from test/environment-variables/deppkg/source/deppkg/foo.d rename to test/environment-variables/sample/deppkg/source/deppkg/foo.d diff --git a/test/environment-variables/sample/dub.json b/test/environment-variables/sample/dub.json new file mode 100644 index 0000000000..6e6395ff13 --- /dev/null +++ b/test/environment-variables/sample/dub.json @@ -0,0 +1,56 @@ +{ + "name": "environment-variables-test", + "dependencies": { + "environment-variables-deppkg": {"path": "deppkg"} + }, + + "environments": { + "ENVIRONMENTS": "root.environments", + "VAR1": "root.VAR1", + "VAR3": "root.VAR3", + "PRIORITYCHECK_DEP_ROOT": "root.PRIORITYCHECK_DEP_ROOT", + "PRIORITYCHECK_ROOT_DEPSPEC": "root.PRIORITYCHECK_ROOT_DEPSPEC", + "PRIORITYCHECK_ROOT_DEPBLDSPEC": "root.PRIORITYCHECK_ROOT_DEPBLDSPEC" + }, + "buildEnvironments": { + "BUILD_ENVIRONMENTS": "root.buildEnvironments", + "PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC": "root.PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC" + }, + "runEnvironments": { + "RUN_ENVIRONMENTS": "root.runEnvironments" + }, + "preGenerateEnvironments": { + "PRE_GENERATE_ENVIRONMENTS": "root.preGenerateEnvironments", + "PRIORITYCHECK_DEPSPEC_ROOTSPEC": "root.PRIORITYCHECK_DEPSPEC_ROOTSPEC" + }, + "postGenerateEnvironments": { + "POST_GENERATE_ENVIRONMENTS": "root.postGenerateEnvironments" + }, + "preBuildEnvironments": { + "PRE_BUILD_ENVIRONMENTS": "root.preBuildEnvironments", + "PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC": "root.PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC", + "PRIORITYCHECK_DEPSPEC_ROOTSPEC": "root.PRIORITYCHECK_DEPSPEC_ROOTSPEC" + }, + "postBuildEnvironments": { + "POST_BUILD_ENVIRONMENTS": "root.postBuildEnvironments" + }, + "preRunEnvironments": { + "PRE_RUN_ENVIRONMENTS": "root.preRunEnvironments" + }, + "postRunEnvironments": { + "POST_RUN_ENVIRONMENTS": "root.postRunEnvironments" + }, + + "preGenerateCommands": [ + "echo root.preGenerate: $PRIORITYCHECK_SYS_SET", + "echo root.preGenerate: $PRIORITYCHECK_SET_DEP", + "echo root.preGenerate: $PRIORITYCHECK_DEP_ROOT", + "echo root.preGenerate: $PRIORITYCHECK_ROOT_DEPSPEC", + "echo root.preGenerate: $PRIORITYCHECK_DEPSPEC_ROOTSPEC" + ], + "postGenerateCommands": ["echo root.postGenerate: $VAR4"], + "preBuildCommands": ["echo root.preBuild: $VAR4"], + "postBuildCommands": ["echo root.postBuild: $VAR4"], + "preRunCommands": ["echo root.preRun: $VAR4"], + "postRunCommands": ["echo root.postRun: $VAR4"] +} diff --git a/test/environment-variables/dub.settings.json b/test/environment-variables/sample/dub.settings.json similarity index 100% rename from test/environment-variables/dub.settings.json rename to test/environment-variables/sample/dub.settings.json diff --git a/test/environment-variables/sample/source/app.d b/test/environment-variables/sample/source/app.d new file mode 100644 index 0000000000..037672a0bb --- /dev/null +++ b/test/environment-variables/sample/source/app.d @@ -0,0 +1,12 @@ +import std.stdio; +import std.process; + +void main() +{ + writeln("app.run: ", environment.get("VAR1", "")); + writeln("app.run: ", environment.get("VAR2", "")); + writeln("app.run: ", environment.get("VAR3", "")); + writeln("app.run: ", environment.get("VAR4", "")); + writeln("app.run: ", environment.get("VAR5", "")); + writeln("app.run: ", environment.get("SYSENVVAREXPCHECK", "")); +} diff --git a/test/environment-variables/source/app.d b/test/environment-variables/source/app.d index 037672a0bb..47608b052f 100644 --- a/test/environment-variables/source/app.d +++ b/test/environment-variables/source/app.d @@ -1,12 +1,92 @@ -import std.stdio; -import std.process; +module environment_variables; + +import common; + +import std; void main() { - writeln("app.run: ", environment.get("VAR1", "")); - writeln("app.run: ", environment.get("VAR2", "")); - writeln("app.run: ", environment.get("VAR3", "")); - writeln("app.run: ", environment.get("VAR4", "")); - writeln("app.run: ", environment.get("VAR5", "")); - writeln("app.run: ", environment.get("SYSENVVAREXPCHECK", "")); + auto currDir = environment.get("CURR_DIR"); + // preGenerateCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.preGenerateEnvironments < root.preGenerateEnvironments + // preBuildCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments < deppkg.preBuildEnvironments < root.preBuildEnvironments + // Build tools uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments + // postBuildCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.buildEnvironments < root.buildEnvironments < deppkg.postBuildEnvironments < root.postBuildEnvironments + // postGenerateCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.postGenerateEnvironments < root.postGenerateEnvironments + // preRunCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments < deppkg.preRunEnvironments < root.preRunEnvironments + // User application uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments + // postRunCommands uses system.environments < settings.environments < deppkg.environments < root.environments < deppkg.runEnvironments < root.runEnvironments < deppkg.postRunEnvironments < root.postRunEnvironments + + // Test cases covers: + // preGenerateCommands [in root] + // priority check: system.environments < settings.environments + // priority check: settings.environments < deppkg.environments + // priority check: deppkg.environments < root.environments + // priority check: root.environments < deppkg.preGenerateEnvironments + // priority check: deppkg.preGenerateEnvironments < root.preGenerateEnvironments + // postGenerateCommands [in root] + // expantion check: deppkg.VAR4 + // preBuildCommands [in deppkg] + // root.environments < deppkg.buildEnvironments + // deppkg.buildEnvironments < root.buildEnvironments + // root.buildEnvironments < deppkg.postBuildEnvironments + // deppkg.preBuildEnvironments < root.preBuildEnvironments + // postBuildCommands [in deppkg] + // expantion check: deppkg.VAR4 + // preRunCommands [in deppkg][in root] + // expantion check: deppkg.VAR4 + // Application run + // expantion check: root.VAR1 + // expantion check: settings.VAR2 + // expantion check: root.VAR3 + // expantion check: deppkg.VAR4 + // expantion check: system.VAR5 + // expantion check: system.SYSENVVAREXPCHECK + // postRunCommands [in deppkg][in root] + // expantion check: deppkg.VAR4 + auto res = execute([dub, "run", "-f"], [ + "PRIORITYCHECK_SYS_SET": "system.PRIORITYCHECK_SYS_SET", + "SYSENVVAREXPCHECK": "system.SYSENVVAREXPCHECK", + "VAR5": "system.VAR5" + ], Config.none, size_t.max, "sample"); + scope (failure) { + writeln("environment-variables test failed..."); + writeln("Testing stdout is:"); + writeln(res.output); + die("environment-variables test failed"); + } + + // preGenerateCommands [in root] + assert(res.output.canFind("root.preGenerate: setting.PRIORITYCHECK_SYS_SET"), "preGenerate environment variables priority check is failed."); + assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_SET_DEP"), "preGenerate environment variables priority check is failed."); + assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_DEP_ROOT"), "preGenerate environment variables priority check is failed."); + assert(res.output.canFind("root.preGenerate: deppkg.PRIORITYCHECK_ROOT_DEPSPEC"), "preGenerate environment variables priority check is failed."); + assert(res.output.canFind("root.preGenerate: root.PRIORITYCHECK_DEPSPEC_ROOTSPEC"), "preGenerate environment variables priority check is failed."); + + // postGenerateCommands [in root] + assert(res.output.canFind("root.postGenerate: deppkg.VAR4", "postGenerate environment variables expantion check is failed.")); + + // preBuildCommands [in deppkg] + assert(res.output.canFind("deppkg.preBuild: deppkg.PRIORITYCHECK_ROOT_DEPBLDSPEC"), "preBuild environment variables priority check is failed."); + assert(res.output.canFind("deppkg.preBuild: root.PRIORITYCHECK_DEPBLDSPEC_ROOTBLDSPEC"), "preBuild environment variables priority check is failed."); + assert(res.output.canFind("deppkg.preBuild: deppkg.PRIORITYCHECK_ROOTBLDSPEC_DEPSPEC"), "preBuild environment variables priority check is failed."); + assert(res.output.canFind("deppkg.preBuild: root.PRIORITYCHECK_DEPSPEC_ROOTSPEC"), "preBuild environment variables priority check is failed."); + + // postBuildCommands [in deppkg] + assert(res.output.canFind("deppkg.postBuild: deppkg.VAR4"), "postBuild environment variables expantion check is failed."); + + // preRunCommands [in deppkg][in root] + assert(!res.output.canFind("deppkg.preRun: deppkg.VAR4"), "preRun that is defined dependent library does not call."); + assert(res.output.canFind("root.preRun: deppkg.VAR4"), "preRun environment variables expantion check is failed."); + + // Application run + assert(res.output.canFind("app.run: root.VAR1"), "run environment variables expantion check is failed."); + assert(res.output.canFind("app.run: settings.VAR2"), "run environment variables expantion check is failed."); + assert(res.output.canFind("app.run: root.VAR3"), "run environment variables expantion check is failed."); + assert(res.output.canFind("app.run: deppkg.VAR4"), "run environment variables expantion check is failed."); + assert(res.output.canFind("app.run: system.VAR5"), "run environment variables expantion check is failed."); + assert(res.output.canFind("app.run: system.SYSENVVAREXPCHECK"), "run environment variables expantion check is failed."); + + // postRunCommands [in deppkg][in root] + assert(!res.output.canFind("deppkg.postRun: deppkg.VAR4"), "postRunCommands that is defined dependent library does not call."); + assert(res.output.canFind("root.postRun: deppkg.VAR4"), "postRun environment variables expantion check is failed."); } diff --git a/test/expected-issue1037-output b/test/expected-issue1037-output deleted file mode 100644 index 2f1964705e..0000000000 --- a/test/expected-issue1037-output +++ /dev/null @@ -1,3 +0,0 @@ -Error Unresolvable dependencies to package gitcompatibledubpackage: - b @DIR/b depends on gitcompatibledubpackage ~>1.0.2 - issue1037-better-dependency-messages ~master depends on gitcompatibledubpackage 1.0.1 diff --git a/test/extra/.gitignore b/test/extra/.gitignore new file mode 100644 index 0000000000..7eb300fdb3 --- /dev/null +++ b/test/extra/.gitignore @@ -0,0 +1,7 @@ +* +!/*.d +!/*/ +!/*/dub.json +!/*/dub.sdl +!/*/source/ +!/*/.gitignore \ No newline at end of file diff --git a/test/1-sourceLib-simple/dub.json b/test/extra/1-sourceLib-simple/dub.json similarity index 100% rename from test/1-sourceLib-simple/dub.json rename to test/extra/1-sourceLib-simple/dub.json diff --git a/test/1-sourceLib-simple/source/sourcelib/app.d b/test/extra/1-sourceLib-simple/source/sourcelib/app.d similarity index 100% rename from test/1-sourceLib-simple/source/sourcelib/app.d rename to test/extra/1-sourceLib-simple/source/sourcelib/app.d diff --git a/test/extra/4-describe/.gitignore b/test/extra/4-describe/.gitignore new file mode 100644 index 0000000000..7f724941b1 --- /dev/null +++ b/test/extra/4-describe/.gitignore @@ -0,0 +1,5 @@ +!*/ +!*/dub.json +metadata_cache.json +/project/dummy-dep1.dat +/project/dummy.dat diff --git a/test/describe-dependency-1/data/dummy-dep1.dat b/test/extra/4-describe/dependency-1/data/dummy-dep1.dat similarity index 100% rename from test/describe-dependency-1/data/dummy-dep1.dat rename to test/extra/4-describe/dependency-1/data/dummy-dep1.dat diff --git a/test/describe-dependency-1/dependency-postGenerateCommands.sh b/test/extra/4-describe/dependency-1/dependency-postGenerateCommands.sh similarity index 100% rename from test/describe-dependency-1/dependency-postGenerateCommands.sh rename to test/extra/4-describe/dependency-1/dependency-postGenerateCommands.sh diff --git a/test/describe-dependency-1/dependency-preGenerateCommands.sh b/test/extra/4-describe/dependency-1/dependency-preGenerateCommands.sh similarity index 100% rename from test/describe-dependency-1/dependency-preGenerateCommands.sh rename to test/extra/4-describe/dependency-1/dependency-preGenerateCommands.sh diff --git a/test/describe-dependency-1/dub.json b/test/extra/4-describe/dependency-1/dub.json similarity index 65% rename from test/describe-dependency-1/dub.json rename to test/extra/4-describe/dependency-1/dub.json index 89e12cae44..daadec3f78 100644 --- a/test/describe-dependency-1/dub.json +++ b/test/extra/4-describe/dependency-1/dub.json @@ -14,10 +14,10 @@ "copyFiles": ["data/*"], "versions": ["anotherVerIdent"], "debugVersions": ["anotherDebugVerIdent"], - "preGenerateCommands-posix": ["../describe-dependency-1/dependency-preGenerateCommands.sh"], - "postGenerateCommands-posix": ["../describe-dependency-1/dependency-postGenerateCommands.sh"], - "preBuildCommands-posix": ["../describe-dependency-1/dependency-preBuildCommands.sh"], - "postBuildCommands-posix": ["../describe-dependency-1/dependency-postBuildCommands.sh"], + "preGenerateCommands-posix": ["../dependency-1/dependency-preGenerateCommands.sh"], + "postGenerateCommands-posix": ["../dependency-1/dependency-postGenerateCommands.sh"], + "preBuildCommands-posix": ["../dependency-1/dependency-preBuildCommands.sh"], + "postBuildCommands-posix": ["../dependency-1/dependency-postBuildCommands.sh"], "buildRequirements": ["requireContracts"], "buildOptions": ["stackStomping"], "configurations": [ diff --git a/test/describe-dependency-1/otherdir/dummy.d b/test/extra/4-describe/dependency-1/otherdir/dummy.d similarity index 100% rename from test/describe-dependency-1/otherdir/dummy.d rename to test/extra/4-describe/dependency-1/otherdir/dummy.d diff --git a/test/describe-dependency-1/source/dummy.d b/test/extra/4-describe/dependency-1/source/dummy.d similarity index 100% rename from test/describe-dependency-1/source/dummy.d rename to test/extra/4-describe/dependency-1/source/dummy.d diff --git a/test/describe-dependency-2/dub.json b/test/extra/4-describe/dependency-2/dub.json similarity index 100% rename from test/describe-dependency-2/dub.json rename to test/extra/4-describe/dependency-2/dub.json diff --git a/test/describe-dependency-2/some-extra-string-import-path/dummy.d b/test/extra/4-describe/dependency-2/some-extra-string-import-path/dummy.d similarity index 100% rename from test/describe-dependency-2/some-extra-string-import-path/dummy.d rename to test/extra/4-describe/dependency-2/some-extra-string-import-path/dummy.d diff --git a/test/describe-dependency-2/some-path/dummy.d b/test/extra/4-describe/dependency-2/some-path/dummy.d similarity index 100% rename from test/describe-dependency-2/some-path/dummy.d rename to test/extra/4-describe/dependency-2/some-path/dummy.d diff --git a/test/describe-dependency-3/dep3-source/dummy.d b/test/extra/4-describe/dependency-3/dep3-source/dummy.d similarity index 100% rename from test/describe-dependency-3/dep3-source/dummy.d rename to test/extra/4-describe/dependency-3/dep3-source/dummy.d diff --git a/test/describe-dependency-3/dep3-string-import-path/dummy.d b/test/extra/4-describe/dependency-3/dep3-string-import-path/dummy.d similarity index 100% rename from test/describe-dependency-3/dep3-string-import-path/dummy.d rename to test/extra/4-describe/dependency-3/dep3-string-import-path/dummy.d diff --git a/test/describe-dependency-3/dub.json b/test/extra/4-describe/dependency-3/dub.json similarity index 100% rename from test/describe-dependency-3/dub.json rename to test/extra/4-describe/dependency-3/dub.json diff --git a/test/describe-project/data/dummy.dat b/test/extra/4-describe/project/data/dummy.dat similarity index 100% rename from test/describe-project/data/dummy.dat rename to test/extra/4-describe/project/data/dummy.dat diff --git a/test/describe-project/do-postGenerateCommands.sh b/test/extra/4-describe/project/do-postGenerateCommands.sh similarity index 100% rename from test/describe-project/do-postGenerateCommands.sh rename to test/extra/4-describe/project/do-postGenerateCommands.sh diff --git a/test/describe-project/do-preGenerateCommands.sh b/test/extra/4-describe/project/do-preGenerateCommands.sh similarity index 100% rename from test/describe-project/do-preGenerateCommands.sh rename to test/extra/4-describe/project/do-preGenerateCommands.sh diff --git a/test/describe-project/dub.json b/test/extra/4-describe/project/dub.json similarity index 90% rename from test/describe-project/dub.json rename to test/extra/4-describe/project/dub.json index c52d085c41..a18f282819 100644 --- a/test/describe-project/dub.json +++ b/test/extra/4-describe/project/dub.json @@ -24,15 +24,15 @@ "dependencies": { "describe-dependency-1": { "version": "1.0", - "path": "../describe-dependency-1" + "path": "../dependency-1" }, "describe-dependency-2": { "version": "1.0", - "path": "../describe-dependency-2" + "path": "../dependency-2" }, "describe-dependency-3": { "version": "1.0", - "path": "../describe-dependency-3" + "path": "../dependency-3" } }, "configurations": [ diff --git a/test/describe-project/src/dummy.d b/test/extra/4-describe/project/src/dummy.d similarity index 100% rename from test/describe-project/src/dummy.d rename to test/extra/4-describe/project/src/dummy.d diff --git a/test/describe-project/views/dummy.d b/test/extra/4-describe/project/views/dummy.d similarity index 100% rename from test/describe-project/views/dummy.d rename to test/extra/4-describe/project/views/dummy.d diff --git a/test/extra/4-describe/test-utils/dub.json b/test/extra/4-describe/test-utils/dub.json new file mode 100644 index 0000000000..3448f7016f --- /dev/null +++ b/test/extra/4-describe/test-utils/dub.json @@ -0,0 +1,4 @@ +{ + "name": "describe-test-utils", + "targetType": "sourceLibrary" +} diff --git a/test/extra/4-describe/test-utils/source/describe_test_utils.d b/test/extra/4-describe/test-utils/source/describe_test_utils.d new file mode 100644 index 0000000000..b122af0930 --- /dev/null +++ b/test/extra/4-describe/test-utils/source/describe_test_utils.d @@ -0,0 +1,87 @@ +module describe_test_utils; + +void printDifference(const char[][] dubOutput, const char[][] expected) +{ + import std.stdio; + import std.algorithm; + import std.range; + import std.array; + + writefln(" dub vs us"); + foreach (it, us; lockstep(dubOutput, expected)) { + if (it == us) { + writefln("✅ '%s' vs '%s'", it, us); + } else { + writefln("❌ '%s' vs '%s'", it, us); + } + } + + const(const char[])[] extra; + if (dubOutput.length < expected.length) { + writeln("Dub output was cut short:"); + extra = expected[dubOutput.length .. $]; + } else if (dubOutput.length > expected.length) { + writeln("Dub output was too much:"); + extra = dubOutput[expected.length .. $]; + } + foreach (line; extra) + writeln(line); +} +inout(char[]) escape(inout char[] input) { + version(Posix) + immutable escapeChar = '\''; + else + immutable escapeChar = '"'; + + if (doEscape) + return escapeChar ~ input ~ escapeChar; + return input; +} + +version(Posix) { + immutable bool doEscape; + shared static this() { + import std.process; + import std.uni; + import std.file; + import std.algorithm; + import std.conv; + doEscape = __VERSION__ < 2103 || getcwd().any!isSpace; + } +} else + immutable bool doEscape = true; + +string myBuildPath (string[] segments...) { + import std.path; + // On windows: + // + // std.path.buildPath("c:\foo", "bar", "") + // => "c:\foo\bar" + // + // but we want "c:\foo\bar\" + auto result = buildPath(segments); + if (segments[$ - 1] == "") + result ~= dirSeparator; + return result; +} + +string libName(string base) { + version(Posix) + return "lib" ~ base ~ ".a"; + else + return base ~ ".lib"; +} + +string libSuffix() { + version(Posix) + return ".a"; + else + return ".lib"; +} + +string fixWindowsCR(string line) { + // FIXME: dub listing output contains \r\r\n instead of \r\n on windows + while (line.length && line[$ - 1] == '\r') + line = line[0 .. $ - 1]; + return line; +} diff --git a/test/extra/issue1336-registry/.gitignore b/test/extra/issue1336-registry/.gitignore new file mode 100644 index 0000000000..da495fc466 --- /dev/null +++ b/test/extra/issue1336-registry/.gitignore @@ -0,0 +1,4 @@ +!/api/ +!/api/** +!/packages/ +!/packages/** \ No newline at end of file diff --git a/test/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true b/test/extra/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true similarity index 100% rename from test/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true rename to test/extra/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true diff --git a/test/issue1336-registry/packages/gitcompatibledubpackage/1.0.2.zip b/test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.2.zip similarity index 100% rename from test/issue1336-registry/packages/gitcompatibledubpackage/1.0.2.zip rename to test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.2.zip diff --git a/test/issue1336-registry/packages/gitcompatibledubpackage/1.0.3.zip b/test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.3.zip similarity index 100% rename from test/issue1336-registry/packages/gitcompatibledubpackage/1.0.3.zip rename to test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.3.zip diff --git a/test/issue1336-registry/packages/gitcompatibledubpackage/1.0.4.zip b/test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.4.zip similarity index 100% rename from test/issue1336-registry/packages/gitcompatibledubpackage/1.0.4.zip rename to test/extra/issue1336-registry/packages/gitcompatibledubpackage/1.0.4.zip diff --git a/test/extra/issue1416-maven-repo-pkg-supplier/.gitignore b/test/extra/issue1416-maven-repo-pkg-supplier/.gitignore new file mode 100644 index 0000000000..d3de5a3391 --- /dev/null +++ b/test/extra/issue1416-maven-repo-pkg-supplier/.gitignore @@ -0,0 +1,2 @@ +!/maven/ +!/maven/** diff --git a/test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.5/maven-dubpackage-1.0.5.zip b/test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.5/maven-dubpackage-1.0.5.zip similarity index 100% rename from test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.5/maven-dubpackage-1.0.5.zip rename to test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.5/maven-dubpackage-1.0.5.zip diff --git a/test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.6/maven-dubpackage-1.0.6.zip b/test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.6/maven-dubpackage-1.0.6.zip similarity index 100% rename from test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.6/maven-dubpackage-1.0.6.zip rename to test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/1.0.6/maven-dubpackage-1.0.6.zip diff --git a/test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/maven-metadata.xml b/test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/maven-metadata.xml similarity index 100% rename from test/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/maven-metadata.xml rename to test/extra/issue1416-maven-repo-pkg-supplier/maven/release/dubpackages/maven-dubpackage/maven-metadata.xml diff --git a/test/extra/test_registry/.gitignore b/test/extra/test_registry/.gitignore new file mode 100644 index 0000000000..0c4c3c4aa2 --- /dev/null +++ b/test/extra/test_registry/.gitignore @@ -0,0 +1,3 @@ +!/source/ +!/source/*.d +!/test_registry.d diff --git a/test/extra/test_registry/dub.json b/test/extra/test_registry/dub.json new file mode 100644 index 0000000000..b71c03056f --- /dev/null +++ b/test/extra/test_registry/dub.json @@ -0,0 +1,3 @@ +{ + "name": "test_registry_helper" +} diff --git a/test/extra/test_registry/source/test_registry_helper.d b/test/extra/test_registry/source/test_registry_helper.d new file mode 100644 index 0000000000..2665558647 --- /dev/null +++ b/test/extra/test_registry/source/test_registry_helper.d @@ -0,0 +1,54 @@ +module test_registry_helper; + +import std.process; +import std.stdio; + +struct TestRegistry { + immutable string port; + + this(string folder) { + import std.path; + import std.conv; + + immutable dir = __FILE_FULL_PATH__.dirName.dirName; + immutable testRegistrySrc = dir.buildPath("test_registry.d"); + immutable testRegistryExe = dir.buildPath("test_registry"); + immutable dub = environment["DUB"]; + // A path independent of the current test's dubHome + immutable newDubHome = dir.buildPath("dub"); + + auto p = spawnProcess( + [dub, "build", "--single", testRegistrySrc], + ["DUB_HOME": newDubHome] + ); + if (p.wait != 0) { + writeln("[FAIL]: dub build test_registry failed"); + throw new Exception("dub build test_registry failed"); + } + + this.port = text(getRandomPort); + this.pid = spawnProcess([testRegistryExe, "--folder=" ~ folder, "--port=" ~ port]); + + import core.time; + import core.thread.osthread; + Thread.sleep(1.seconds); + } + + ~this() { + scope(exit) wait(this.pid); + try { + writeln("--- The next few lines are test_registry shutting down, don't worry about them"); + stdout.flush(); + kill(this.pid); + } catch (ProcessException) {} + } + +private: + Pid pid; + static ushort getRandomPort() { + ushort result = cast(ushort)(thisProcessID % ushort.max); + if (result < 1024) + result += 1025; + return result; + } +} diff --git a/test/test_registry.d b/test/extra/test_registry/test_registry.d similarity index 97% rename from test/test_registry.d rename to test/extra/test_registry/test_registry.d index 6e98466028..fdb1920110 100755 --- a/test/test_registry.d +++ b/test/extra/test_registry/test_registry.d @@ -34,7 +34,7 @@ auto apiFileHandler(string skip, string folder) { requestURI.skipOver(skip); const reqFile = buildPath(folder, requestURI); if (reqFile.exists) { - return req.sendFile(res, PosixPath(reqFile)); + return req.sendFile(res, NativePath(reqFile)); } } return toDelegate(&handler); diff --git a/test/feat663-search.sh b/test/feat663-search.sh deleted file mode 100755 index 77289a688e..0000000000 --- a/test/feat663-search.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -if ${DUB} search 2>/dev/null; then - die $LINENO '`dub search` succeeded' -fi -if ${DUB} search nonexistent123456789package 2>/dev/null; then - die $LINENO '`dub search nonexistent123456789package` succeeded' -fi -if ! OUTPUT=$(${DUB} search '"dub-registry"' -v 2>&1); then - die $LINENO '`dub search "dub-registry"` failed' "$OUTPUT" -fi -if ! grep -q '^\s\sdub-registry (.*)\s'<<<"$OUTPUT"; then - die $LINENO '`grep -q '"'"'^\s\sdub-registry (.*)\s'"'"'` failed' "$OUTPUT" -fi diff --git a/test/feat663-search/dub.json b/test/feat663-search/dub.json new file mode 100644 index 0000000000..280e83c616 --- /dev/null +++ b/test/feat663-search/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-feat663-search", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/feat663-search/source/app.d b/test/feat663-search/source/app.d new file mode 100644 index 0000000000..4cdceef4c9 --- /dev/null +++ b/test/feat663-search/source/app.d @@ -0,0 +1,47 @@ +import common; + +import std.algorithm; +import std.array; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + { + auto p = execute([dub, "search"]); + if (p.status == 0) + die("`dub search` succeeded"); + } + + { + auto p = execute([dub, "search", "nonexistent123456789package"]); + if (p.status == 0) + die("`dub search nonexistent123456789package` succeeded"); + } + + { + auto p = pipeProcess([dub, "search", `"dub-registry"`], Redirect.stdout | Redirect.stderrToStdout); + const output = p.stdout.byLineCopy.array; + + if (p.pid.wait != 0) { + immutable error = q"(`dub search "dub-registry"` failed)"; + writeln(error); + writeln("Output:"); + foreach (line; output) + writeln(line); + die(error); + } + + import std.regex; + auto r = regex(`^\s\sdub-registry \(.*\)\s`); + if (!output.any!(line => line.matchFirst(r))) { + immutable error = q"(`dub search "dub-registry"` did not contain the desired line)"; + writeln(error); + writeln("Output:"); + foreach (line; output) + writeln(line); + die(error); + } + } +} diff --git a/test/fetchzip.sh b/test/fetchzip.sh deleted file mode 100755 index d5917d4f1b..0000000000 --- a/test/fetchzip.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -PORT=$(getRandomPort) - -${DUB} remove gitcompatibledubpackage --non-interactive 2>/dev/null || true - -${DUB} build --single "$DIR"/test_registry.d -"$DIR"/test_registry --folder="$DIR/issue1336-registry" --port=$PORT & -PID=$! -sleep 1 -trap 'kill $PID 2>/dev/null || true' exit - -echo "Trying to download gitcompatibledubpackage (1.0.4)" -timeout 1s ${DUB} fetch gitcompatibledubpackage@1.0.4 --skip-registry=all --registry=http://localhost:$PORT -if [ $? -eq 124 ]; then - die $LINENO 'Fetching from responsive registry should not time-out.' -fi -${DUB} remove gitcompatibledubpackage@1.0.4 - -echo "Downloads should be retried when the zip is corrupted - gitcompatibledubpackage (1.0.3)" -zipOut=$(! timeout 1s ${DUB} fetch gitcompatibledubpackage@1.0.3 --skip-registry=all --registry=http://localhost:$PORT 2>&1) -rc=$? - -if ! zipCount=$(grep -Fc 'Failed to extract zip archive' <<<"$zipOut") || [ "$zipCount" -lt 3 ] ; then - echo '========== +Output was ==========' >&2 - echo "$zipOut" >&2 - echo '========== -Output was ==========' >&2 - die $LINENO 'DUB should have tried to download the zip archive multiple times.' -elif [ $rc -eq 124 ]; then - die $LINENO 'DUB timed out unexpectedly.' -fi -if ${DUB} remove gitcompatibledubpackage --non-interactive 2>/dev/null; then - die $LINENO 'DUB should not have installed a broken package.' -fi - -echo "HTTP status errors on downloads should be retried - gitcompatibledubpackage (1.0.2)" -retryOut=$(! timeout 1s ${DUB} fetch gitcompatibledubpackage@1.0.2 --skip-registry=all --registry=http://localhost:$PORT --vverbose 2>&1) -rc=$? -if ! retryCount=$(echo "$retryOut" | grep -Fc 'Bad Gateway') || [ "$retryCount" -lt 3 ] ; then - echo '========== +Output was ==========' >&2 - echo "$retryOut" >&2 - echo '========== -Output was ==========' >&2 - die $LINENO "DUB should have retried download on server error multiple times, but only tried $retryCount times." -elif [ $rc -eq 124 ]; then - die $LINENO 'DUB timed out unexpectedly.' -fi -if ${DUB} remove gitcompatibledubpackage --non-interactive 2>/dev/null; then - die $LINENO 'DUB should not have installed a package.' -fi - -echo "HTTP status errors on downloads should retry with fallback mirror - gitcompatibledubpackage (1.0.2)" -timeout 1s "$DUB" fetch gitcompatibledubpackage@1.0.2 --skip-registry=all --registry="http://localhost:$PORT http://localhost:$PORT/fallback" -if [ $? -eq 124 ]; then - die $LINENO 'Fetching from responsive registry should not time-out.' -fi -${DUB} remove gitcompatibledubpackage@1.0.2 diff --git a/test/fetchzip.sh.min_frontend b/test/fetchzip.sh.min_frontend deleted file mode 100644 index 4817f99644..0000000000 --- a/test/fetchzip.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.077 diff --git a/test/fetchzip/dub.json b/test/fetchzip/dub.json new file mode 100644 index 0000000000..d168630ec3 --- /dev/null +++ b/test/fetchzip/dub.json @@ -0,0 +1,12 @@ +{ + "name": "test-fetchzip", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + }, + "test_registry_helper": { + "path": "../extra/test_registry" + } + } +} diff --git a/test/fetchzip/source/app.d b/test/fetchzip/source/app.d new file mode 100644 index 0000000000..90aa4c5e13 --- /dev/null +++ b/test/fetchzip/source/app.d @@ -0,0 +1,122 @@ +import common; +import test_registry_helper; + +import core.time; +import core.thread.osthread; +import std.array; +import std.conv; +import std.file; +import std.format; +import std.process; +import std.path; +import std.range; +import std.regex; +import std.stdio; + +void main () { + auto testRegistry = TestRegistry("../extra/issue1336-registry"); + immutable port = testRegistry.port; + + // ignore failure + execute([dub, "remove", "gitcompatibledubpackage", "--non-interactive"]); + + immutable registryArgs = [ + "--skip-registry=all", + "--registry=http://localhost:" ~ text(port), + ]; + + log("Trying to download gitcompatibledubpackage (1.0.4)"); + { + auto pid = spawnProcess([dub, "fetch", "gitcompatibledubpackage@1.0.4"] ~ registryArgs); + scope(exit) pid.wait; + + // no waitTimeout function for non-windows :( + Thread.sleep(timeoutDuration); + auto r = pid.tryWait; + if (!r.terminated) + die("Fetching from responsive registry should not time-out."); + if (r.status != 0) + die("Dub fetch failed"); + + if (spawnProcess([dub, "remove", "gitcompatibledubpackage@1.0.4"]).wait != 0) + die("Dub remove failed"); + } + + log("Downloads should be retried when the zip is corrupted - gitcompatibledubpackage (1.0.3)"); + { + auto p = teeProcess([dub, "fetch", "gitcompatibledubpackage@1.0.3"] ~ registryArgs, + Redirect.stdout | Redirect.stderrToStdout); + scope(exit) p.pid.wait; + + Thread.sleep(timeoutDuration); + auto r = p.pid.tryWait; + if (!r.terminated) + die("Dub timed out unexpectedly"); + + const output = p.stdout; + auto needle = regex(`Failed to extract zip archive`); + auto matches = matchAll(output, needle); + if (matches.walkLength < 3) { + writeln("========== +Output was =========="); + writeln(output); + writeln("========== -Output was =========="); + die("Dub should have retried to download the zip archive multiple times."); + } + + if (execute([dub, "remove", "gitcompatibledubpackage", "--non-interactive"]).status == 0) { + die("Dub should not have installed a broken package"); + } + } + + log("HTTP status errors on downloads should be retried - gitcompatibledubpackage (1.0.2)"); + { + auto p = teeProcess([dub, "fetch", "gitcompatibledubpackage@1.0.2", "--vverbose"] ~ registryArgs, + Redirect.stdout | Redirect.stderrToStdout); + scope(exit) p.pid.wait; + + Thread.sleep(timeoutDuration); + auto r = p.pid.tryWait; + if (!r.terminated) + die("Dub timed out unexpectedly"); + + const output = p.stdout; + auto needle = regex(`Bad Gateway`); + auto matches = matchAll(output, needle); + if (matches.walkLength < 3) { + writeln("========== +Output was =========="); + writeln(output); + writeln("========== -Output was =========="); + die("Dub should have retried to download the zip archive multiple times."); + } + + if (execute([dub, "remove", "gitcompatibledubpackage", "--non-interactive"]).status == 0) { + die("Dub should not have installed a broken package"); + } + } + + version(Posix) { + log("HTTP status errors on downloads should retry with fallback mirror - gitcompatibledubpackage (1.0.2)"); + { + auto p = spawnProcess([ + dub, "fetch", "gitcompatibledubpackage@1.0.2", "--vverbose", + "--skip-registry=all", + format("--registry=http://localhost:%1$s http://localhost:%1$s/fallback", port), + ]); + scope(exit) p.wait; + + Thread.sleep(timeoutDuration); + auto r = p.tryWait; + if (!r.terminated) + die("Fetching from responsive registry should not time-out."); + if (r.status != 0) + die("Dub fetch should have succeeded"); + + if (spawnProcess([dub, "remove", "gitcompatibledubpackage@1.0.2"]).wait != 0) + die("Dub should have installed the package"); + } + } + + log("Test success"); +} + +immutable timeoutDuration = 1.seconds; diff --git a/test/fetchzip/test.config b/test/fetchzip/test.config new file mode 100644 index 0000000000..067843f6dc --- /dev/null +++ b/test/fetchzip/test.config @@ -0,0 +1,3 @@ +locks = test_registry +# openssl failes to build with gdmd +dc_backend = [dmd, ldc] diff --git a/test/filesystem-version-with-buildinfo.sh b/test/filesystem-version-with-buildinfo.sh deleted file mode 100755 index a9e24b1904..0000000000 --- a/test/filesystem-version-with-buildinfo.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -${DUB} remove fs-json-dubpackage --non-interactive 2>/dev/null || true - -echo "Trying to get fs-json-dubpackage (1.0.7)" -${DUB} fetch fs-json-dubpackage@1.0.7 --skip-registry=all --registry=file://"$DIR"/filesystem-version-with-buildinfo - -if ! ${DUB} remove fs-json-dubpackage@1.0.7 2>/dev/null; then - die $LINENO 'DUB did not install package from file system.' -fi diff --git a/test/filesystem-version-with-buildinfo/.gitignore b/test/filesystem-version-with-buildinfo/.gitignore new file mode 100644 index 0000000000..84af1f6848 --- /dev/null +++ b/test/filesystem-version-with-buildinfo/.gitignore @@ -0,0 +1,2 @@ +!/file-registry +!/file-registry/* \ No newline at end of file diff --git a/test/filesystem-version-with-buildinfo/.no_build b/test/filesystem-version-with-buildinfo/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/filesystem-version-with-buildinfo/dub.json b/test/filesystem-version-with-buildinfo/dub.json new file mode 100644 index 0000000000..1f524b210d --- /dev/null +++ b/test/filesystem-version-with-buildinfo/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-filesystem-version-with-buildinfo", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/filesystem-version-with-buildinfo/fs-json-dubpackage-1.0.7+build-9-9-9.zip b/test/filesystem-version-with-buildinfo/file-registry/fs-json-dubpackage-1.0.7+build-9-9-9.zip similarity index 100% rename from test/filesystem-version-with-buildinfo/fs-json-dubpackage-1.0.7+build-9-9-9.zip rename to test/filesystem-version-with-buildinfo/file-registry/fs-json-dubpackage-1.0.7+build-9-9-9.zip diff --git a/test/filesystem-version-with-buildinfo/source/app.d b/test/filesystem-version-with-buildinfo/source/app.d new file mode 100644 index 0000000000..d732b11938 --- /dev/null +++ b/test/filesystem-version-with-buildinfo/source/app.d @@ -0,0 +1,25 @@ +import common; + +import std.process; +import std.file; +import std.path; + +void main () { + // Ignore errors + execute([dub, "remove", "fs-json-dubpackage", "--non-interactive"]); + + log("Trying to get fs-json-dubpackage (1.0.7)"); + { + auto p = spawnProcess( + [dub, "fetch", "fs-json-dubpackage@1.0.7", "--skip-registry=all", "--registry=file://" ~ getcwd.buildPath("file-registry")] + ); + if (p.wait != 0) + die("Dub fetch failed"); + } + + { + auto p = execute([dub, "remove", "fs-json-dubpackage@1.0.7"]); + if (p.status != 0) + die("Dub did not install package from file system."); + } +} diff --git a/test/frameworks.sh b/test/frameworks.sh deleted file mode 100755 index 589d4abb85..0000000000 --- a/test/frameworks.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -if [[ "$OSTYPE" == "darwin"* ]]; then - . $(dirname "${BASH_SOURCE[0]}")/common.sh - - cd ${CURR_DIR}/frameworks - rm -rf .dub - rm -rf out/ - - ${DUB} build -fi \ No newline at end of file diff --git a/test/frameworks/.no_build b/test/frameworks/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/frameworks/.no_run b/test/frameworks/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/frameworks/dub.sdl b/test/frameworks/dub.sdl index ca38cc035d..7ae7ff83b5 100644 --- a/test/frameworks/dub.sdl +++ b/test/frameworks/dub.sdl @@ -5,6 +5,7 @@ configuration "osx" { platforms "osx" frameworks "Foundation" + targetType "executable" } configuration "other" { diff --git a/test/frameworks/test.config b/test/frameworks/test.config new file mode 100644 index 0000000000..0d3463eab3 --- /dev/null +++ b/test/frameworks/test.config @@ -0,0 +1,2 @@ +os = osx +dub_command = build diff --git a/test/git-dependency/.gitignore b/test/git-dependency/.gitignore new file mode 100644 index 0000000000..384434d079 --- /dev/null +++ b/test/git-dependency/.gitignore @@ -0,0 +1 @@ +!/src/ \ No newline at end of file diff --git a/test/help.sh b/test/help.sh deleted file mode 100755 index 8d56f790e5..0000000000 --- a/test/help.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -### It shows the general help message -if ! { ${DUB} help | grep "Manages the DUB project in the current directory."; } then - die $LINENO 'DUB did not print the default help message, with the `help` command.' -fi - -if ! { ${DUB} -h | grep "Manages the DUB project in the current directory."; } then - die $LINENO 'DUB did not print the default help message, with the `-h` argument.' -fi - -if ! { ${DUB} --help | grep "Manages the DUB project in the current directory."; } then - die $LINENO 'DUB did not print the default help message, with the `--help` argument.' -fi - -### It shows the build command help -if ! { ${DUB} build -h | grep "Builds a package"; } then - die $LINENO 'DUB did not print the build help message, with the `-h` argument.' -fi - -if ! { ${DUB} build --help | grep "Builds a package"; } then - die $LINENO 'DUB did not print the build help message, with the `--help` argument.' -fi diff --git a/test/help/dub.json b/test/help/dub.json new file mode 100644 index 0000000000..ade74597c1 --- /dev/null +++ b/test/help/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-help", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/help/source/app.d b/test/help/source/app.d new file mode 100644 index 0000000000..13f0e90336 --- /dev/null +++ b/test/help/source/app.d @@ -0,0 +1,48 @@ +import common; + +import std.process; +import std.file; +import std.path; +import std.stdio; + +void main () { + // It shows the general help message + runTestCase( + ["help"], + "Manages the DUB project in the current directory.", + "DUB did not print the default help message, with the `help` command.", + ); + + runTestCase( + ["-h"], + "Manages the DUB project in the current directory.", + "DUB did not print the default help message, with the `-h` argument.", + ); + runTestCase( + ["--help"], + "Manages the DUB project in the current directory.", + "DUB did not print the default help message, with the `--help` argument.", + ); + + // It shows the build command help + runTestCase( + ["build", "-h"], + "Builds a package", + "DUB did not print the build help message, with the `-h` argument.", + ); + runTestCase( + ["build", "--help"], + "Builds a package", + "DUB did not print the build help message, with the `--help` argument.", + ); +} + +void runTestCase(string[] args, string needle, string error) { + auto p = execute(dub ~ args); + if (p.status != 0) + die("Dub failed to run"); + + import std.algorithm.searching; + if (!p.output.canFind(needle)) + die(error); +} diff --git a/test/ignore-hidden-1/.gitignore b/test/ignore-hidden-1/.gitignore index 433d26664a..7c3ddf2665 100644 --- a/test/ignore-hidden-1/.gitignore +++ b/test/ignore-hidden-1/.gitignore @@ -1,5 +1 @@ -.dub -docs.json -__dummy.html -*.o -*.obj +!/source/.hidden.d diff --git a/test/ignore-hidden-1/.no_run b/test/ignore-hidden-1/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ignore-hidden-1/.no_test b/test/ignore-hidden-1/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ignore-hidden-1/test.config b/test/ignore-hidden-1/test.config new file mode 100644 index 0000000000..32efffa32d --- /dev/null +++ b/test/ignore-hidden-1/test.config @@ -0,0 +1 @@ +dub_command = build diff --git a/test/ignore-hidden-2/.gitignore b/test/ignore-hidden-2/.gitignore index 433d26664a..7c3ddf2665 100644 --- a/test/ignore-hidden-2/.gitignore +++ b/test/ignore-hidden-2/.gitignore @@ -1,5 +1 @@ -.dub -docs.json -__dummy.html -*.o -*.obj +!/source/.hidden.d diff --git a/test/ignore-hidden-2/.no_run b/test/ignore-hidden-2/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ignore-hidden-2/.no_test b/test/ignore-hidden-2/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ignore-hidden-2/test.config b/test/ignore-hidden-2/test.config new file mode 100644 index 0000000000..32efffa32d --- /dev/null +++ b/test/ignore-hidden-2/test.config @@ -0,0 +1 @@ +dub_command = build diff --git a/test/ignore-useless-arch-switch/.no_test b/test/ignore-useless-arch-switch/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/ignore-useless-arch-switch/dub.sdl b/test/ignore-useless-arch-switch/dub.sdl index 919a41f950..48a53c70e8 100644 --- a/test/ignore-useless-arch-switch/dub.sdl +++ b/test/ignore-useless-arch-switch/dub.sdl @@ -1,2 +1,3 @@ name "ignore-useless-arch-switch" targetType "executable" +dependency "common" path="../common" diff --git a/test/ignore-useless-arch-switch/source/app.d b/test/ignore-useless-arch-switch/source/app.d index b48449c7db..08f7d466f3 100644 --- a/test/ignore-useless-arch-switch/source/app.d +++ b/test/ignore-useless-arch-switch/source/app.d @@ -1,13 +1,16 @@ +import common; + import std.json; import std.path; import std.process; -import std.stdio; -string getCacheFile (in string[] program) { - auto p = execute(program); +string getCacheFile (in string[] args) { + auto p = execute([dub, "describe"] ~ args); with (p) { if (status != 0) { - assert(false, "Failed to invoke dub describe: " ~ output); + log("dub describe failed. Output:"); + log(output); + die("Failed to invoke dub describe"); } return output.parseJSON["targets"][0]["cacheArtifactPath"].str; } @@ -21,20 +24,12 @@ void main() string archArg = "x86"; else { string archArg; - writeln("Skipping because of unsupported architecture"); - return; + skip("Unsupported architecture"); } - const describeProgram = [ - environment["DUB"], - "describe", - "--compiler=" ~ environment["DC"], - "--root=" ~ __FILE_FULL_PATH__.dirName.dirName, - ]; - immutable plainCacheFile = describeProgram.getCacheFile; - - const describeWithArch = describeProgram ~ [ "--arch=" ~ archArg ]; - immutable archCacheFile = describeWithArch.getCacheFile; + immutable plainCacheFile = getCacheFile([]); + immutable archCacheFile = getCacheFile(["--arch=" ~ archArg]); - assert(plainCacheFile == archCacheFile, "--arch shouldn't have modified the cache file"); + if (plainCacheFile != archCacheFile) + die("--arch shouldn't have modified the cache file"); } diff --git a/test/injected-from-dependency/.gitignore b/test/injected-from-dependency/.gitignore new file mode 100644 index 0000000000..e28c6574a7 --- /dev/null +++ b/test/injected-from-dependency/.gitignore @@ -0,0 +1,2 @@ +!/*.d +!/toload/ diff --git a/test/injected-from-dependency/.no_test b/test/injected-from-dependency/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/interactive-remove.sh b/test/interactive-remove.sh deleted file mode 100755 index dfe1a9431c..0000000000 --- a/test/interactive-remove.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -# This test messes with the user's package directory -# Hence it's a pretty bad test, but we need it. -# Ideally, we should not have this run by default / run it in a container. -# In the meantime, in order to make it pass on developer's machines, -# we need to nuke every `dub` version in the user cache... -$DUB remove dub -n || true -DUBPKGPATH=${DPATH+"$DPATH/dub/packages/dub"} -DUBPKGPATH=${DUBPKGPATH:-"$HOME/.dub/packages/dub"} - -$DUB fetch dub@1.9.0 && [ -d $DUBPKGPATH/1.9.0/dub ] -$DUB fetch dub@1.10.0 && [ -d $DUBPKGPATH/1.10.0/dub ] - -echo 1 | $DUB remove dub | tr -d '\n' | grep --ignore-case 'select.*1\.9\.0.*1\.10\.0.*' -if [ -d $DUBPKGPATH/1.9.0/dub ]; then - die $LINENO 'Failed to remove dub-1.9.0' -fi - -$DUB fetch dub@1.9.0 && [ -d $DUBPKGPATH/1.9.0/dub ] -# EOF aborts remove -echo -xn '' | $DUB remove dub -if [ ! -d $DUBPKGPATH/1.9.0/dub ] || [ ! -d $DUBPKGPATH/1.10.0/dub ]; then - die $LINENO 'Aborted dub still removed a package' -fi - -# validates input -echo -e 'abc\n4\n-1\n3' | $DUB remove dub -if [ -d $DUBPKGPATH/1.9.0/dub ] || [ -d $DUBPKGPATH/1.10.0/dub ]; then - die $LINENO 'Failed to remove all version of dub' -fi - -$DUB fetch dub@1.9.0 && [ -d $DUBPKGPATH/1.9.0/dub ] -$DUB fetch dub@1.10.0 && [ -d $DUBPKGPATH/1.10.0/dub ] -# is non-interactive with a -$DUB remove dub@1.9.0 -$DUB remove dub@1.10.0 -if [ -d $DUBPKGPATH/1.9.0/dub ] || [ -d $DUBPKGPATH/1.10.0/dub ]; then - die $LINENO 'Failed to non-interactively remove specified versions' -fi diff --git a/test/interactive-remove/dub.json b/test/interactive-remove/dub.json new file mode 100644 index 0000000000..32b7ad72d9 --- /dev/null +++ b/test/interactive-remove/dub.json @@ -0,0 +1,8 @@ +{ + "name": "test-interactive-remove", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/interactive-remove/source/app.d b/test/interactive-remove/source/app.d new file mode 100644 index 0000000000..bc779dea70 --- /dev/null +++ b/test/interactive-remove/source/app.d @@ -0,0 +1,98 @@ +import common; + +import std.array; +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.regex; +import std.string; +import std.stdio; + +string pkgDir; + +void main () { + pkgDir = dubHome.buildPath("packages", "dub"); + + // Nuke existing dir + if (dubHome.exists) dubHome.rmdirRecurse(); + + fetchDub("1.9.0"); + fetchDub("1.10.0"); + + { + auto p = pipeProcess([dub, "remove", "dub"]); + scope(exit) p.pid.wait; + p.stdin.writeln(1); + p.stdin.close(); + + const output = p.stdout.byLineCopy.join('\n'); + p.pid.wait; + + auto r = regex(`select.*1\.9\.0.*1\.10\.0`, "is"); + if (!output.matchFirst(r)) { + writeln("Dub didn't print the menu correctly. Output:"); + writeln(output); + die("unrecognized dub remove dialog"); + } + + if (existsDubDir("1.9.0")) + die("Failed to remove dub-1.9.0"); + } + + { + fetchDub("1.9.0"); + + // EOF abort remove + auto p = pipeProcess([dub, "remove", "dub"], Redirect.stdin); + scope(exit) p.pid.wait; + p.stdin.close(); + p.pid.wait; + + if (!existsDubDir("1.9.0") || !existsDubDir("1.10.0")) + die("Aborted dub still removed a package"); + } + + { + // validate input + auto p = pipeProcess([dub, "remove", "dub"], Redirect.stdin); + scope(exit) p.pid.wait; + p.stdin.writeln("abc"); + p.stdin.writeln("4"); + p.stdin.writeln("-1"); + p.stdin.write("3"); + p.stdin.close(); + p.pid.wait; + + if (existsDubDir("1.9.0") || existsDubDir("1.10.0")) + die("Failed to remove all version of dub"); + } + + fetchDub("1.9.0"); + fetchDub("1.10.0"); + { + // is non-interactive with a + foreach (ver; ["1.9.0", "1.10.0"]) + if (spawnProcess([dub, "remove", "dub@" ~ ver]).wait != 0) + die("Dub failed to remove version ", ver); + + foreach (ver; ["1.9.0", "1.10.0"]) + if (existsDubDir(ver)) + die("Failed to non-interactively remove specified versions"); + } +} + +bool existsDubDir(const(char)[] ver) { + immutable path = pkgDir.buildPath(ver, "dub"); + return path.exists && path.isDir; +} + +void fetchDub(string dubVer) { + if (spawnProcess([dub, "fetch", "dub@" ~ dubVer]).wait != 0) + die("Dub fetch failed"); + + if (!existsDubDir(dubVer)) { + writeln(pkgDir.buildPath(dubVer, "dub")); + die("Dub did not create the expected ", dubVer, " dir"); + } +} diff --git a/test/issue1003-check-empty-ld-flags.sh b/test/issue1003-check-empty-ld-flags.sh deleted file mode 100755 index 61678f720b..0000000000 --- a/test/issue1003-check-empty-ld-flags.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/issue1003-check-empty-ld-flags - -${DUB} build --compiler=${DC} --force diff --git a/test/issue1003-check-empty-ld-flags/test.config b/test/issue1003-check-empty-ld-flags/test.config new file mode 100644 index 0000000000..32efffa32d --- /dev/null +++ b/test/issue1003-check-empty-ld-flags/test.config @@ -0,0 +1 @@ +dub_command = build diff --git a/test/issue1004-override-config.sh b/test/issue1004-override-config.sh deleted file mode 100755 index 96080f18b3..0000000000 --- a/test/issue1004-override-config.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1004-override-config -${DUB} build --bare main --override-config a/success diff --git a/test/issue1004-override-config/.gitignore b/test/issue1004-override-config/.gitignore new file mode 100644 index 0000000000..290ddbb4d6 --- /dev/null +++ b/test/issue1004-override-config/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/a/a.d +!/sample/a/dub.sdl +!/sample/main/ +!/sample/main/source/main.d +!/sample/main/dub.sdl diff --git a/test/issue1004-override-config/.no_build b/test/issue1004-override-config/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1004-override-config/dub.json b/test/issue1004-override-config/dub.json new file mode 100644 index 0000000000..8d8dbbb067 --- /dev/null +++ b/test/issue1004-override-config/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1004-override-config", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1004-override-config/a/a.d b/test/issue1004-override-config/sample/a/a.d similarity index 100% rename from test/issue1004-override-config/a/a.d rename to test/issue1004-override-config/sample/a/a.d diff --git a/test/issue1004-override-config/a/dub.sdl b/test/issue1004-override-config/sample/a/dub.sdl similarity index 100% rename from test/issue1004-override-config/a/dub.sdl rename to test/issue1004-override-config/sample/a/dub.sdl diff --git a/test/issue1004-override-config/main/dub.sdl b/test/issue1004-override-config/sample/main/dub.sdl similarity index 100% rename from test/issue1004-override-config/main/dub.sdl rename to test/issue1004-override-config/sample/main/dub.sdl diff --git a/test/issue1004-override-config/main/source/main.d b/test/issue1004-override-config/sample/main/source/main.d similarity index 100% rename from test/issue1004-override-config/main/source/main.d rename to test/issue1004-override-config/sample/main/source/main.d diff --git a/test/issue1004-override-config/source/app.d b/test/issue1004-override-config/source/app.d new file mode 100644 index 0000000000..0363667bb6 --- /dev/null +++ b/test/issue1004-override-config/source/app.d @@ -0,0 +1,11 @@ +import common; + +import std.process; + +void main () { + auto p = spawnProcess( + [dub, "build", "--bare", "main", "--override-config", "a/success"], null, Config.none, "sample"); + + if (p.wait != 0) + die("Dub build failed"); +} diff --git a/test/issue1005-configuration-resolution.sh b/test/issue1005-configuration-resolution.sh deleted file mode 100755 index 1233e76df2..0000000000 --- a/test/issue1005-configuration-resolution.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1005-configuration-resolution -${DUB} build --bare main diff --git a/test/issue1005-configuration-resolution/.gitignore b/test/issue1005-configuration-resolution/.gitignore new file mode 100644 index 0000000000..30c3d35390 --- /dev/null +++ b/test/issue1005-configuration-resolution/.gitignore @@ -0,0 +1,6 @@ +/sample/** +!/sample/ +!/sample/*/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/* diff --git a/test/issue1005-configuration-resolution/.no_build b/test/issue1005-configuration-resolution/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1005-configuration-resolution/dub.json b/test/issue1005-configuration-resolution/dub.json new file mode 100644 index 0000000000..d89beb2462 --- /dev/null +++ b/test/issue1005-configuration-resolution/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1005-configuration-resolution", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1005-configuration-resolution/a/dub.sdl b/test/issue1005-configuration-resolution/sample/a/dub.sdl similarity index 100% rename from test/issue1005-configuration-resolution/a/dub.sdl rename to test/issue1005-configuration-resolution/sample/a/dub.sdl diff --git a/test/issue1005-configuration-resolution/b/dub.sdl b/test/issue1005-configuration-resolution/sample/b/dub.sdl similarity index 100% rename from test/issue1005-configuration-resolution/b/dub.sdl rename to test/issue1005-configuration-resolution/sample/b/dub.sdl diff --git a/test/issue1005-configuration-resolution/b/source/b.d b/test/issue1005-configuration-resolution/sample/b/source/b.d similarity index 100% rename from test/issue1005-configuration-resolution/b/source/b.d rename to test/issue1005-configuration-resolution/sample/b/source/b.d diff --git a/test/issue1005-configuration-resolution/c/dub.sdl b/test/issue1005-configuration-resolution/sample/c/dub.sdl similarity index 100% rename from test/issue1005-configuration-resolution/c/dub.sdl rename to test/issue1005-configuration-resolution/sample/c/dub.sdl diff --git a/test/issue1005-configuration-resolution/main/dub.sdl b/test/issue1005-configuration-resolution/sample/main/dub.sdl similarity index 100% rename from test/issue1005-configuration-resolution/main/dub.sdl rename to test/issue1005-configuration-resolution/sample/main/dub.sdl diff --git a/test/issue1005-configuration-resolution/main/source/app.d b/test/issue1005-configuration-resolution/sample/main/source/app.d similarity index 100% rename from test/issue1005-configuration-resolution/main/source/app.d rename to test/issue1005-configuration-resolution/sample/main/source/app.d diff --git a/test/issue1005-configuration-resolution/source/app.d b/test/issue1005-configuration-resolution/source/app.d new file mode 100644 index 0000000000..b04ed53a43 --- /dev/null +++ b/test/issue1005-configuration-resolution/source/app.d @@ -0,0 +1,11 @@ +import common; + +import std.process; + +void main () { + auto p = spawnProcess( + [dub, "build", "--bare", "main"], null, Config.none, "sample"); + + if (p.wait != 0) + die("Dub build failed"); +} diff --git a/test/issue1024-selective-upgrade.sh b/test/issue1024-selective-upgrade.sh deleted file mode 100755 index dc7c009713..0000000000 --- a/test/issue1024-selective-upgrade.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1024-selective-upgrade -echo "{\"fileVersion\": 1,\"versions\": {\"a\": \"1.0.0\", \"b\": \"1.0.0\"}}" > main/dub.selections.json -$DUB upgrade --bare --root=main a - -if ! grep -c -e "\"a\": \"1.0.1\"" main/dub.selections.json; then - die $LINENO "Specified dependency was not upgraded." -fi - -if grep -c -e "\"b\": \"1.0.1\"" main/dub.selections.json; then - die $LINENO "Non-specified dependency got upgraded." -fi diff --git a/test/issue1024-selective-upgrade/.gitignore b/test/issue1024-selective-upgrade/.gitignore new file mode 100644 index 0000000000..71e6ee7a81 --- /dev/null +++ b/test/issue1024-selective-upgrade/.gitignore @@ -0,0 +1,4 @@ +/sample/** +!/sample/ +!/sample/*/ +!/sample/*/dub.sdl \ No newline at end of file diff --git a/test/issue1024-selective-upgrade/.no_build b/test/issue1024-selective-upgrade/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1024-selective-upgrade/dub.json b/test/issue1024-selective-upgrade/dub.json new file mode 100644 index 0000000000..1855a39d4b --- /dev/null +++ b/test/issue1024-selective-upgrade/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1024-selective-upgrade", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1024-selective-upgrade/a-1.0.0/dub.sdl b/test/issue1024-selective-upgrade/sample/a-1.0.0/dub.sdl similarity index 100% rename from test/issue1024-selective-upgrade/a-1.0.0/dub.sdl rename to test/issue1024-selective-upgrade/sample/a-1.0.0/dub.sdl diff --git a/test/issue1024-selective-upgrade/a-1.0.1/dub.sdl b/test/issue1024-selective-upgrade/sample/a-1.0.1/dub.sdl similarity index 100% rename from test/issue1024-selective-upgrade/a-1.0.1/dub.sdl rename to test/issue1024-selective-upgrade/sample/a-1.0.1/dub.sdl diff --git a/test/issue1024-selective-upgrade/b-1.0.0/dub.sdl b/test/issue1024-selective-upgrade/sample/b-1.0.0/dub.sdl similarity index 100% rename from test/issue1024-selective-upgrade/b-1.0.0/dub.sdl rename to test/issue1024-selective-upgrade/sample/b-1.0.0/dub.sdl diff --git a/test/issue1024-selective-upgrade/b-1.0.1/dub.sdl b/test/issue1024-selective-upgrade/sample/b-1.0.1/dub.sdl similarity index 100% rename from test/issue1024-selective-upgrade/b-1.0.1/dub.sdl rename to test/issue1024-selective-upgrade/sample/b-1.0.1/dub.sdl diff --git a/test/issue1024-selective-upgrade/main/dub.sdl b/test/issue1024-selective-upgrade/sample/main/dub.sdl similarity index 100% rename from test/issue1024-selective-upgrade/main/dub.sdl rename to test/issue1024-selective-upgrade/sample/main/dub.sdl diff --git a/test/issue1024-selective-upgrade/source/app.d b/test/issue1024-selective-upgrade/source/app.d new file mode 100644 index 0000000000..0145319de3 --- /dev/null +++ b/test/issue1024-selective-upgrade/source/app.d @@ -0,0 +1,27 @@ +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + chdir("sample"); + write("main/dub.selections.json", ` +{ + "fileVersion": 1, + "versions": { + "a": "1.0.0", + "b": "1.0.0" + } +}`); + + auto p = spawnProcess([dub, "upgrade", "--bare", "--root=main", "a"]); + if (p.wait != 0) + die("Dub upgrade failed"); + + immutable selections = readText("main/dub.selections.json"); + if (!selections.canFind(`"a": "1.0.1"`)) + die("Specified dependency was not upgraded."); + if (selections.canFind(`"b": "1.0.1"`)) + die("Non-specified dependency got upgraded."); +} diff --git a/test/issue103-single-file-package.sh b/test/issue103-single-file-package.sh deleted file mode 100755 index 671e5186ad..0000000000 --- a/test/issue103-single-file-package.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR} -rm -f single-file-test - -${DUB} run --single issue103-single-file-package-json.d --compiler=${DC} -if [ ! -f single-file-test ]; then - die $LINENO 'Normal invocation did not produce a binary in the current directory' -fi -rm single-file-test - -./issue103-single-file-package.d foo -- bar -${DUB} ./issue103-single-file-package foo -- bar -./issue103-single-file-package-no-ext foo -- bar - -${DUB} issue103-single-file-package-w-dep.d - -if [ -f single-file-test ]; then - die $LINENO 'Shebang invocation produced binary in current directory' -fi - -if ! { ${DUB} run --single issue103-single-file-package-w-dep.d --temp-build 2>&1 || true; } | grep -cF "To force a rebuild"; then - echo "Invocation triggered unnecessary rebuild." - exit 1 -fi - -if ${DUB} "issue103-single-file-package-error.d" 2> /dev/null; then - echo "Invalid package comment syntax did not trigger an error." - exit 1 -fi diff --git a/test/issue103-single-file-package/.gitignore b/test/issue103-single-file-package/.gitignore new file mode 100644 index 0000000000..5fe33ec91f --- /dev/null +++ b/test/issue103-single-file-package/.gitignore @@ -0,0 +1,6 @@ +sample/* +!sample/ +!sample/sdl.d +!sample/json.d +!sample/no-ext +!sample/w-dep.d \ No newline at end of file diff --git a/test/issue103-single-file-package/dub.json b/test/issue103-single-file-package/dub.json new file mode 100644 index 0000000000..00fb4f1c1f --- /dev/null +++ b/test/issue103-single-file-package/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue103-single-file-package", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue103-single-file-package-json.d b/test/issue103-single-file-package/sample/json.d similarity index 100% rename from test/issue103-single-file-package-json.d rename to test/issue103-single-file-package/sample/json.d diff --git a/test/issue103-single-file-package.d b/test/issue103-single-file-package/sample/no-ext similarity index 91% rename from test/issue103-single-file-package.d rename to test/issue103-single-file-package/sample/no-ext index 8c766389a0..d956dcc5b5 100755 --- a/test/issue103-single-file-package.d +++ b/test/issue103-single-file-package/sample/no-ext @@ -1,4 +1,4 @@ -#!../bin/dub +#!../../../bin/dub /+ dub.sdl: name "single-file-test" +/ diff --git a/test/issue103-single-file-package-no-ext b/test/issue103-single-file-package/sample/sdl.d similarity index 91% rename from test/issue103-single-file-package-no-ext rename to test/issue103-single-file-package/sample/sdl.d index 8c766389a0..d956dcc5b5 100755 --- a/test/issue103-single-file-package-no-ext +++ b/test/issue103-single-file-package/sample/sdl.d @@ -1,4 +1,4 @@ -#!../bin/dub +#!../../../bin/dub /+ dub.sdl: name "single-file-test" +/ diff --git a/test/issue103-single-file-package-w-dep.d b/test/issue103-single-file-package/sample/w-dep.d similarity index 60% rename from test/issue103-single-file-package-w-dep.d rename to test/issue103-single-file-package/sample/w-dep.d index 5f66241295..e012daaf32 100644 --- a/test/issue103-single-file-package-w-dep.d +++ b/test/issue103-single-file-package/sample/w-dep.d @@ -1,6 +1,6 @@ /+ dub.sdl: name "single-file-test" -dependency "sourcelib-simple" path="1-sourceLib-simple" +dependency "sourcelib-simple" path="../../extra/1-sourceLib-simple" +/ module hello; diff --git a/test/issue103-single-file-package/source/app.d b/test/issue103-single-file-package/source/app.d new file mode 100644 index 0000000000..64396461c7 --- /dev/null +++ b/test/issue103-single-file-package/source/app.d @@ -0,0 +1,44 @@ +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + chdir("sample"); + immutable exePath = "single-file-test" ~ DotExe; + + if (spawnProcess([dub, "run", "--single", "json.d"]).wait != 0) + die("Dub couldn't run single file json package"); + if (!exists(exePath)) + die("Normal invocation did not produce a binary in the current directory"); + remove(exePath); + + version(Posix) + if (spawnProcess(["./sdl.d", "foo", "--", "bar"]).wait != 0) + die("Failed running shebang script with extension"); + + if (spawnProcess([dub, "./sdl.d", "foo", "--", "bar"]).wait != 0) + die("Dub failed to run script with shebang"); + + version(Posix) + if (spawnProcess(["./no-ext", "foo", "--", "bar"]).wait != 0) + die("Failed running shebang script without extension"); + + if (spawnProcess([dub, "w-dep.d"]).wait != 0) + die("Dub couldn't run single file package with dependency"); + + if (exists(exePath)) + die("Shebang invocation produced binary in current directory"); + + { + auto p = execute([dub, "run", "w-dep.d", "--temp-build"]); + if (p.output.canFind("To force a rebuild")) + die("Invocation triggered unnecessary rebuild."); + } + + // missing from git? https://github.com/dlang/dub/pull/1177 was the one that should have added it + version(none) + if (spawnProcess([dub, "error.d"]).wait == 0) + die("Invalid package comment syntax did not trigger an error."); +} diff --git a/test/issue1037-better-dependency-messages.sh b/test/issue1037-better-dependency-messages.sh deleted file mode 100755 index 8847382ce4..0000000000 --- a/test/issue1037-better-dependency-messages.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e -o pipefail - -cd ${CURR_DIR}/issue1037-better-dependency-messages - -temp_file=$(mktemp $(basename $0).XXXXXX) -temp_file2=$(mktemp $(basename $0).XXXXXX) -expected_file="$CURR_DIR/expected-issue1037-output" - -function cleanup { - rm -f $temp_file - rm -f $temp_file2 -} - -trap cleanup EXIT - -sed "s#DIR#$CURR_DIR/issue1037-better-dependency-messages#" "$expected_file" > "$temp_file2" - -$DUB upgrade 2>$temp_file && exit 1 # dub upgrade should fail - -if ! diff "$temp_file2" "$temp_file"; then - die $LINENO 'output not containing conflict information' -fi - -exit 0 diff --git a/test/issue1037-better-dependency-messages/.gitignore b/test/issue1037-better-dependency-messages/.gitignore new file mode 100644 index 0000000000..11d1d2b8f9 --- /dev/null +++ b/test/issue1037-better-dependency-messages/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/*/ +!/sample/*/dub.json \ No newline at end of file diff --git a/test/issue1037-better-dependency-messages/.no_build b/test/issue1037-better-dependency-messages/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1037-better-dependency-messages/.no_run b/test/issue1037-better-dependency-messages/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1037-better-dependency-messages/.no_test b/test/issue1037-better-dependency-messages/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1037-better-dependency-messages/dub.json b/test/issue1037-better-dependency-messages/dub.json index abb7d175fc..6770fe2a46 100644 --- a/test/issue1037-better-dependency-messages/dub.json +++ b/test/issue1037-better-dependency-messages/dub.json @@ -1,10 +1,8 @@ { - "name": "issue1037-better-dependency-messages", + "name": "issue1037-better-dependency-message", "dependencies": { - "gitcompatibledubpackage": "1.0.1", - "b": { - "path": "b", - "version": "*" + "common": { + "path": "../common" } } -} \ No newline at end of file +} diff --git a/test/issue1037-better-dependency-messages/b/dub.json b/test/issue1037-better-dependency-messages/sample/b/dub.json similarity index 100% rename from test/issue1037-better-dependency-messages/b/dub.json rename to test/issue1037-better-dependency-messages/sample/b/dub.json diff --git a/test/issue1037-better-dependency-messages/sample/dub.json b/test/issue1037-better-dependency-messages/sample/dub.json new file mode 100644 index 0000000000..abb7d175fc --- /dev/null +++ b/test/issue1037-better-dependency-messages/sample/dub.json @@ -0,0 +1,10 @@ +{ + "name": "issue1037-better-dependency-messages", + "dependencies": { + "gitcompatibledubpackage": "1.0.1", + "b": { + "path": "b", + "version": "*" + } + } +} \ No newline at end of file diff --git a/test/issue1037-better-dependency-messages/source/app.d b/test/issue1037-better-dependency-messages/source/app.d new file mode 100644 index 0000000000..942b692459 --- /dev/null +++ b/test/issue1037-better-dependency-messages/source/app.d @@ -0,0 +1,29 @@ +import common; + +import std.algorithm; +import std.array; +import std.file; +import std.format; +import std.process; +import std.path; +import std.string; +import std.stdio; + +void main () { + chdir("sample"); + + auto p = teeProcess([dub, "upgrade"]); + if (p.pid.wait == 0) + die("Dub upgrade should have failed"); + + immutable expected = [ + `Error Unresolvable dependencies to package gitcompatibledubpackage:`, + ` b @%s depends on gitcompatibledubpackage ~>1.0.2`.format(getcwd.buildPath("b")), + ` issue1037-better-dependency-messages ~master depends on gitcompatibledubpackage 1.0.1`, + ]; + + const got = p.stderrLines; + + if (!equal(got, expected)) + die("output not containting conflict information"); +} diff --git a/test/issue1040-run-with-ver.sh b/test/issue1040-run-with-ver.sh deleted file mode 100755 index 10b100496b..0000000000 --- a/test/issue1040-run-with-ver.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if ! [ -d ${CURR_DIR}/issue1040-tmpdir ]; then - mkdir ${CURR_DIR}/issue1040-tmpdir - touch ${CURR_DIR}/issue1040-tmpdir/.no_build - touch ${CURR_DIR}/issue1040-tmpdir/.no_run - touch ${CURR_DIR}/issue1040-tmpdir/.no_test - function cleanup { - rm -rf ${CURR_DIR}/issue1040-tmpdir - } - trap cleanup EXIT -fi - -cd ${CURR_DIR}/issue1040-tmpdir - -$DUB fetch dub@1.27.0 --cache=local -$DUB fetch dub@1.28.0 --cache=local -$DUB fetch dub@1.29.0 --cache=local - -if { $DUB fetch dub@1.28.0 --cache=local || true; } | grep -cF 'Fetching' > /dev/null; then - die $LINENO 'Test for doubly fetch of the specified version has failed.' -fi -if ! { $DUB run dub -q --cache=local -- --version || true; } | grep -cF 'DUB version 1.29.0' > /dev/null; then - die $LINENO 'Test for selection of the latest fetched version has failed.' -fi -if ! { $DUB run dub@1.28.0 -q --cache=local -- --version || true; } | grep -cF 'DUB version 1.28.0' > /dev/null; then - die $LINENO 'Test for selection of the specified version has failed.' -fi diff --git a/test/issue1040-run-with-ver/dub.json b/test/issue1040-run-with-ver/dub.json new file mode 100644 index 0000000000..34b3f5995c --- /dev/null +++ b/test/issue1040-run-with-ver/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1040-run-with-ver", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1040-run-with-ver/source/app.d b/test/issue1040-run-with-ver/source/app.d new file mode 100644 index 0000000000..28fc03b015 --- /dev/null +++ b/test/issue1040-run-with-ver/source/app.d @@ -0,0 +1,33 @@ +import common; + +import std.algorithm; +import std.path; +import std.file; +import std.process; + +void main() { + version(Windows) version(LDC) skip("ldc2 doesn't come with libcurl on windows"); + + if (exists("test")) rmdirRecurse("test"); + mkdir("test"); + chdir("test"); + + foreach (ver; ["1.27.0", "1.28.0", "1.29.0"]) + if (spawnProcess([dub, "fetch", "dub@" ~ ver, "--cache=local"]).wait != 0) + die("Dub fetch failed"); + + auto p = teeProcess([dub, "fetch", "dub@1.28.0"]); + p.wait; + if (p.stdout.canFind("Fetching")) + die("Test for doubly fetch of the specified version has failed."); + + p = teeProcess([dub, "run", "dub", "-q", "--cache=local", "--", "--version"]); + p.wait; + if (!p.stdout.canFind("DUB version 1.29.0")) + die("Test for selection of the latest fetched version has failed."); + + p = teeProcess([dub, "run", "dub@1.28.0", "-q", "--cache=local", "--", "--version"]); + p.wait; + if (!p.stdout.canFind("DUB version 1.28.0")) + die("Test for selection of the specified version has failed."); +} diff --git a/test/issue1053-extra-files-visuald.sh b/test/issue1053-extra-files-visuald.sh deleted file mode 100755 index 4c8d9793b7..0000000000 --- a/test/issue1053-extra-files-visuald.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd "${CURR_DIR}/issue1053-extra-files-visuald" || die "Could not cd." - -"$DUB" generate visuald - -if [ `grep -c -e "saturate.vert" .dub/extra_files.visualdproj` -ne 1 ]; then - die $LINENO 'Regression of issue #1053.' -fi - -if [ `grep -c -e "warp.geom" .dub/extra_files.visualdproj` -ne 1 ]; then - die $LINENO 'Regression of issue #1053.' -fi - -if [ `grep -c -e "LICENSE.txt" .dub/extra_files.visualdproj` -ne 1 ]; then - die $LINENO 'Regression of issue #1053.' -fi - -if [ `grep -c -e "README.txt" .dub/extra_files.visualdproj` -ne 1 ]; then - die $LINENO 'Regression of issue #1053.' -fi - -if [ `grep -e "README.txt" .dub/extra_files.visualdproj | grep -c -e 'copy /Y $(InputPath) $(TargetDir)'` -ne 1 ]; then - die $LINENO 'Copying of copyFiles seems broken for visuald.' -fi diff --git a/test/issue1053-extra-files-visuald/.gitignore b/test/issue1053-extra-files-visuald/.gitignore new file mode 100644 index 0000000000..5431d8dd5d --- /dev/null +++ b/test/issue1053-extra-files-visuald/.gitignore @@ -0,0 +1,6 @@ +/sample/* +!/sample/ +!/sample/dub.json +!/sample/text/ +!/sample/shaders +!/sample/source \ No newline at end of file diff --git a/test/issue1053-extra-files-visuald/dub.json b/test/issue1053-extra-files-visuald/dub.json index a24bc8d3f2..200f45b55f 100644 --- a/test/issue1053-extra-files-visuald/dub.json +++ b/test/issue1053-extra-files-visuald/dub.json @@ -1,11 +1,8 @@ { - "name": "extra_files", - "targetType": "executable", - "extraDependencyFiles": [ - "shaders/*" - ], - "copyFiles": [ - "text/LICENSE.txt", - "text/README.txt" - ] + "name": "issue1053-extra-files-visuald", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue1053-extra-files-visuald/sample/dub.json b/test/issue1053-extra-files-visuald/sample/dub.json new file mode 100644 index 0000000000..a24bc8d3f2 --- /dev/null +++ b/test/issue1053-extra-files-visuald/sample/dub.json @@ -0,0 +1,11 @@ +{ + "name": "extra_files", + "targetType": "executable", + "extraDependencyFiles": [ + "shaders/*" + ], + "copyFiles": [ + "text/LICENSE.txt", + "text/README.txt" + ] +} diff --git a/test/issue1053-extra-files-visuald/shaders/saturate.vert b/test/issue1053-extra-files-visuald/sample/shaders/saturate.vert similarity index 100% rename from test/issue1053-extra-files-visuald/shaders/saturate.vert rename to test/issue1053-extra-files-visuald/sample/shaders/saturate.vert diff --git a/test/issue1053-extra-files-visuald/shaders/warp.geom b/test/issue1053-extra-files-visuald/sample/shaders/warp.geom similarity index 100% rename from test/issue1053-extra-files-visuald/shaders/warp.geom rename to test/issue1053-extra-files-visuald/sample/shaders/warp.geom diff --git a/test/issue2085-target-none-visuald/sub/source/app.d b/test/issue1053-extra-files-visuald/sample/source/app.d similarity index 100% rename from test/issue2085-target-none-visuald/sub/source/app.d rename to test/issue1053-extra-files-visuald/sample/source/app.d diff --git a/test/issue1053-extra-files-visuald/text/LICENSE.txt b/test/issue1053-extra-files-visuald/sample/text/LICENSE.txt similarity index 100% rename from test/issue1053-extra-files-visuald/text/LICENSE.txt rename to test/issue1053-extra-files-visuald/sample/text/LICENSE.txt diff --git a/test/issue1053-extra-files-visuald/text/README.txt b/test/issue1053-extra-files-visuald/sample/text/README.txt similarity index 100% rename from test/issue1053-extra-files-visuald/text/README.txt rename to test/issue1053-extra-files-visuald/sample/text/README.txt diff --git a/test/issue1053-extra-files-visuald/source/app.d b/test/issue1053-extra-files-visuald/source/app.d index ab73b3a234..fee35c659e 100644 --- a/test/issue1053-extra-files-visuald/source/app.d +++ b/test/issue1053-extra-files-visuald/source/app.d @@ -1 +1,23 @@ -void main() {} +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + if (spawnProcess([dub, "generate", "visuald"]).wait != 0) + die("Dub couldn't generate visuald project"); + + immutable proj = readText(".dub/extra_files.visualdproj"); + + foreach (needle; ["saturate.vert" , "saturate.vert" , "LICENSE.txt" , "README.txt" ]) + if (!proj.canFind(needle)) + die("regression of issue #1053"); + + immutable lineWithREADME = proj.splitter('\n').filter!(line => line.canFind("README.txt")).front; + if (!lineWithREADME.canFind("copy /Y $(InputPath) $(TargetDir)")) + die("Copying of copyFiles seems broken for visuald."); +} diff --git a/test/issue1070-init-mistakes-dirs-as-files.sh b/test/issue1070-init-mistakes-dirs-as-files.sh deleted file mode 100755 index 4cd8e85765..0000000000 --- a/test/issue1070-init-mistakes-dirs-as-files.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd ${CURR_DIR}/issue1070-init-mistakes-dirs-as-files - -${DUB} init 2>&1 | grep -c "The target directory already contains a 'source/' directory. Aborting." > /dev/null \ No newline at end of file diff --git a/test/issue1070-init-mistakes-dirs-as-files/.gitignore b/test/issue1070-init-mistakes-dirs-as-files/.gitignore new file mode 100644 index 0000000000..a4145133e1 --- /dev/null +++ b/test/issue1070-init-mistakes-dirs-as-files/.gitignore @@ -0,0 +1,3 @@ +!/sample/ +!/sample/source/ +!/sample/source/.empty \ No newline at end of file diff --git a/test/issue1070-init-mistakes-dirs-as-files/.no_build b/test/issue1070-init-mistakes-dirs-as-files/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1070-init-mistakes-dirs-as-files/.no_run b/test/issue1070-init-mistakes-dirs-as-files/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1070-init-mistakes-dirs-as-files/.no_test b/test/issue1070-init-mistakes-dirs-as-files/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1070-init-mistakes-dirs-as-files/dub.json b/test/issue1070-init-mistakes-dirs-as-files/dub.json new file mode 100644 index 0000000000..489062a82c --- /dev/null +++ b/test/issue1070-init-mistakes-dirs-as-files/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1070-ini-tmistakes-dirs-as-files", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1070-init-mistakes-dirs-as-files/source/.empty b/test/issue1070-init-mistakes-dirs-as-files/sample/source/.empty similarity index 100% rename from test/issue1070-init-mistakes-dirs-as-files/source/.empty rename to test/issue1070-init-mistakes-dirs-as-files/sample/source/.empty diff --git a/test/issue1070-init-mistakes-dirs-as-files/source/app.d b/test/issue1070-init-mistakes-dirs-as-files/source/app.d new file mode 100644 index 0000000000..d57db3e041 --- /dev/null +++ b/test/issue1070-init-mistakes-dirs-as-files/source/app.d @@ -0,0 +1,16 @@ +import common; + +import std.algorithm; +import std.path; +import std.file; +import std.process; + +void main() { + chdir("sample"); + + auto p = teeProcess([dub, "init"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + immutable expected = "The target directory already contains a 'source/' directory. Aborting."; + if (!p.stdout.canFind(expected)) + die("Dub init dit not fail as expected"); +} diff --git a/test/issue1091-bogus-rebuild.sh b/test/issue1091-bogus-rebuild.sh deleted file mode 100755 index 3198d42960..0000000000 --- a/test/issue1091-bogus-rebuild.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/1-exec-simple -rm -f dub.selections.json -${DUB} clean -${DUB} build --compiler=${DC} 2>&1 | grep -e 'building configuration' -c -${DUB} build --compiler=${DC} 2>&1 | { ! grep -e 'building configuration' -c; } diff --git a/test/issue1091-bogus-rebuild/.gitignore b/test/issue1091-bogus-rebuild/.gitignore new file mode 100644 index 0000000000..a6f49491b9 --- /dev/null +++ b/test/issue1091-bogus-rebuild/.gitignore @@ -0,0 +1,4 @@ +sample/* +!sample/ +!sample/dub.sdl +!sample/source/ \ No newline at end of file diff --git a/test/issue1091-bogus-rebuild/dub.json b/test/issue1091-bogus-rebuild/dub.json new file mode 100644 index 0000000000..d000f86ab5 --- /dev/null +++ b/test/issue1091-bogus-rebuild/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1091-bogus-rebuild", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1091-bogus-rebuild/sample/dub.sdl b/test/issue1091-bogus-rebuild/sample/dub.sdl new file mode 100644 index 0000000000..e1c33695c4 --- /dev/null +++ b/test/issue1091-bogus-rebuild/sample/dub.sdl @@ -0,0 +1 @@ +name "sample" \ No newline at end of file diff --git a/test/issue1091-bogus-rebuild/sample/source/app.d b/test/issue1091-bogus-rebuild/sample/source/app.d new file mode 100644 index 0000000000..d66321b3c5 --- /dev/null +++ b/test/issue1091-bogus-rebuild/sample/source/app.d @@ -0,0 +1 @@ +void main () {} diff --git a/test/issue1091-bogus-rebuild/source/app.d b/test/issue1091-bogus-rebuild/source/app.d new file mode 100644 index 0000000000..ec0927c181 --- /dev/null +++ b/test/issue1091-bogus-rebuild/source/app.d @@ -0,0 +1,23 @@ +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + immutable dub = environment["DUB"]; + chdir("sample"); + + if (spawnProcess([dub, "clean"]).wait != 0) + die("Dub clean failed"); + + auto p = teeProcess([dub, "build"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("building configuration")) + die("Dub didn't build the package"); + + p = teeProcess([dub, "build"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (p.stdout.canFind("building configuration")) + die("Dub rebuilt the package"); +} diff --git a/test/issue1117-extra-dependency-files.sh b/test/issue1117-extra-dependency-files.sh deleted file mode 100755 index 7bb268c2f1..0000000000 --- a/test/issue1117-extra-dependency-files.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1117-extra-dependency-files - -# Ensure the test can be re-run -${DUB} clean - -if ! { ${DUB} build 2>&1 || true; } | grep -cF 'building configuration'; then - die $LINENO 'Build was not executed.' -fi - -if ! { ${DUB} build 2>&1 || true; } | grep -cF 'is up to date'; then - die $LINENO 'Build was executed.' -fi - -touch ./dependency.txt - -if ! { ${DUB} build 2>&1 || true; } | grep -cF 'building configuration'; then - die $LINENO 'Build was not executed.' -fi diff --git a/test/issue1117-extra-dependency-files/.gitignore b/test/issue1117-extra-dependency-files/.gitignore index 304e9559a5..ced4e3f25a 100644 --- a/test/issue1117-extra-dependency-files/.gitignore +++ b/test/issue1117-extra-dependency-files/.gitignore @@ -1,8 +1,5 @@ -.dub -docs.json -__dummy.html -docs/ -*.exe -*.o -*.obj -*.lst +sample/* +!sample/ +!sample/dependency.txt +!sample/dub.json +!sample/source \ No newline at end of file diff --git a/test/issue1117-extra-dependency-files/.no_build b/test/issue1117-extra-dependency-files/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1117-extra-dependency-files/dependency.txt b/test/issue1117-extra-dependency-files/dependency.txt deleted file mode 100644 index 5ab2f8a432..0000000000 --- a/test/issue1117-extra-dependency-files/dependency.txt +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/test/issue1117-extra-dependency-files/dub.json b/test/issue1117-extra-dependency-files/dub.json index 00e57a9313..34d22e0eac 100644 --- a/test/issue1117-extra-dependency-files/dub.json +++ b/test/issue1117-extra-dependency-files/dub.json @@ -1,4 +1,8 @@ { - "name": "test", - "extraDependencyFiles": ["dependency.txt"] -} \ No newline at end of file + "name": "issue1117-extra-dependency-files", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/1-dynLib-simple/.no_run b/test/issue1117-extra-dependency-files/sample/dependency.txt similarity index 100% rename from test/1-dynLib-simple/.no_run rename to test/issue1117-extra-dependency-files/sample/dependency.txt diff --git a/test/issue1117-extra-dependency-files/sample/dub.json b/test/issue1117-extra-dependency-files/sample/dub.json new file mode 100644 index 0000000000..5e21a6e4a0 --- /dev/null +++ b/test/issue1117-extra-dependency-files/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "test", + "extraDependencyFiles": ["dependency.txt"] +} diff --git a/test/issue1117-extra-dependency-files/sample/source/app.d b/test/issue1117-extra-dependency-files/sample/source/app.d new file mode 100644 index 0000000000..ef93217bed --- /dev/null +++ b/test/issue1117-extra-dependency-files/sample/source/app.d @@ -0,0 +1 @@ +void main(){} \ No newline at end of file diff --git a/test/issue1117-extra-dependency-files/source/app.d b/test/issue1117-extra-dependency-files/source/app.d index ef93217bed..1c3a4b4076 100644 --- a/test/issue1117-extra-dependency-files/source/app.d +++ b/test/issue1117-extra-dependency-files/source/app.d @@ -1 +1,29 @@ -void main(){} \ No newline at end of file +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + chdir("sample"); + + if (spawnProcess([dub, "clean"]).wait != 0) + die("Dub clean failed"); + + auto p = teeProcess([dub, "build"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("building configuration")) + die("Build was not executed."); + + p = teeProcess([dub, "build"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("is up to date")) + die("Build was executed."); + + write("dependency.txt", ""); + + p = teeProcess([dub, "build"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("building configuration")) + die("Build was not executed."); +} diff --git a/test/issue1136-temp-copy-files.sh b/test/issue1136-temp-copy-files.sh deleted file mode 100755 index ab935cbc93..0000000000 --- a/test/issue1136-temp-copy-files.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1136-temp-copy-files - -"$DUB" app.d diff --git a/test/issue1136-temp-copy-files/.gitignore b/test/issue1136-temp-copy-files/.gitignore new file mode 100644 index 0000000000..29e445c2e6 --- /dev/null +++ b/test/issue1136-temp-copy-files/.gitignore @@ -0,0 +1,6 @@ +sample/** +!sample/ +!sample/app.d +!sample/mylib/ +!sample/mylib/dub.sdl +!sample/mylib/helloworld.txt \ No newline at end of file diff --git a/test/issue1136-temp-copy-files/.no_build b/test/issue1136-temp-copy-files/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1136-temp-copy-files/dub.json b/test/issue1136-temp-copy-files/dub.json new file mode 100644 index 0000000000..e1faa16bd5 --- /dev/null +++ b/test/issue1136-temp-copy-files/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1136-temp-copy-files", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1136-temp-copy-files/app.d b/test/issue1136-temp-copy-files/sample/app.d similarity index 99% rename from test/issue1136-temp-copy-files/app.d rename to test/issue1136-temp-copy-files/sample/app.d index 388398430f..b927ee1e63 100644 --- a/test/issue1136-temp-copy-files/app.d +++ b/test/issue1136-temp-copy-files/sample/app.d @@ -12,4 +12,4 @@ void main() { string filePath = buildPath(thisExePath.dirName, "helloworld.txt"); enforce(filePath.exists); -} \ No newline at end of file +} diff --git a/test/issue1136-temp-copy-files/mylib/dub.sdl b/test/issue1136-temp-copy-files/sample/mylib/dub.sdl similarity index 100% rename from test/issue1136-temp-copy-files/mylib/dub.sdl rename to test/issue1136-temp-copy-files/sample/mylib/dub.sdl diff --git a/test/issue1136-temp-copy-files/mylib/helloworld.txt b/test/issue1136-temp-copy-files/sample/mylib/helloworld.txt similarity index 100% rename from test/issue1136-temp-copy-files/mylib/helloworld.txt rename to test/issue1136-temp-copy-files/sample/mylib/helloworld.txt diff --git a/test/issue1136-temp-copy-files/source/app.d b/test/issue1136-temp-copy-files/source/app.d new file mode 100644 index 0000000000..81728b97ea --- /dev/null +++ b/test/issue1136-temp-copy-files/source/app.d @@ -0,0 +1,10 @@ +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + if (spawnProcess([dub, "app.d"], null, Config.none, "sample").wait != 0) + die("dub failed"); +} diff --git a/test/issue1158-stdin-for-single-files.sh b/test/issue1158-stdin-for-single-files.sh deleted file mode 100755 index 1d2baea680..0000000000 --- a/test/issue1158-stdin-for-single-files.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/issue1158-stdin-for-single-files - -if ! { cat stdin.d | ${DUB} - --value=v 2>&1 || true; } | grep -cF '["--value=v"]'; then - die $LINENO 'Stdin for single files failed.' -fi \ No newline at end of file diff --git a/test/issue1158-stdin-for-single-files/.gitignore b/test/issue1158-stdin-for-single-files/.gitignore new file mode 100644 index 0000000000..81c519c1d7 --- /dev/null +++ b/test/issue1158-stdin-for-single-files/.gitignore @@ -0,0 +1 @@ +!/stdin.d \ No newline at end of file diff --git a/test/issue1158-stdin-for-single-files/.no_build b/test/issue1158-stdin-for-single-files/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1158-stdin-for-single-files/dub.json b/test/issue1158-stdin-for-single-files/dub.json new file mode 100644 index 0000000000..9fc4eb2732 --- /dev/null +++ b/test/issue1158-stdin-for-single-files/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1158-stdin-for-single-files", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1158-stdin-for-single-files/source/app.d b/test/issue1158-stdin-for-single-files/source/app.d new file mode 100644 index 0000000000..460f65daf1 --- /dev/null +++ b/test/issue1158-stdin-for-single-files/source/app.d @@ -0,0 +1,18 @@ +import common; + +import std.array; +import std.algorithm; +import std.process; +import std.file; + +void main () { + immutable stdin = readText("stdin.d"); + auto p = teeProcess([dub, "-", "--value=v"]); + p.stdin.write(stdin); + p.stdin.close(); + if (p.pid.wait != 0) + die("Dub run failed"); + + if (!p.stdout.canFind(`["--value=v"]`)) + die("Stdin for single files failed."); +} diff --git a/test/issue1180-local-cache-broken.sh b/test/issue1180-local-cache-broken.sh deleted file mode 100755 index 41a8588001..0000000000 --- a/test/issue1180-local-cache-broken.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -PORT=$(getRandomPort) - -"$DUB" remove maven-dubpackage --root="$DIR/issue1180-local-cache-broken" --non-interactive 2>/dev/null || true - -"$DUB" build --single "$DIR"/test_registry.d -"$DIR"/test_registry --folder="$DIR/issue1416-maven-repo-pkg-supplier" --port=$PORT & -PID=$! -sleep 1 -trap 'kill $PID 2>/dev/null || true' exit - -echo "Trying to download maven-dubpackage (1.0.5)" -"$DUB" upgrade --root="$DIR/issue1180-local-cache-broken" --cache=local --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages - -if ! "$DUB" remove maven-dubpackage@1.0.5 --root="$DIR/issue1180-local-cache-broken" --non-interactive 2>/dev/null; then - die $LINENO 'DUB did not install package from maven registry.' -fi diff --git a/test/issue1180-local-cache-broken.sh.min_frontend b/test/issue1180-local-cache-broken.sh.min_frontend deleted file mode 100644 index 4817f99644..0000000000 --- a/test/issue1180-local-cache-broken.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.077 diff --git a/test/issue1180-local-cache-broken/.gitignore b/test/issue1180-local-cache-broken/.gitignore index 0fd9d379b1..fbd04c7ffd 100644 --- a/test/issue1180-local-cache-broken/.gitignore +++ b/test/issue1180-local-cache-broken/.gitignore @@ -1,4 +1,4 @@ -test -*.o -*.exe -.dub \ No newline at end of file +sample/* +!sample/ +!sample/dub.json +!sample/source/ \ No newline at end of file diff --git a/test/issue1180-local-cache-broken/.no_build b/test/issue1180-local-cache-broken/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1180-local-cache-broken/dub.json b/test/issue1180-local-cache-broken/dub.json index 495617df11..931da376e8 100644 --- a/test/issue1180-local-cache-broken/dub.json +++ b/test/issue1180-local-cache-broken/dub.json @@ -1,7 +1,11 @@ { - "name": "test", + "name": "issue1180-local-cache-broken", "dependencies": { - "maven-dubpackage": "1.0.5" + "common": { + "path": "../common" + }, + "test_registry_helper": { + "path": "../extra/test_registry" + } } - -} \ No newline at end of file +} diff --git a/test/issue1180-local-cache-broken/sample/dub.json b/test/issue1180-local-cache-broken/sample/dub.json new file mode 100644 index 0000000000..bbb4768aa0 --- /dev/null +++ b/test/issue1180-local-cache-broken/sample/dub.json @@ -0,0 +1,7 @@ +{ + "name": "test", + "dependencies": { + "maven-dubpackage": "1.0.5" + } + +} diff --git a/test/issue1180-local-cache-broken/sample/source/app.d b/test/issue1180-local-cache-broken/sample/source/app.d new file mode 100644 index 0000000000..ef93217bed --- /dev/null +++ b/test/issue1180-local-cache-broken/sample/source/app.d @@ -0,0 +1 @@ +void main(){} \ No newline at end of file diff --git a/test/issue1180-local-cache-broken/source/app.d b/test/issue1180-local-cache-broken/source/app.d index ef93217bed..43701bc8c6 100644 --- a/test/issue1180-local-cache-broken/source/app.d +++ b/test/issue1180-local-cache-broken/source/app.d @@ -1 +1,32 @@ -void main(){} \ No newline at end of file +import common; +import test_registry_helper; + +import std.algorithm; +import std.path; +import std.process; +import std.file; +import std.stdio; + +void main () { + auto testRegistry = TestRegistry("../extra/issue1416-maven-repo-pkg-supplier"); + + // Ignore errors + execute([dub, "remove", "maven-dubpackage", "--root=sample", "--non-interactive"]); + + immutable mvnUrl = "mvn+http://localhost:" ~ testRegistry.port ~ "/maven/release/dubpackages"; + + log("Trying to download maven-dubpackage (1.0.5)"); + auto p = spawnProcess([ + dub, + "upgrade", + "--root=sample", + "--cache=local", + "--skip-registry=all", + "--registry=" ~ mvnUrl, + ]); + if (p.wait != 0) + die("Dub upgrade failed"); + + if (spawnProcess([dub, "remove", "maven-dubpackage@1.0.5", "--root=sample", "--non-interactive"]).wait != 0) + die("DUB did not install package from maven registry."); +} diff --git a/test/issue1180-local-cache-broken/test.config b/test/issue1180-local-cache-broken/test.config new file mode 100644 index 0000000000..cc1dd48245 --- /dev/null +++ b/test/issue1180-local-cache-broken/test.config @@ -0,0 +1,3 @@ +locks = test_registry +# openssl failes to build with gdmd +dc_backend = [dmd, ldc] \ No newline at end of file diff --git a/test/issue1194-warn-wrong-subconfig.sh b/test/issue1194-warn-wrong-subconfig.sh deleted file mode 100755 index 2bb7e542e9..0000000000 --- a/test/issue1194-warn-wrong-subconfig.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -OUTPUT=`${DUB} build --root ${CURR_DIR}/issue1194-warn-wrong-subconfig 2>&1 || true` - -trap 'printf "%s" "Failing received output:\n$OUTPUT" | hexdump -C' ERR - -# make sure the proper errors occur in the output -echo "$OUTPUT" | fgrep -c 'sub configuration directive "bar" -> [baz] references a package that is not specified as a dependency' > /dev/null -echo $OUTPUT | fgrep -c 'sub configuration directive "staticlib-simple" -> [foo] references a configuration that does not exist' > /dev/null -! echo $OUTPUT | fgrep -c 'sub configuration directive "sourcelib-simple" -> [library] references a package that is not specified as a dependency' > /dev/null -! echo $OUTPUT | fgrep -c 'sub configuration directive "sourcelib-simple" -> [library] references a configuration that does not exist' > /dev/null - -# make sure no bogs warnings are issued for packages with no sub configuration directives -OUTPUT=`${DUB} build --root ${CURR_DIR}/1-exec-simple 2>&1` -! echo $OUTPUT | grep -c 'sub configuration directive.*references' > /dev/null diff --git a/test/issue1194-warn-wrong-subconfig/.gitignore b/test/issue1194-warn-wrong-subconfig/.gitignore new file mode 100644 index 0000000000..a6f49491b9 --- /dev/null +++ b/test/issue1194-warn-wrong-subconfig/.gitignore @@ -0,0 +1,4 @@ +sample/* +!sample/ +!sample/dub.sdl +!sample/source/ \ No newline at end of file diff --git a/test/issue1194-warn-wrong-subconfig/.no_build b/test/issue1194-warn-wrong-subconfig/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1194-warn-wrong-subconfig/dub.json b/test/issue1194-warn-wrong-subconfig/dub.json new file mode 100644 index 0000000000..25a6c43287 --- /dev/null +++ b/test/issue1194-warn-wrong-subconfig/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1194-warn-wrong-subconfig", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1194-warn-wrong-subconfig/dub.sdl b/test/issue1194-warn-wrong-subconfig/sample/dub.sdl similarity index 54% rename from test/issue1194-warn-wrong-subconfig/dub.sdl rename to test/issue1194-warn-wrong-subconfig/sample/dub.sdl index 867864ddf5..a6ab975df9 100644 --- a/test/issue1194-warn-wrong-subconfig/dub.sdl +++ b/test/issue1194-warn-wrong-subconfig/sample/dub.sdl @@ -1,6 +1,6 @@ name "test" -dependency "staticlib-simple" path="../1-staticLib-simple" -dependency "sourcelib-simple" path="../1-sourceLib-simple" +dependency "staticlib-simple" path="../../1-staticLib-simple" +dependency "sourcelib-simple" path="../../extra/1-sourceLib-simple" targetType "executable" subConfiguration "staticlib-simple" "foo" diff --git a/test/issue1194-warn-wrong-subconfig/sample/source/app.d b/test/issue1194-warn-wrong-subconfig/sample/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue1194-warn-wrong-subconfig/sample/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue1194-warn-wrong-subconfig/source/app.d b/test/issue1194-warn-wrong-subconfig/source/app.d index ab73b3a234..3f3b9bf29a 100644 --- a/test/issue1194-warn-wrong-subconfig/source/app.d +++ b/test/issue1194-warn-wrong-subconfig/source/app.d @@ -1 +1,23 @@ -void main() {} +import common; + +import std.algorithm; +import std.process; +import std.file; +import std.regex; + +void main () { + auto p = teeProcess([dub, "build", "--root=sample"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + // make sure the proper errors occur in the output + assert(p.stdout.canFind(`sub configuration directive "bar" -> [baz] references a package that is not specified as a dependency`)); + assert(p.stdout.canFind(`sub configuration directive "staticlib-simple" -> [foo] references a configuration that does not exist`)); + assert(!p.stdout.canFind(`sub configuration directive "sourcelib-simple" -> [library] references a package that is not specified as a dependency`)); + assert(!p.stdout.canFind(`sub configuration directive "sourcelib-simple" -> [library] references a configuration that does not exist`)); + + // make sure no bogus warnings are issued for packages with no sub configuration directives + p = teeProcess([dub, "build", "--root=../1-exec-simple"], Redirect.stdout | Redirect.stderrToStdout); + if (p.wait != 0) + die("dub build 1-exec-simple failed"); + if (p.stdout.matchFirst(`sub configuration directive.*references`)) + die("didn't find the correct line in output"); +} diff --git a/test/issue1262-version-inheritance-diamond/.gitignore b/test/issue1262-version-inheritance-diamond/.gitignore index c09a5970c4..24c94b803f 100644 --- a/test/issue1262-version-inheritance-diamond/.gitignore +++ b/test/issue1262-version-inheritance-diamond/.gitignore @@ -1,15 +1,3 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance-diamond -issue1262-version-inheritance-diamond.so -issue1262-version-inheritance-diamond.dylib -issue1262-version-inheritance-diamond.dll -issue1262-version-inheritance-diamond.a -issue1262-version-inheritance-diamond.lib -issue1262-version-inheritance-diamond-test-* -*.exe -*.o -*.obj -*.lst +!/daughter +!/son +!/diamond diff --git a/test/issue1262-version-inheritance-diamond/.no_run b/test/issue1262-version-inheritance-diamond/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1262-version-inheritance-diamond/.no_test b/test/issue1262-version-inheritance-diamond/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1262-version-inheritance-diamond/daughter/.gitignore b/test/issue1262-version-inheritance-diamond/daughter/.gitignore deleted file mode 100644 index f190acb869..0000000000 --- a/test/issue1262-version-inheritance-diamond/daughter/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -daughter.so -daughter.dylib -daughter.dll -daughter.a -daughter.lib -daughter-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1262-version-inheritance-diamond/daughter/dub.sdl b/test/issue1262-version-inheritance-diamond/daughter/dub.sdl index 3a0eee7b8d..f41d55b815 100644 --- a/test/issue1262-version-inheritance-diamond/daughter/dub.sdl +++ b/test/issue1262-version-inheritance-diamond/daughter/dub.sdl @@ -1,3 +1,3 @@ -name "daughter" +name "issue1262-diamond-daughter" versions "Daughter" -dependency "diamond" path="../diamond" +dependency "issue1262-diamond-diamond" path="../diamond" diff --git a/test/issue1262-version-inheritance-diamond/diamond/.gitignore b/test/issue1262-version-inheritance-diamond/diamond/.gitignore deleted file mode 100644 index c359a73474..0000000000 --- a/test/issue1262-version-inheritance-diamond/diamond/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -diamond.so -diamond.dylib -diamond.dll -diamond.a -diamond.lib -diamond-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1262-version-inheritance-diamond/diamond/dub.sdl b/test/issue1262-version-inheritance-diamond/diamond/dub.sdl index 85cb8a1307..d543e1c96a 100644 --- a/test/issue1262-version-inheritance-diamond/diamond/dub.sdl +++ b/test/issue1262-version-inheritance-diamond/diamond/dub.sdl @@ -1,2 +1,2 @@ -name "diamond" +name "issue1262-diamond-diamond" versions "Diamond" diff --git a/test/issue1262-version-inheritance-diamond/dub.sdl b/test/issue1262-version-inheritance-diamond/dub.sdl index 588adb82e3..cda35d55a9 100644 --- a/test/issue1262-version-inheritance-diamond/dub.sdl +++ b/test/issue1262-version-inheritance-diamond/dub.sdl @@ -1,4 +1,4 @@ name "issue1262-version-inheritance-diamond" versions "Parent" -dependency "daughter" path="daughter" -dependency "son" path="son" +dependency "issue1262-diamond-daughter" path="daughter" +dependency "issue1262-diamond-son" path="son" diff --git a/test/issue1262-version-inheritance-diamond/son/.gitignore b/test/issue1262-version-inheritance-diamond/son/.gitignore deleted file mode 100644 index 601a33b470..0000000000 --- a/test/issue1262-version-inheritance-diamond/son/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -son.so -son.dylib -son.dll -son.a -son.lib -son-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1262-version-inheritance-diamond/son/dub.sdl b/test/issue1262-version-inheritance-diamond/son/dub.sdl index 41dc1be69c..e2b1287104 100644 --- a/test/issue1262-version-inheritance-diamond/son/dub.sdl +++ b/test/issue1262-version-inheritance-diamond/son/dub.sdl @@ -1,3 +1,3 @@ -name "son" +name "issue1262-diamond-son" versions "Son" -dependency "diamond" path="../diamond" +dependency "issue1262-diamond-diamond" path="../diamond" diff --git a/test/issue1262-version-inheritance-diamond/test.config b/test/issue1262-version-inheritance-diamond/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/issue1262-version-inheritance-diamond/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/issue1262-version-inheritance/.gitignore b/test/issue1262-version-inheritance/.gitignore index 84dca77bd2..ae96d4212d 100644 --- a/test/issue1262-version-inheritance/.gitignore +++ b/test/issue1262-version-inheritance/.gitignore @@ -1,15 +1,2 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance -issue1262-version-inheritance.so -issue1262-version-inheritance.dylib -issue1262-version-inheritance.dll -issue1262-version-inheritance.a -issue1262-version-inheritance.lib -issue1262-version-inheritance-test-* -*.exe -*.o -*.obj -*.lst +!/daughter +!/son diff --git a/test/issue1262-version-inheritance/.no_run b/test/issue1262-version-inheritance/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1262-version-inheritance/.no_test b/test/issue1262-version-inheritance/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1262-version-inheritance/daughter/.gitignore b/test/issue1262-version-inheritance/daughter/.gitignore deleted file mode 100644 index f190acb869..0000000000 --- a/test/issue1262-version-inheritance/daughter/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -daughter.so -daughter.dylib -daughter.dll -daughter.a -daughter.lib -daughter-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1262-version-inheritance/daughter/dub.sdl b/test/issue1262-version-inheritance/daughter/dub.sdl index baa3295606..ff3251e913 100644 --- a/test/issue1262-version-inheritance/daughter/dub.sdl +++ b/test/issue1262-version-inheritance/daughter/dub.sdl @@ -1,3 +1,3 @@ -name "daughter" +name "issue1262-daughter" versions "Daughter" diff --git a/test/issue1262-version-inheritance/dub.sdl b/test/issue1262-version-inheritance/dub.sdl index 46568fbfc5..6b27f593ed 100644 --- a/test/issue1262-version-inheritance/dub.sdl +++ b/test/issue1262-version-inheritance/dub.sdl @@ -1,4 +1,4 @@ name "issue1262-version-inheritance" versions "Parent" -dependency "daughter" path="daughter" -dependency "son" path="son" +dependency "issue1262-daughter" path="daughter" +dependency "issue1262-son" path="son" diff --git a/test/issue1262-version-inheritance/son/.gitignore b/test/issue1262-version-inheritance/son/.gitignore deleted file mode 100644 index 601a33b470..0000000000 --- a/test/issue1262-version-inheritance/son/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -son.so -son.dylib -son.dll -son.a -son.lib -son-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1262-version-inheritance/son/dub.sdl b/test/issue1262-version-inheritance/son/dub.sdl index 5882548ada..3f087ef5d4 100644 --- a/test/issue1262-version-inheritance/son/dub.sdl +++ b/test/issue1262-version-inheritance/son/dub.sdl @@ -1,2 +1,2 @@ -name "son" +name "issue1262-son" versions "Son" diff --git a/test/issue1262-version-inheritance/test.config b/test/issue1262-version-inheritance/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/issue1262-version-inheritance/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/issue1277.sh b/test/issue1277.sh deleted file mode 100755 index 5471c8d773..0000000000 --- a/test/issue1277.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/issue1003-check-empty-ld-flags - -# It should fail -! ${DUB} --root=${CURR_DIR}/issue1277/ build diff --git a/test/issue1277/.gitignore b/test/issue1277/.gitignore new file mode 100644 index 0000000000..911c163398 --- /dev/null +++ b/test/issue1277/.gitignore @@ -0,0 +1 @@ +!/sample/ diff --git a/test/issue1277/.no_build b/test/issue1277/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1277/dub.json b/test/issue1277/dub.json new file mode 100644 index 0000000000..0d34c521ea --- /dev/null +++ b/test/issue1277/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1277", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1277/sample/source/app.d b/test/issue1277/sample/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue1277/sample/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue1277/source/app.d b/test/issue1277/source/app.d index ab73b3a234..b84fb2826e 100644 --- a/test/issue1277/source/app.d +++ b/test/issue1277/source/app.d @@ -1 +1,12 @@ -void main() {} +import common; + +import std.process; +import std.file; +import std.path; + +void main () { + auto p = spawnProcess( + [dub, "--root=" ~ getcwd().buildPath("sample"), "build"], null, Config.none, "../issue1003-check-empty-ld-flags"); + if (p.wait == 0) + die("Dub should have failed"); +} diff --git "a/test/issue130-unicode-\320\241\320\235\320\220\320\257\320\220\320\241\320\242\320\225\320\257\320\205/dub.sdl" "b/test/issue130-unicode-\320\241\320\235\320\220\320\257\320\220\320\241\320\242\320\225\320\257\320\205/dub.sdl" index 6bc471cf7a..c68488d4c6 100644 --- "a/test/issue130-unicode-\320\241\320\235\320\220\320\257\320\220\320\241\320\242\320\225\320\257\320\205/dub.sdl" +++ "b/test/issue130-unicode-\320\241\320\235\320\220\320\257\320\220\320\241\320\242\320\225\320\257\320\205/dub.sdl" @@ -1 +1 @@ -name "tests" +name "issue130-unicode" diff --git a/test/issue1336-registry/.gitignore b/test/issue1336-registry/.gitignore deleted file mode 100644 index 86e1bdf49c..0000000000 --- a/test/issue1336-registry/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -issue1336-registry.so -issue1336-registry.dylib -issue1336-registry.dll -issue1336-registry.a -issue1336-registry.lib -issue1336-registry-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1336-registry/.no_build b/test/issue1336-registry/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1350-transitive-none-deps/.gitignore b/test/issue1350-transitive-none-deps/.gitignore index 4571d26027..7b19ef120a 100644 --- a/test/issue1350-transitive-none-deps/.gitignore +++ b/test/issue1350-transitive-none-deps/.gitignore @@ -1,15 +1,5 @@ -.dub -docs.json -__dummy.html -docs/ -test -test.so -test.dylib -test.dll -test.a -test.lib -test-test-* -*.exe -*.o -*.obj -*.lst +!/common-dep/ +!/common-none/ +!/dep1 +!/dep2 +!/test.d diff --git a/test/issue1350-transitive-none-deps/.no_run b/test/issue1350-transitive-none-deps/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1350-transitive-none-deps/.no_test b/test/issue1350-transitive-none-deps/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1350-transitive-none-deps/common-dep/dub.sdl b/test/issue1350-transitive-none-deps/common-dep/dub.sdl index e4d29b2412..a6b7bb7df3 100644 --- a/test/issue1350-transitive-none-deps/common-dep/dub.sdl +++ b/test/issue1350-transitive-none-deps/common-dep/dub.sdl @@ -1,4 +1,4 @@ -name "common-dep" +name "issue1350-common-dep" targetType "library" importPaths "." sourceFiles "common.d" diff --git a/test/issue1350-transitive-none-deps/common-none/dub.sdl b/test/issue1350-transitive-none-deps/common-none/dub.sdl index 79986cc395..70d7315878 100644 --- a/test/issue1350-transitive-none-deps/common-none/dub.sdl +++ b/test/issue1350-transitive-none-deps/common-none/dub.sdl @@ -1,3 +1,3 @@ -name "common-none" +name "issue1350-common-none" targetType "none" -dependency "common-dep" path="../common-dep" +dependency "issue1350-common-dep" path="../common-dep" diff --git a/test/issue1350-transitive-none-deps/dep1/dub.sdl b/test/issue1350-transitive-none-deps/dep1/dub.sdl index 432097ae2c..ba412736be 100644 --- a/test/issue1350-transitive-none-deps/dep1/dub.sdl +++ b/test/issue1350-transitive-none-deps/dep1/dub.sdl @@ -1,4 +1,4 @@ -name "dep1" +name "issue1350-dep1" importPaths "." sourceFiles "dep1.d" -dependency "common-none" path="../common-none" +dependency "issue1350-common-none" path="../common-none" diff --git a/test/issue1350-transitive-none-deps/dep2/dub.sdl b/test/issue1350-transitive-none-deps/dep2/dub.sdl index 3157e086b7..d6ad8b82fc 100644 --- a/test/issue1350-transitive-none-deps/dep2/dub.sdl +++ b/test/issue1350-transitive-none-deps/dep2/dub.sdl @@ -1,4 +1,4 @@ -name "dep2" +name "issue1350-dep2" importPaths "." sourceFiles "dep2.d" -dependency "common-none" path="../common-none" +dependency "issue1350-common-none" path="../common-none" diff --git a/test/issue1350-transitive-none-deps/dub.sdl b/test/issue1350-transitive-none-deps/dub.sdl index 5bcd9407c0..1b948e60df 100644 --- a/test/issue1350-transitive-none-deps/dub.sdl +++ b/test/issue1350-transitive-none-deps/dub.sdl @@ -1,5 +1,5 @@ -name "test" +name "issue1350-transitive-none-depss" targetType "executable" sourceFiles "test.d" -dependency "dep1" path="dep1" -dependency "dep2" path="dep2" +dependency "issue1350-dep1" path="dep1" +dependency "issue1350-dep2" path="dep2" diff --git a/test/issue1350-transitive-none-deps/test.config b/test/issue1350-transitive-none-deps/test.config new file mode 100644 index 0000000000..32efffa32d --- /dev/null +++ b/test/issue1350-transitive-none-deps/test.config @@ -0,0 +1 @@ +dub_command = build diff --git a/test/issue1372-ignore-files-in-hidden-dirs.sh b/test/issue1372-ignore-files-in-hidden-dirs.sh deleted file mode 100755 index f4560e9832..0000000000 --- a/test/issue1372-ignore-files-in-hidden-dirs.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - - -BASEDIR=${CURR_DIR}/issue1372-ignore-files-in-hidden-dirs -rm -rf ${BASEDIR}/.dub -rm -rf ${BASEDIR}/issue1372 - -echo "Compile and ignore hidden directories" -${DUB} build --root ${BASEDIR} --config=normal --force -OUTPUT=`${BASEDIR}/issue1372` -if [[ "$OUTPUT" != "no hidden file compiled" ]]; then die $LINENO "Normal compilation failed"; fi - -rm -rf ${BASEDIR}/.dub -rm -rf ${BASEDIR}/issue1372 - - -echo "Compile and explcitly include file in hidden directories" -${DUB} build --root ${BASEDIR} --config=hiddenfile --force -OUTPUT=`${BASEDIR}/issue1372` - -if [[ "$OUTPUT" != "hidden file compiled" ]]; then die $LINENO "Hidden file compilation failed"; fi - -rm -rf ${BASEDIR}/.dub -rm -rf ${BASEDIR}/issue1372 - -echo "Compile and explcitly include extra hidden directories" -${DUB} build --root ${BASEDIR} --config=hiddendir --force -OUTPUT=`${BASEDIR}/issue1372` - -if [[ "$OUTPUT" != "hidden dir compiled" ]]; then die $LINENO "Hidden directory compilation failed"; fi - -rm -rf ${BASEDIR}/.dub -rm -rf ${BASEDIR}/issue1372 diff --git a/test/issue1372-ignore-files-in-hidden-dirs/.gitignore b/test/issue1372-ignore-files-in-hidden-dirs/.gitignore new file mode 100644 index 0000000000..bf44e1c41e --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/.gitignore @@ -0,0 +1,6 @@ +sample/* +!sample/ +!sample/dub.json +!sample/.hiddensource +!sample/source/ +!sample/source/* \ No newline at end of file diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub.json b/test/issue1372-ignore-files-in-hidden-dirs/dub.json index a07edbd232..4c402c579a 100644 --- a/test/issue1372-ignore-files-in-hidden-dirs/dub.json +++ b/test/issue1372-ignore-files-in-hidden-dirs/dub.json @@ -1,22 +1,8 @@ { - "name": "issue1372", - "mainSourceFile": "source/app.d", - "configurations": [ - { - "name": "normal", - "targetType": "executable" - }, - { - "name": "hiddenfile", - "targetType": "executable", - "versions" : ["UseHiddenFile"], - "sourceFiles":["source/.compileMe/hello.d"] - }, - { - "name": "hiddendir", - "targetType": "executable", - "versions" : ["UseHiddenFile"], - "sourcePaths":["source", ".hiddensource"], - "importPaths":["source", ".hiddensource"] - }] + "name": "issue1372-ignore-files-in-hidden-dirs", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d b/test/issue1372-ignore-files-in-hidden-dirs/sample/.hiddensource/hello.d similarity index 100% rename from test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d rename to test/issue1372-ignore-files-in-hidden-dirs/sample/.hiddensource/hello.d diff --git a/test/issue1372-ignore-files-in-hidden-dirs/sample/dub.json b/test/issue1372-ignore-files-in-hidden-dirs/sample/dub.json new file mode 100644 index 0000000000..a07edbd232 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/sample/dub.json @@ -0,0 +1,22 @@ +{ + "name": "issue1372", + "mainSourceFile": "source/app.d", + "configurations": [ + { + "name": "normal", + "targetType": "executable" + }, + { + "name": "hiddenfile", + "targetType": "executable", + "versions" : ["UseHiddenFile"], + "sourceFiles":["source/.compileMe/hello.d"] + }, + { + "name": "hiddendir", + "targetType": "executable", + "versions" : ["UseHiddenFile"], + "sourcePaths":["source", ".hiddensource"], + "importPaths":["source", ".hiddensource"] + }] +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d b/test/issue1372-ignore-files-in-hidden-dirs/sample/source/.AppleDouble/app.d similarity index 100% rename from test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d rename to test/issue1372-ignore-files-in-hidden-dirs/sample/source/.AppleDouble/app.d diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d b/test/issue1372-ignore-files-in-hidden-dirs/sample/source/.compileMe/hello.d similarity index 100% rename from test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d rename to test/issue1372-ignore-files-in-hidden-dirs/sample/source/.compileMe/hello.d diff --git a/test/issue1372-ignore-files-in-hidden-dirs/sample/source/app.d b/test/issue1372-ignore-files-in-hidden-dirs/sample/source/app.d new file mode 100644 index 0000000000..126276e50a --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/sample/source/app.d @@ -0,0 +1,18 @@ +import std.stdio; + +void main() +{ + version(UseHiddenFile) + { + import hello; + helloFun(); + } + else + { + static assert(!__traits(compiles, { + import hello; + helloFun(); + })); + writeln("no hidden file compiled"); + } +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/app.d b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d index 126276e50a..55444cb7dc 100644 --- a/test/issue1372-ignore-files-in-hidden-dirs/source/app.d +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d @@ -1,18 +1,25 @@ -import std.stdio; +import common; -void main() -{ - version(UseHiddenFile) - { - import hello; - helloFun(); - } - else - { - static assert(!__traits(compiles, { - import hello; - helloFun(); - })); - writeln("no hidden file compiled"); - } +import std.algorithm; +import std.process; +import std.file; + +void main () { + log("Compile and ignore hidden directories"); + auto p = teeProcess([dub, "run", "--root=sample", "--config=normal", "--force"]); + if (p.wait != 0) die("Dub run normal failed"); + if (!p.stdout.canFind("no hidden file compiled")) + die("Normal compilation failed"); + + log("compile and explicitly include file in hidden directories"); + p = teeProcess([dub, "run", "--root=sample", "--config=hiddenfile", "--force"]); + if (p.wait != 0) die("Dub run hiddenfile failed"); + if (!p.stdout.canFind("hidden file compiled")) + die("Hidden file compilation failed"); + + log("Compile and explcitly include extra hidden directories"); + p = teeProcess([dub, "run", "--root=sample", "--config=hiddendir", "--force"]); + if (p.wait != 0) die("Dub run hiddendir failed"); + if (!p.stdout.canFind("hidden dir compiled")) + die("Hidden directory compilation failed"); } diff --git a/test/issue1396-pre-post-run-commands.sh b/test/issue1396-pre-post-run-commands.sh deleted file mode 100755 index fdb797e257..0000000000 --- a/test/issue1396-pre-post-run-commands.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1396-pre-post-run-commands -rm -rf .dub -rm -rf test.txt -"$DUB" - -if ! grep -c -e "pre-run" test.txt; then - die $LINENO 'pre run not executed.' -fi - -if ! grep -c -e "post-run-0" test.txt; then - die $LINENO 'post run not executed.' -fi diff --git a/test/issue1396-pre-post-run-commands/.gitignore b/test/issue1396-pre-post-run-commands/.gitignore new file mode 100644 index 0000000000..ef4d6125f0 --- /dev/null +++ b/test/issue1396-pre-post-run-commands/.gitignore @@ -0,0 +1,5 @@ +/sample/* +!/sample/ +!/sample/dub.sdl +!/sample/post-run.sh +!/sample/source/ \ No newline at end of file diff --git a/test/issue1396-pre-post-run-commands/.no_build b/test/issue1396-pre-post-run-commands/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1396-pre-post-run-commands/dub.json b/test/issue1396-pre-post-run-commands/dub.json new file mode 100644 index 0000000000..88edd55401 --- /dev/null +++ b/test/issue1396-pre-post-run-commands/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1396-pre-post-run-commands", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1396-pre-post-run-commands/dub.sdl b/test/issue1396-pre-post-run-commands/sample/dub.sdl similarity index 100% rename from test/issue1396-pre-post-run-commands/dub.sdl rename to test/issue1396-pre-post-run-commands/sample/dub.sdl diff --git a/test/issue1396-pre-post-run-commands/post-run.sh b/test/issue1396-pre-post-run-commands/sample/post-run.sh similarity index 100% rename from test/issue1396-pre-post-run-commands/post-run.sh rename to test/issue1396-pre-post-run-commands/sample/post-run.sh diff --git a/test/issue1396-pre-post-run-commands/sample/source/app.d b/test/issue1396-pre-post-run-commands/sample/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue1396-pre-post-run-commands/sample/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue1396-pre-post-run-commands/source/app.d b/test/issue1396-pre-post-run-commands/source/app.d index ab73b3a234..ef09671c5e 100644 --- a/test/issue1396-pre-post-run-commands/source/app.d +++ b/test/issue1396-pre-post-run-commands/source/app.d @@ -1 +1,18 @@ -void main() {} +import common; + +import std.algorithm; +import std.process; +import std.file; + +void main () { + if ("sample/text.txt".exists) remove("sample/test.txt"); + + if (spawnProcess(dub, null, Config.none, "sample").wait) + die("Dub run failed"); + + immutable got = readText("sample/test.txt"); + if (!got.canFind("pre-run")) + die("pre run not executed."); + if (!got.canFind("post-run-0")) + die("post run not executed."); +} diff --git a/test/issue1396-pre-post-run-commands/test.config b/test/issue1396-pre-post-run-commands/test.config new file mode 100644 index 0000000000..76a192f538 --- /dev/null +++ b/test/issue1396-pre-post-run-commands/test.config @@ -0,0 +1 @@ +os = [linux, osx] \ No newline at end of file diff --git a/test/issue1401-file-system-pkg-supplier/.gitignore b/test/issue1401-file-system-pkg-supplier/.gitignore new file mode 100644 index 0000000000..911c163398 --- /dev/null +++ b/test/issue1401-file-system-pkg-supplier/.gitignore @@ -0,0 +1 @@ +!/sample/ diff --git a/test/issue1401-file-system-pkg-supplier/.no_build b/test/issue1401-file-system-pkg-supplier/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1401-file-system-pkg-supplier/dub.json b/test/issue1401-file-system-pkg-supplier/dub.json new file mode 100644 index 0000000000..e957f6fbf0 --- /dev/null +++ b/test/issue1401-file-system-pkg-supplier/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1401-file-system-pkg-supplier", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1401-file-system-pkg-supplier/fs-json-dubpackage-1.0.7.zip b/test/issue1401-file-system-pkg-supplier/sample/fs-json-dubpackage-1.0.7.zip similarity index 100% rename from test/issue1401-file-system-pkg-supplier/fs-json-dubpackage-1.0.7.zip rename to test/issue1401-file-system-pkg-supplier/sample/fs-json-dubpackage-1.0.7.zip diff --git a/test/issue1401-file-system-pkg-supplier/fs-sdl-dubpackage-1.0.5.zip b/test/issue1401-file-system-pkg-supplier/sample/fs-sdl-dubpackage-1.0.5.zip similarity index 100% rename from test/issue1401-file-system-pkg-supplier/fs-sdl-dubpackage-1.0.5.zip rename to test/issue1401-file-system-pkg-supplier/sample/fs-sdl-dubpackage-1.0.5.zip diff --git a/test/issue1401-file-system-pkg-supplier/fs-sdl-dubpackage-1.0.6.zip b/test/issue1401-file-system-pkg-supplier/sample/fs-sdl-dubpackage-1.0.6.zip similarity index 100% rename from test/issue1401-file-system-pkg-supplier/fs-sdl-dubpackage-1.0.6.zip rename to test/issue1401-file-system-pkg-supplier/sample/fs-sdl-dubpackage-1.0.6.zip diff --git a/test/issue1401-file-system-pkg-supplier/source/app.d b/test/issue1401-file-system-pkg-supplier/source/app.d new file mode 100644 index 0000000000..8da397f7b6 --- /dev/null +++ b/test/issue1401-file-system-pkg-supplier/source/app.d @@ -0,0 +1,31 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + foreach (pkg; ["fs-json-dubpackage", "fs-sdl-dubpackage"]) + execute([dub, "remove", pkg, "--non-interactive"]); + + immutable registryArgs = [ "--skip-registry=all", "--registry=file://" ~ getcwd() ~ "/sample" ]; + + log("Trying to get fs-sdl-dubpackage (1.0.5)"); + if (spawnProcess([dub, "fetch", "fs-sdl-dubpackage", "--version=1.0.5"] ~ registryArgs).wait != 0) + die("dub fetch failed"); + if (spawnProcess([dub, "remove", "fs-sdl-dubpackage@1.0.5"]).wait != 0) + die("DUB did not install package from file system."); + + log("Trying to get fs-sdl-dubpackage (latest)"); + if (spawnProcess([dub, "fetch", "fs-sdl-dubpackage"] ~ registryArgs).wait != 0) + die("dub fetch failed"); + if (spawnProcess([dub, "remove", "fs-sdl-dubpackage@1.0.6"]).wait != 0) + die("DUB did not install latest package from file system."); + + log("Trying to get fs-json-dubpackage (1.0.7)"); + if (spawnProcess([dub, "fetch", "fs-json-dubpackage@1.0.7"] ~ registryArgs).wait != 0) + die("dub fetch failed"); + if (spawnProcess([dub, "remove", "fs-json-dubpackage@1.0.7"]).wait != 0) + die("DUB did not install package from file system."); +} diff --git a/test/issue1401-filesystem-supplier.sh b/test/issue1401-filesystem-supplier.sh deleted file mode 100755 index 18d1fcd8c3..0000000000 --- a/test/issue1401-filesystem-supplier.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -${DUB} remove fs-json-dubpackage --non-interactive 2>/dev/null || true -${DUB} remove fs-sdl-dubpackage --non-interactive 2>/dev/null || true - -echo "Trying to get fs-sdl-dubpackage (1.0.5)" -${DUB} fetch fs-sdl-dubpackage --version=1.0.5 --skip-registry=all --registry=file://"$DIR"/issue1401-file-system-pkg-supplier - -if ! ${DUB} remove fs-sdl-dubpackage@1.0.5 2>/dev/null; then - die $LINENO 'DUB did not install package from file system.' -fi - -echo "Trying to get fs-sdl-dubpackage (latest)" -${DUB} fetch fs-sdl-dubpackage --skip-registry=all --registry=file://"$DIR"/issue1401-file-system-pkg-supplier - -if ! ${DUB} remove fs-sdl-dubpackage@1.0.6 2>/dev/null; then - die $LINENO 'DUB did not install latest package from file system.' -fi - -echo "Trying to get fs-json-dubpackage (1.0.7)" -${DUB} fetch fs-json-dubpackage@1.0.7 --skip-registry=all --registry=file://"$DIR"/issue1401-file-system-pkg-supplier - -if ! ${DUB} remove fs-json-dubpackage@1.0.7 2>/dev/null; then - die $LINENO 'DUB did not install package from file system.' -fi diff --git a/test/issue1408-inherit-linker-files/.gitignore b/test/issue1408-inherit-linker-files/.gitignore new file mode 100644 index 0000000000..2649a54269 --- /dev/null +++ b/test/issue1408-inherit-linker-files/.gitignore @@ -0,0 +1,3 @@ +!/*.d +!/dub.sdl +!/lib/ \ No newline at end of file diff --git a/test/issue1408-inherit-linker-files/.no_run b/test/issue1408-inherit-linker-files/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1408-inherit-linker-files/.no_test b/test/issue1408-inherit-linker-files/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1408-inherit-linker-files/dub.sdl b/test/issue1408-inherit-linker-files/dub.sdl index d26b1c9309..284ecd7018 100644 --- a/test/issue1408-inherit-linker-files/dub.sdl +++ b/test/issue1408-inherit-linker-files/dub.sdl @@ -1,4 +1,4 @@ -name "test" +name "issue1408-inherit-linker-files" targetType "executable" dependency ":dep" version="*" sourceFiles "main.d" @@ -8,7 +8,7 @@ importPaths "." subPackage { name "dep" sourceFiles "dep.d" - sourceFiles "lib/liblib.a" platform="posix" - sourceFiles "lib/lib.lib" platform="windows" + sourceFiles "lib/libissue1408-lib.a" platform="posix" + sourceFiles "lib/issue1408-lib.lib" platform="windows" preBuildCommands "$DUB_EXE build --root=\"$PACKAGE_DIR/lib\"" } diff --git a/test/issue1408-inherit-linker-files/lib/dub.sdl b/test/issue1408-inherit-linker-files/lib/dub.sdl index 0706e67df9..e82a430676 100644 --- a/test/issue1408-inherit-linker-files/lib/dub.sdl +++ b/test/issue1408-inherit-linker-files/lib/dub.sdl @@ -1,3 +1,3 @@ -name "lib" +name "issue1408-lib" targetType "staticLibrary" sourceFiles "lib.d" diff --git a/test/issue1408-inherit-linker-files/test.config b/test/issue1408-inherit-linker-files/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/issue1408-inherit-linker-files/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/issue1416-maven-repo-pkg-supplier.sh b/test/issue1416-maven-repo-pkg-supplier.sh deleted file mode 100755 index 4b65f52187..0000000000 --- a/test/issue1416-maven-repo-pkg-supplier.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -PORT=$(getRandomPort) - -${DUB} remove maven-dubpackage --non-interactive 2>/dev/null || true - -${DUB} build --single "$DIR"/test_registry.d -"$DIR"/test_registry --folder="$DIR/issue1416-maven-repo-pkg-supplier" --port=$PORT & -PID=$! -sleep 1 -trap 'kill $PID 2>/dev/null || true' exit - -echo "Trying to download maven-dubpackage (1.0.5)" -${DUB} fetch maven-dubpackage@1.0.5 --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages - -if ! ${DUB} remove maven-dubpackage@1.0.5 2>/dev/null; then - die $LINENO 'DUB did not install package from maven registry.' -fi - -echo "Trying to download maven-dubpackage (latest)" -${DUB} fetch maven-dubpackage --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages - -if ! ${DUB} remove maven-dubpackage@1.0.6 2>/dev/null; then - die $LINENO 'DUB fetch did not install latest package from maven registry.' -fi - -echo "Trying to search (exact) maven-dubpackage" -${DUB} search maven-dubpackage --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages | grep -c "maven-dubpackage (1.0.6)" diff --git a/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend b/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend deleted file mode 100644 index 4817f99644..0000000000 --- a/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.077 diff --git a/test/issue1416-maven-repo-pkg-supplier/.gitignore b/test/issue1416-maven-repo-pkg-supplier/.gitignore deleted file mode 100644 index 304e9559a5..0000000000 --- a/test/issue1416-maven-repo-pkg-supplier/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -*.exe -*.o -*.obj -*.lst diff --git a/test/issue1416-maven-repo-pkg-supplier/.no_build b/test/issue1416-maven-repo-pkg-supplier/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1416-maven-repo-pkg-supplier/dub.json b/test/issue1416-maven-repo-pkg-supplier/dub.json new file mode 100644 index 0000000000..617f3dc872 --- /dev/null +++ b/test/issue1416-maven-repo-pkg-supplier/dub.json @@ -0,0 +1,11 @@ +{ + "name": "issue1416-maven-repo-pkg-supplier", + "dependencies": { + "common": { + "path": "../common" + }, + "test_registry_helper": { + "path": "../extra/test_registry" + } + } +} diff --git a/test/issue1416-maven-repo-pkg-supplier/source/app.d b/test/issue1416-maven-repo-pkg-supplier/source/app.d new file mode 100644 index 0000000000..576b68ba08 --- /dev/null +++ b/test/issue1416-maven-repo-pkg-supplier/source/app.d @@ -0,0 +1,38 @@ +import common; +import test_registry_helper; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + auto testRegistry = TestRegistry("../extra/issue1416-maven-repo-pkg-supplier"); + immutable registryArgs = [ + "--skip-registry=all", + "--registry=mvn+http://localhost:" ~ testRegistry.port ~ "/maven/release/dubpackages", + ]; + + execute([dub, "remove", "maven-dubpackage", "--non-interactive"]); + + log("Trying to download maven-dubpackage (1.0.5)"); + + if (spawnProcess([dub, "fetch", "maven-dubpackage@1.0.5"] ~ registryArgs).wait != 0) + die("Dub fetch failed"); + if (spawnProcess([dub, "remove", "maven-dubpackage@1.0.5"]).wait != 0) + die("DUB did not install package from maven registry."); + + log("Trying to download maven-dubpackage (latest)"); + + if (spawnProcess([dub, "fetch", "maven-dubpackage"] ~ registryArgs).wait != 0) + die("Dub fetch failed"); + if (spawnProcess([dub, "remove", "maven-dubpackage@1.0.6"]).wait != 0) + die("DUB fetch did not install latest package from maven registry."); + + log("Trying to search (exact) maven-dubpackage"); + auto p = teeProcess([dub, "search", "maven-dubpackage"] ~ registryArgs); + if (p.wait != 0) + die("DUB search failed"); + if (!p.stdout.canFind("maven-dubpackage (1.0.6)")) + die("DUB search did not find the correct package"); +} diff --git a/test/issue1416-maven-repo-pkg-supplier/test.config b/test/issue1416-maven-repo-pkg-supplier/test.config new file mode 100644 index 0000000000..b034b4d269 --- /dev/null +++ b/test/issue1416-maven-repo-pkg-supplier/test.config @@ -0,0 +1,2 @@ +locks = test_registry +dc_backend = [dmd, ldc] diff --git a/test/issue1427-betterC/.gitignore b/test/issue1427-betterC/.gitignore deleted file mode 100644 index 0fd9d379b1..0000000000 --- a/test/issue1427-betterC/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -test -*.o -*.exe -.dub \ No newline at end of file diff --git a/test/issue1427-betterC/.min_frontend b/test/issue1427-betterC/.min_frontend deleted file mode 100644 index 67aaf4ad8d..0000000000 --- a/test/issue1427-betterC/.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.078 diff --git a/test/issue1427-betterC/.no_run b/test/issue1427-betterC/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1427-betterC/.no_test b/test/issue1427-betterC/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1427-betterC/dub.json b/test/issue1427-betterC/dub.json index d6e9256637..c680ea4e30 100644 --- a/test/issue1427-betterC/dub.json +++ b/test/issue1427-betterC/dub.json @@ -1,4 +1,4 @@ { - "name": "test", + "name": "issue1427-betterC", "buildOptions": ["betterC"] -} \ No newline at end of file +} diff --git a/test/issue1447-build-settings-vars.sh b/test/issue1447-build-settings-vars.sh deleted file mode 100755 index f06a7fa040..0000000000 --- a/test/issue1447-build-settings-vars.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -set -e - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if [[ `uname -m` == "i386" ]]; then - ARCH=x86 -elif [[ `uname -m` == "i686" ]]; then - ARCH=x86 -elif [[ `uname -m` == "arm64" ]]; then - ARCH="aarch64" -else - ARCH=$(uname -m) -fi - -rm -rf ${CURR_DIR}/issue1447-build-settings-vars/.dub -rm -rf ${CURR_DIR}/issue1447-build-settings-vars/test - -${DUB} build --root ${CURR_DIR}/issue1447-build-settings-vars --arch=$ARCH -OUTPUT=`${CURR_DIR}/issue1447-build-settings-vars/test` - -rm -rf ${CURR_DIR}/issue1447-build-settings-vars/.dub -rm -rf ${CURR_DIR}/issue1447-build-settings-vars/test - -if [[ "$OUTPUT" != "$ARCH" ]]; then die $LINENO "Build settings ARCH var incorrect"; fi diff --git a/test/issue1447-build-settings-vars/.gitignore b/test/issue1447-build-settings-vars/.gitignore new file mode 100644 index 0000000000..33a972a236 --- /dev/null +++ b/test/issue1447-build-settings-vars/.gitignore @@ -0,0 +1,5 @@ +/sample/* +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/view-*/ diff --git a/test/issue1447-build-settings-vars/.no_run b/test/issue1447-build-settings-vars/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1447-build-settings-vars/.no_test b/test/issue1447-build-settings-vars/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1447-build-settings-vars/dub.json b/test/issue1447-build-settings-vars/dub.json index 9f5d345d4e..42cf2eb264 100644 --- a/test/issue1447-build-settings-vars/dub.json +++ b/test/issue1447-build-settings-vars/dub.json @@ -1,4 +1,8 @@ { - "name": "test", - "stringImportPaths": ["view-$ARCH"] -} \ No newline at end of file + "name": "issue1447-build-settings-vars", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1447-build-settings-vars/sample/dub.json b/test/issue1447-build-settings-vars/sample/dub.json new file mode 100644 index 0000000000..38165d43e9 --- /dev/null +++ b/test/issue1447-build-settings-vars/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "test", + "stringImportPaths": ["view-$ARCH"] +} diff --git a/test/issue1447-build-settings-vars/sample/source/app.d b/test/issue1447-build-settings-vars/sample/source/app.d new file mode 100644 index 0000000000..3e94dfc9e6 --- /dev/null +++ b/test/issue1447-build-settings-vars/sample/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln(import("arch")); +} diff --git a/test/issue1447-build-settings-vars/view-aarch64/arch b/test/issue1447-build-settings-vars/sample/view-aarch64/arch similarity index 100% rename from test/issue1447-build-settings-vars/view-aarch64/arch rename to test/issue1447-build-settings-vars/sample/view-aarch64/arch diff --git a/test/issue1447-build-settings-vars/view-x86/arch b/test/issue1447-build-settings-vars/sample/view-x86/arch similarity index 100% rename from test/issue1447-build-settings-vars/view-x86/arch rename to test/issue1447-build-settings-vars/sample/view-x86/arch diff --git a/test/issue1447-build-settings-vars/view-x86_64/arch b/test/issue1447-build-settings-vars/sample/view-x86_64/arch similarity index 100% rename from test/issue1447-build-settings-vars/view-x86_64/arch rename to test/issue1447-build-settings-vars/sample/view-x86_64/arch diff --git a/test/issue1447-build-settings-vars/source/app.d b/test/issue1447-build-settings-vars/source/app.d index 3e94dfc9e6..09cbe51b32 100644 --- a/test/issue1447-build-settings-vars/source/app.d +++ b/test/issue1447-build-settings-vars/source/app.d @@ -1,6 +1,31 @@ -import std.stdio; +import common; -void main() -{ - writeln(import("arch")); +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.string; + +void main () { + version(AArch64) + if (environment["DC"].baseName.canFind("ldmd")) + skip("dub doesn't allow passing `-arch aarch64` to ldmd2"); + + chdir("sample"); + + auto arch = execute(["uname", "-m"]).output.strip; + if (arch == "i386") + arch = "x86"; + if (arch == "i686") + arch = "x86"; + if (arch == "arm64") + arch = "aarch64"; + + if (spawnProcess([dub, "build", "--arch=" ~ arch]).wait != 0) + die("Dub build failed"); + auto p = teeProcess(["./test"]); + p.wait; + immutable output = p.stdout.chomp; + if (output != arch) + die("Build settings ARCH was incorrect. Expected ", arch, " got ", output); } diff --git a/test/issue1447-build-settings-vars/test.config b/test/issue1447-build-settings-vars/test.config new file mode 100644 index 0000000000..3075fc310d --- /dev/null +++ b/test/issue1447-build-settings-vars/test.config @@ -0,0 +1 @@ +os = [linux, osx] diff --git a/test/issue1474-generate-source.script.d b/test/issue1474-generate-source.script.d deleted file mode 100644 index d345f58437..0000000000 --- a/test/issue1474-generate-source.script.d +++ /dev/null @@ -1,29 +0,0 @@ -/+ dub.sdl: - name "issue1474-generate-source" -+/ - -module issue1474_generate_source; - -import std.process; -import std.stdio; -import std.algorithm; -import std.path; - -int main() -{ - const dub = environment.get("DUB", buildPath(__FILE_FULL_PATH__.dirName.dirName, "bin", "dub")); - const curr_dir = environment.get("CURR_DIR", buildPath(__FILE_FULL_PATH__.dirName)); - const dc = environment.get("DC", "dmd"); - const cmd = [dub, "build", "--compiler", dc]; - const result = execute(cmd, null, Config.none, size_t.max, curr_dir.buildPath("issue1474")); - if (result.status || result.output.canFind("Failed")) - { - writefln("\n> %-(%s %)", cmd); - writeln("==========================================================="); - writeln(result.output); - writeln("==========================================================="); - writeln("Last command failed with exit code ", result.status, '\n'); - return 1; - } - return 0; -} diff --git a/test/issue1474-generate-source/.gitignore b/test/issue1474-generate-source/.gitignore new file mode 100644 index 0000000000..6b0d66d00a --- /dev/null +++ b/test/issue1474-generate-source/.gitignore @@ -0,0 +1,7 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d +!/sample/ext/ +!/sample/ext/kekw.d \ No newline at end of file diff --git a/test/issue1474-generate-source/dub.json b/test/issue1474-generate-source/dub.json new file mode 100644 index 0000000000..7f87a9620e --- /dev/null +++ b/test/issue1474-generate-source/dub.json @@ -0,0 +1,9 @@ +{ + "name": "issue1474-generate-source", + "targetType": "executable", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1474/dub.json b/test/issue1474-generate-source/sample/dub.json similarity index 100% rename from test/issue1474/dub.json rename to test/issue1474-generate-source/sample/dub.json diff --git a/test/issue1474/ext/kekw.d b/test/issue1474-generate-source/sample/ext/kekw.d similarity index 100% rename from test/issue1474/ext/kekw.d rename to test/issue1474-generate-source/sample/ext/kekw.d diff --git a/test/issue1474/source/app.d b/test/issue1474-generate-source/sample/source/app.d similarity index 100% rename from test/issue1474/source/app.d rename to test/issue1474-generate-source/sample/source/app.d diff --git a/test/issue1474-generate-source/source/app.d b/test/issue1474-generate-source/source/app.d new file mode 100644 index 0000000000..ee8dcf07aa --- /dev/null +++ b/test/issue1474-generate-source/source/app.d @@ -0,0 +1,16 @@ +import common; + +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + immutable generatedFile = "ext/fortytwo.d"; + if (exists(generatedFile)) + remove(generatedFile); + + if (spawnProcess([dub, "build"]).wait != 0) + die("Dub failed to build with generated sources"); +} diff --git a/test/issue1474/.no_build b/test/issue1474/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1477-subpackage-visuald-paths.sh b/test/issue1477-subpackage-visuald-paths.sh deleted file mode 100755 index 7f55bcfc7b..0000000000 --- a/test/issue1477-subpackage-visuald-paths.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -# Check project files generated from project "root" -cd ${CURR_DIR}/issue1477-subpackage-visuald-paths -rm -rf .dub -${DUB} generate visuald :subpackage_a -if ! grep " ${CURR_DIR}/output-1504.txt - -grep "env_variables_work" < ${CURR_DIR}/output-1504.txt - -# Don't manage to make it work -#grep "Invalid source" < ${CURR_DIR}/output-1504.txt && true - diff --git a/test/issue1504-envvar-in-path/.gitignore b/test/issue1504-envvar-in-path/.gitignore new file mode 100644 index 0000000000..bf3d695758 --- /dev/null +++ b/test/issue1504-envvar-in-path/.gitignore @@ -0,0 +1,7 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d +!/sample/teststrings/ +!/sample/teststrings/* diff --git a/test/issue1504-envvar-in-path/.no_build b/test/issue1504-envvar-in-path/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1504-envvar-in-path/dub.json b/test/issue1504-envvar-in-path/dub.json index 1858aa64f3..a3e8fe05bf 100644 --- a/test/issue1504-envvar-in-path/dub.json +++ b/test/issue1504-envvar-in-path/dub.json @@ -1,5 +1,8 @@ { - "name": "test", - "stringImportPaths": ["$MY_VARIABLE"] + "name": "issue1503-envvar-in-path", + "dependencies": { + "common": { + "path": "../common" + } + } } - diff --git a/test/issue1504-envvar-in-path/sample/dub.json b/test/issue1504-envvar-in-path/sample/dub.json new file mode 100644 index 0000000000..0e05408505 --- /dev/null +++ b/test/issue1504-envvar-in-path/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "test", + "stringImportPaths": ["$MY_VARIABLE"] +} diff --git a/test/issue1504-envvar-in-path/sample/source/app.d b/test/issue1504-envvar-in-path/sample/source/app.d new file mode 100644 index 0000000000..2b03f41af9 --- /dev/null +++ b/test/issue1504-envvar-in-path/sample/source/app.d @@ -0,0 +1,5 @@ +pragma(msg, import("message.txt")); + +void main() +{ +} diff --git a/test/issue1504-envvar-in-path/teststrings/message.txt b/test/issue1504-envvar-in-path/sample/teststrings/message.txt similarity index 100% rename from test/issue1504-envvar-in-path/teststrings/message.txt rename to test/issue1504-envvar-in-path/sample/teststrings/message.txt diff --git a/test/issue1504-envvar-in-path/source/app.d b/test/issue1504-envvar-in-path/source/app.d index 2b03f41af9..77ad26bf76 100644 --- a/test/issue1504-envvar-in-path/source/app.d +++ b/test/issue1504-envvar-in-path/source/app.d @@ -1,5 +1,20 @@ -pragma(msg, import("message.txt")); +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + auto p = teeProcess([dub, "build", "--force", "--root=sample"], + Redirect.stdout | Redirect.stderrToStdout, + ["MY_VARIABLE": "teststrings"]); + if (p.wait != 0) + die("Dub build failed"); + + if (!p.stdout.canFind("env_variables_work")) + die("couldn't find `env_variables_work` in dub build output"); + if (p.stdout.canFind("Invalid source")) + die("found `Invalid source` in dub build output"); -void main() -{ } diff --git a/test/issue1505-single-file-package-dynamic-library.sh b/test/issue1505-single-file-package-dynamic-library.sh deleted file mode 100755 index 0a78b2072a..0000000000 --- a/test/issue1505-single-file-package-dynamic-library.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -set -eux -o pipefail - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR} - -rm -f libsingle-file-test-dynamic-library.{so,dylib} -rm -f single-file-test-dynamic-library.dll - -${DUB} build --single issue1505-single-file-package-dynamic-library.d -if [[ ! -f libsingle-file-test-dynamic-library.so ]] \ -&& [[ ! -f libsingle-file-test-dynamic-library.dylib ]] \ -&& [[ ! -f single-file-test-dynamic-library.dll ]]; then - die $LINENO 'Normal invocation did not produce a dynamic library in the current directory' -fi -rm -f libsingle-file-test-dynamic-library.{so,dylib} -rm -f single-file-test-dynamic-library.dll diff --git a/test/issue1505-single-file-package-dynamic-library/.gitignore b/test/issue1505-single-file-package-dynamic-library/.gitignore new file mode 100644 index 0000000000..747c7b88e5 --- /dev/null +++ b/test/issue1505-single-file-package-dynamic-library/.gitignore @@ -0,0 +1 @@ +!/sample.d diff --git a/test/issue1505-single-file-package-dynamic-library/dub.json b/test/issue1505-single-file-package-dynamic-library/dub.json new file mode 100644 index 0000000000..3fc843849c --- /dev/null +++ b/test/issue1505-single-file-package-dynamic-library/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1505-single-file-package-dynamic-library", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1505-single-file-package-dynamic-library.d b/test/issue1505-single-file-package-dynamic-library/sample.d similarity index 100% rename from test/issue1505-single-file-package-dynamic-library.d rename to test/issue1505-single-file-package-dynamic-library/sample.d diff --git a/test/issue1505-single-file-package-dynamic-library/source/app.d b/test/issue1505-single-file-package-dynamic-library/source/app.d new file mode 100644 index 0000000000..2aa8cf1277 --- /dev/null +++ b/test/issue1505-single-file-package-dynamic-library/source/app.d @@ -0,0 +1,24 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + immutable files = [ + "libsingle-file-test-dynamic-library.so", + "libsingle-file-test-dynamic-library.dylib", + "single-file-test-dynamic-library.dll", + ]; + foreach (file; files) + if (exists(file)) remove(file); + + if (spawnProcess([dub, "build", "--single", "sample.d"]).wait != 0) + die("Dub build failed"); + + foreach (file; files) + if (exists(file)) return; + + die("Normal invocation did not produce a dynamic library in the current directory"); +} diff --git a/test/issue1524-maven-upgrade-dependency-tree.sh b/test/issue1524-maven-upgrade-dependency-tree.sh deleted file mode 100755 index 05dd22ff6c..0000000000 --- a/test/issue1524-maven-upgrade-dependency-tree.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -PORT=$(getRandomPort) - -${DUB} remove maven-dubpackage-a --non-interactive 2>/dev/null || true -${DUB} remove maven-dubpackage-b --non-interactive 2>/dev/null || true - -${DUB} build --single "$DIR"/test_registry.d -"$DIR"/test_registry --folder="$DIR/issue1524-maven-upgrade-dependency-tree" --port=$PORT & -PID=$! -sleep 1 -trap 'kill $PID 2>/dev/null || true' exit - -echo "Trying to download maven-dubpackage-a (1.0.5) with dependency to maven-dubpackage-b (1.0.6)" -${DUB} upgrade --root "$DIR/issue1524-maven-upgrade-dependency-tree" --skip-registry=standard --registry=mvn+http://localhost:$PORT/maven/release/dubpackages - -if ! ${DUB} remove maven-dubpackage-a@1.0.5 2>/dev/null; then - die $LINENO 'DUB did not install package "maven-dubpackage-a" from maven registry.' -fi - -if ! ${DUB} remove maven-dubpackage-b@1.0.6 2>/dev/null; then - die $LINENO 'DUB did not install package "maven-dubpackage-b" from maven registry.' -fi - diff --git a/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend b/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend deleted file mode 100644 index 4817f99644..0000000000 --- a/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.077 diff --git a/test/issue1524-maven-upgrade-dependency-tree/.gitignore b/test/issue1524-maven-upgrade-dependency-tree/.gitignore index 304e9559a5..349b2d0efc 100644 --- a/test/issue1524-maven-upgrade-dependency-tree/.gitignore +++ b/test/issue1524-maven-upgrade-dependency-tree/.gitignore @@ -1,8 +1,7 @@ -.dub -docs.json -__dummy.html -docs/ -*.exe -*.o -*.obj -*.lst +/sample/** +!/sample/ +!/sample/dub.json +!/sample/maven/ +!/sample/maven/** +!/sample/source/ +!/sample/source/*.d \ No newline at end of file diff --git a/test/issue1524-maven-upgrade-dependency-tree/.no_build b/test/issue1524-maven-upgrade-dependency-tree/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1524-maven-upgrade-dependency-tree/dub.json b/test/issue1524-maven-upgrade-dependency-tree/dub.json index 131a264d30..274c5732c9 100644 --- a/test/issue1524-maven-upgrade-dependency-tree/dub.json +++ b/test/issue1524-maven-upgrade-dependency-tree/dub.json @@ -1,6 +1,11 @@ { - "name": "test", + "name": "issue1524-maven-upgrade-dependency-tree", "dependencies": { - "maven-dubpackage-a": "~>1.0.5" + "common": { + "path": "../common" + }, + "test_registry_helper": { + "path": "../extra/test_registry" + } } -} \ No newline at end of file +} diff --git a/test/issue1524-maven-upgrade-dependency-tree/sample/dub.json b/test/issue1524-maven-upgrade-dependency-tree/sample/dub.json new file mode 100644 index 0000000000..8005251f7c --- /dev/null +++ b/test/issue1524-maven-upgrade-dependency-tree/sample/dub.json @@ -0,0 +1,6 @@ +{ + "name": "test", + "dependencies": { + "maven-dubpackage-a": "~>1.0.5" + } +} diff --git a/test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-a/1.0.5/maven-dubpackage-a-1.0.5.zip b/test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-a/1.0.5/maven-dubpackage-a-1.0.5.zip similarity index 100% rename from test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-a/1.0.5/maven-dubpackage-a-1.0.5.zip rename to test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-a/1.0.5/maven-dubpackage-a-1.0.5.zip diff --git a/test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-a/maven-metadata.xml b/test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-a/maven-metadata.xml similarity index 100% rename from test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-a/maven-metadata.xml rename to test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-a/maven-metadata.xml diff --git a/test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-b/1.0.6/maven-dubpackage-b-1.0.6.zip b/test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-b/1.0.6/maven-dubpackage-b-1.0.6.zip similarity index 100% rename from test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-b/1.0.6/maven-dubpackage-b-1.0.6.zip rename to test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-b/1.0.6/maven-dubpackage-b-1.0.6.zip diff --git a/test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-b/maven-metadata.xml b/test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-b/maven-metadata.xml similarity index 100% rename from test/issue1524-maven-upgrade-dependency-tree/maven/release/dubpackages/maven-dubpackage-b/maven-metadata.xml rename to test/issue1524-maven-upgrade-dependency-tree/sample/maven/release/dubpackages/maven-dubpackage-b/maven-metadata.xml diff --git a/test/issue1524-maven-upgrade-dependency-tree/sample/source/app.d b/test/issue1524-maven-upgrade-dependency-tree/sample/source/app.d new file mode 100644 index 0000000000..ef93217bed --- /dev/null +++ b/test/issue1524-maven-upgrade-dependency-tree/sample/source/app.d @@ -0,0 +1 @@ +void main(){} \ No newline at end of file diff --git a/test/issue1524-maven-upgrade-dependency-tree/source/app.d b/test/issue1524-maven-upgrade-dependency-tree/source/app.d index ef93217bed..99893e7862 100644 --- a/test/issue1524-maven-upgrade-dependency-tree/source/app.d +++ b/test/issue1524-maven-upgrade-dependency-tree/source/app.d @@ -1 +1,28 @@ -void main(){} \ No newline at end of file +import common; +import test_registry_helper; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + auto testRegistry = TestRegistry("sample"); + immutable registryArgs = [ + "--skip-registry=standard", + "--registry=mvn+http://localhost:" ~ testRegistry.port ~ "/maven/release/dubpackages", + ]; + + // ignore errors + execute([dub, "remove", "maven-dubpackage-a", "--non-interactive"]); + execute([dub, "remove", "maven-dubpackage-b", "--non-interactive"]); + + if (spawnProcess([dub, "upgrade", "--root=sample"] ~ registryArgs).wait != 0) + die("Dub upgrade failed"); + + if (spawnProcess([dub, "remove", "maven-dubpackage-a@1.0.5"]).wait != 0) + die(`DUB did not install package "maven-dubpackage-a" from maven registry.`); + + if (spawnProcess([dub, "remove", "maven-dubpackage-b@1.0.6"]).wait != 0) + die(`DUB did not install package "maven-dubpackage-b" from maven registry.`); +} diff --git a/test/issue1524-maven-upgrade-dependency-tree/test.config b/test/issue1524-maven-upgrade-dependency-tree/test.config new file mode 100644 index 0000000000..b034b4d269 --- /dev/null +++ b/test/issue1524-maven-upgrade-dependency-tree/test.config @@ -0,0 +1,2 @@ +locks = test_registry +dc_backend = [dmd, ldc] diff --git a/test/issue1531-toolchain-requirements.sh b/test/issue1531-toolchain-requirements.sh deleted file mode 100755 index 638167aa58..0000000000 --- a/test/issue1531-toolchain-requirements.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash -set -e - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cat << EOF | $DUB - || die $LINENO "Did not pass without toolchainRequirements" -/+ dub.sdl: -+/ -void main() {} -EOF - -# pass test dub requirement given as $1 -function test_dub_req_pass { - cat << EOF | $DUB - || die $LINENO "Did not pass requirement dub=\"$1\"" -/+ dub.sdl: - toolchainRequirements dub="$1" -+/ -void main() {} -EOF -} - -# fail test dub requirement given as $1 -function test_dub_req_fail { - ! cat << EOF | $DUB - || die $LINENO "Did not pass requirement dub=\"$1\"" -/+ dub.sdl: - toolchainRequirements dub="$1" -+/ -void main() {} -EOF -} - -test_dub_req_pass ">=1.7.0" -test_dub_req_fail "~>0.9" -test_dub_req_fail "~>999.0" - -# extract compiler version -if [[ $DC == *ldc* ]] || [[ $DC == *ldmd* ]]; then - VER_REG='\((([[:digit:]]+)(\.[[:digit:]]+\.[[:digit:]]+[A-Za-z0-9.+-]*))\)' - DC_NAME=ldc -elif [[ $DC == *dmd* ]]; then - VER_REG='v(([[:digit:]]+)(\.[[:digit:]]+\.[[:digit:]]+[A-Za-z0-9.+-]*))' - DC_NAME=dmd -elif [[ $DC == *gdc* ]]; then - VER_REG='\) (([[:digit:]]+)(\.[[:digit:]]+\.[[:digit:]]+[A-Za-z0-9.+-]*))' - DC_NAME=gdc -else - die $LINENO "Did not recognize compiler" -fi -if [[ $($DC --version) =~ $VER_REG ]]; then - DC_VER=${BASH_REMATCH[1]} - DC_VER_MAJ=${BASH_REMATCH[2]} - DC_VER_REM=${BASH_REMATCH[3]} - $DC --version - echo $DC version is $DC_VER -else - $DC --version - die $LINENO "Could not extract compiler version" -fi - -# create test app directory -TMPDIR=$(mktemp -d /tmp/dubtest1531_XXXXXX) -mkdir -p $TMPDIR/source -cat << EOF > $TMPDIR/source/app.d -module dubtest1531; -void main() {} -EOF - -# write dub.sdl with compiler requirement given as $1 -function write_cl_req { - cat << EOF > $TMPDIR/dub.sdl -name "dubtest1531" -toolchainRequirements ${DC_NAME}="$1" -EOF -} - -# pass test compiler requirement given as $1 -function test_cl_req_pass { - echo "Expecting success on '$DC $1'" 2>&1 - write_cl_req $1 - $DUB build -q --compiler=$DC --root=$TMPDIR || die $LINENO "Did not pass with $DC_NAME=\"$1\"" -} - -# fail test compiler requirement given as $1 -function test_cl_req_fail { - echo "Expecting failure on '$DC $1'" 2>&1 - write_cl_req $1 - ! $DUB --compiler=$DC --root=$TMPDIR || die $LINENO "Did not fail with $DC_NAME=\"$1\"" -} - - -test_cl_req_pass "==$DC_VER" -test_cl_req_pass ">=$DC_VER" -test_cl_req_fail ">$DC_VER" -test_cl_req_pass "<=$DC_VER" -test_cl_req_fail "<$DC_VER" -test_cl_req_pass ">=$DC_VER <$(($DC_VER_MAJ + 1))$DC_VER_REM" -test_cl_req_pass "~>$DC_VER" -test_cl_req_fail "~>$(($DC_VER_MAJ + 1))$DC_VER_REM" -test_cl_req_fail no - -rm -rf $TMPDIR diff --git a/test/issue1531-toolchain-requirements/dub.json b/test/issue1531-toolchain-requirements/dub.json new file mode 100644 index 0000000000..3e7a7b2581 --- /dev/null +++ b/test/issue1531-toolchain-requirements/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1531-toolchain-requirements", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1531-toolchain-requirements/source/app.d b/test/issue1531-toolchain-requirements/source/app.d new file mode 100644 index 0000000000..ad7597d128 --- /dev/null +++ b/test/issue1531-toolchain-requirements/source/app.d @@ -0,0 +1,148 @@ +import common; + +import std.algorithm; +import std.conv; +import std.file; +import std.path; +import std.process; + +version (LDC) + immutable dcName = "ldc"; +else version (DigitalMars) + immutable dcName = "dmd"; +else version (GNU) + immutable dcName = "gdc"; +else static assert (false, "Unknown compiler"); +string dcTestDubSdlPath; + +void main () { + testDub(">=1.7.0", true); + testDub("~>0.9", false); + testDub("~>999.0", false); + + if (exists("test")) + rmdirRecurse("test"); + mkdirRecurse(buildPath("test", "source")); + dcTestDubSdlPath = buildPath("test", "dub.sdl"); + write(buildPath("test", "source", "app.d"), q{ + module dubtest1531; + void main () {} + }); + + immutable ver = getDcVer(); + + Version nextMajor = ver; + nextMajor.major += 1; + + testDc("==" ~ ver, true); + testDc(">=" ~ ver, true); + testDc(">" ~ ver, false); + testDc("<=" ~ ver, true); + testDc("<" ~ ver, false); + testDc(">=" ~ ver ~ " <" ~ nextMajor, true); + testDc("~>" ~ ver, true); + testDc("~>" ~ nextMajor, false); + testDc("no", false); +} + +struct Version { + uint major; + uint minor; + uint patch; + string tail; + + string toString() const { + return text(major, ".", minor, ".", patch, tail); + } + alias toString this; +} + +Version getDcVer() { + import std.regex; + + immutable dc = environment["DC"]; + immutable dcBase = baseName(dc); + Regex!char r; + + if (dcBase.canFind("ldc") || dcBase.canFind("ldmd")) + r = regex(`\((\d+)\.(\d+)\.(\d+)([A-Za-z0-9.+-]*)\)`); + else if (dcBase.canFind("gdc")) + die("Not implemented"); + else if (dcBase.canFind("gdmd")) + return getDcVerGdmd(dc); + else if (dcBase.canFind("dmd")) + r = regex(`v(\d+)\.(\d+)\.(\d+)([A-Za-z0-9.+-]*)`); + else + die("Unknown DC: ", dcBase); + + immutable p = execute([dc, "--version"]); + if (p.status != 0) + die("Failed to execute `DC --version`"); + + const m = p.output.matchFirst(r); + if (!m) + die("DC --version printed in unknown format"); + + Version result; + result.major = m[1].to!uint; + result.minor = m[2].to!uint; + result.patch = m[3].to!uint; + result.tail = m[4]; + return result; + +} + +Version getDcVerGdmd(string dc) { + import std.array; + import std.string; + + immutable progLog = "`" ~ dc ~ " -q,-dumpfullversion --version`"; + immutable p = execute([dc, "-q,-dumpfullversion", "--version"]); + if (p.status != 0) + die("Couldn't execute ", progLog); + + immutable parts = p.output.chomp.split('.'); + if (parts.length != 3) { + log(p.output); + die(progLog, " didn't output version in 'major.minor.patch' format"); + } + + immutable np = parts.map!(to!int).array; + return Version(np[0], np[1], np[2], ""); +} + +void testDub(string requirement, bool expectSuccess) { + if (requirement !is null) + requirement = `toolchainRequirements dub="` ~ requirement ~ `"`; + + auto p = pipeProcess([dub, "-"], Redirect.stdin); + + p.stdin.writefln(q{ + /+ dub.sdl: + %s + +/ + void main() {} + }, + requirement); + + p.stdin.close(); + + immutable gotSuccess = p.pid.wait == 0; + if (gotSuccess != expectSuccess) + die("Did not pass with: ", requirement); +} + +void testDc(string requirement, bool expectSuccess) { + import std.stdio; + File(dcTestDubSdlPath, "w").writefln(` +name "dubtest1531" +toolchainRequirements %s="%s"`, dcName, requirement); + + writeln("Expecting ", expectSuccess ? "success" : "failure", " with ", dcName, " ", requirement); + stdout.flush(); + immutable gotSuccess = spawnProcess([dub, "build", "-q", "--root=test"]).wait == 0; + if (gotSuccess != expectSuccess) { + immutable error = gotSuccess ? "Did not fail" : "Did not pass"; + die(error, " with ", dcName, `="`, requirement, `"`); + } +} diff --git a/test/issue1556-fetch-and-build-pkgs/.no_build b/test/issue1556-fetch-and-build-pkgs/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1556-fetch-and-build.sh b/test/issue1556-fetch-and-build.sh deleted file mode 100755 index 6bef98d7b9..0000000000 --- a/test/issue1556-fetch-and-build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -dub remove main-package --non-interactive 2>/dev/null || true -dub remove dependency-package --non-interactive 2>/dev/null || true - - -echo "Trying to fetch fs-sdl-dubpackage" -"$DUB" --cache=local fetch main-package --skip-registry=all --registry=file://"$DIR"/issue1556-fetch-and-build-pkgs - -echo "Trying to build it (should fetch dependency-package)" -"$DUB" --cache=local build main-package --skip-registry=all --registry=file://"$DIR"/issue1556-fetch-and-build-pkgs - diff --git a/test/issue1556-fetch-and-build/.gitignore b/test/issue1556-fetch-and-build/.gitignore new file mode 100644 index 0000000000..ea815def5c --- /dev/null +++ b/test/issue1556-fetch-and-build/.gitignore @@ -0,0 +1,3 @@ +/sample/* +!/sample/ +!/sample/*.zip diff --git a/test/issue1556-fetch-and-build/dub.json b/test/issue1556-fetch-and-build/dub.json new file mode 100644 index 0000000000..8d6718db26 --- /dev/null +++ b/test/issue1556-fetch-and-build/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1556-fetch-and-build", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip b/test/issue1556-fetch-and-build/sample/dependency-package-1.0.0.zip similarity index 100% rename from test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip rename to test/issue1556-fetch-and-build/sample/dependency-package-1.0.0.zip diff --git a/test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip b/test/issue1556-fetch-and-build/sample/main-package-1.0.0.zip similarity index 100% rename from test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip rename to test/issue1556-fetch-and-build/sample/main-package-1.0.0.zip diff --git a/test/issue1556-fetch-and-build/source/app.d b/test/issue1556-fetch-and-build/source/app.d new file mode 100644 index 0000000000..bed423d32c --- /dev/null +++ b/test/issue1556-fetch-and-build/source/app.d @@ -0,0 +1,26 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + execute([dub, "remove", "main-package", "--non-interactive"]); + execute([dub, "remove", "dependency-package", "--non-interactive"]); + + immutable registryArgs = [ + "--skip-registry=all", + "--registry=file://" ~ getcwd().buildPath("sample"), + ]; + + log("Trying to fetch main-package"); + auto p = spawnProcess([dub, "--cache=local", "fetch", "main-package"] ~ registryArgs); + if (p.wait != 0) + die("Dub fetch failed"); + + log("Trying to build it (should fetch dependency-package)"); + p = spawnProcess([dub, "--cache=local", "build", "main-package"] ~ registryArgs); + if (p.wait != 0) + die("Dub fetch failed"); +} diff --git a/test/issue1567-fetch-sub-package.sh b/test/issue1567-fetch-sub-package.sh deleted file mode 100755 index 62c067844e..0000000000 --- a/test/issue1567-fetch-sub-package.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -DIR=$(dirname "${BASH_SOURCE[0]}") -packname="fetch-sub-package-dubpackage" -sub_packagename="my-sub-package" - -${DUB} remove $packname --non-interactive 2>/dev/null || true -${DUB} fetch "$packname:$sub_packagename" --skip-registry=all --registry=file://"$DIR"/issue1567-fetch-sub-package - -if ! ${DUB} remove $packname@1.0.1 2>/dev/null; then - die $LINENO 'DUB did not install package $packname:$sub_packagename.' -fi diff --git a/test/issue1567-fetch-sub-package/.gitignore b/test/issue1567-fetch-sub-package/.gitignore new file mode 100644 index 0000000000..ea815def5c --- /dev/null +++ b/test/issue1567-fetch-sub-package/.gitignore @@ -0,0 +1,3 @@ +/sample/* +!/sample/ +!/sample/*.zip diff --git a/test/issue1567-fetch-sub-package/.no_build b/test/issue1567-fetch-sub-package/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1567-fetch-sub-package/.no_run b/test/issue1567-fetch-sub-package/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1567-fetch-sub-package/.no_test b/test/issue1567-fetch-sub-package/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1567-fetch-sub-package/dub.json b/test/issue1567-fetch-sub-package/dub.json new file mode 100644 index 0000000000..deefee5f0a --- /dev/null +++ b/test/issue1567-fetch-sub-package/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1567-fetch-sub-package", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1567-fetch-sub-package/fetch-sub-package-dubpackage-1.0.1.zip b/test/issue1567-fetch-sub-package/sample/fetch-sub-package-dubpackage-1.0.1.zip similarity index 100% rename from test/issue1567-fetch-sub-package/fetch-sub-package-dubpackage-1.0.1.zip rename to test/issue1567-fetch-sub-package/sample/fetch-sub-package-dubpackage-1.0.1.zip diff --git a/test/issue1567-fetch-sub-package/source/app.d b/test/issue1567-fetch-sub-package/source/app.d new file mode 100644 index 0000000000..0d88c8837d --- /dev/null +++ b/test/issue1567-fetch-sub-package/source/app.d @@ -0,0 +1,20 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + immutable pkgName = "fetch-sub-package-dubpackage"; + immutable subPkgName = pkgName ~ ":my-sub-package"; + + execute([dub, "remove", pkgName]); + + auto p = spawnProcess([dub, "fetch", subPkgName, "--skip-registry=all", "--registry=file://" ~ getcwd().buildPath("sample")]); + if (p.wait != 0) + die("Dub fetch failed"); + + if (spawnProcess([dub, "remove", pkgName ~ "@1.0.1"]).wait != 0) + die("DUB did not install package $packname:$sub_packagename."); +} diff --git a/test/issue1574-addcommand.sh b/test/issue1574-addcommand.sh deleted file mode 100755 index 94d90f1340..0000000000 --- a/test/issue1574-addcommand.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -DIR=$(dirname "${BASH_SOURCE[0]}") - -. "$DIR"/common.sh - -PORT=$(getRandomPort) -tempDir="issue1574-addcommand" - -"$DUB" build --single "$DIR"/test_registry.d -"$DIR"/test_registry --folder="$DIR/issue1336-registry" --port=$PORT & -PID=$! -sleep 1 - -function cleanup { - cd .. - rm -rf $tempDir - kill $PID 2>/dev/null || true -} -trap cleanup EXIT - - -$DUB init --non-interactive --format=json $tempDir -cd $tempDir - -echo "import gitcompatibledubpackage.subdir.file; void main(){}" > source/app.d -$DUB add gitcompatibledubpackage --skip-registry=all --registry=http://localhost:$PORT -grep -q '"gitcompatibledubpackage"\s*:\s*"~>1\.0\.4"' dub.json -$DUB add gitcompatibledubpackage=1.0.2 non-existing-issue1574-pkg='~>9.8.7' --skip-registry=all -grep -q '"gitcompatibledubpackage"\s*:\s*"1\.0\.2"' dub.json -grep -q '"non-existing-issue1574-pkg"\s*:\s*"~>9\.8\.7"' dub.json -if $DUB add foo@1.2.3 gitcompatibledubpackage='~>a.b.c' --skip-registry=all; then - die $LINENO 'Adding non-semver spec should error' -fi -if grep -q '"foo"' dub.json; then - die $LINENO 'Failing add command should not write recipe file' -fi diff --git a/test/issue1574-addcommand.sh.min_frontend b/test/issue1574-addcommand.sh.min_frontend deleted file mode 100644 index 4817f99644..0000000000 --- a/test/issue1574-addcommand.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.077 diff --git a/test/issue1574-addcommand/dub.json b/test/issue1574-addcommand/dub.json new file mode 100644 index 0000000000..ae73ace420 --- /dev/null +++ b/test/issue1574-addcommand/dub.json @@ -0,0 +1,11 @@ +{ + "name": "issue1564-addcommand", + "dependencies": { + "common": { + "path": "../common" + }, + "test_registry_helper": { + "path": "../extra/test_registry" + } + } +} diff --git a/test/issue1574-addcommand/source/app.d b/test/issue1574-addcommand/source/app.d new file mode 100644 index 0000000000..4f87e5d02b --- /dev/null +++ b/test/issue1574-addcommand/source/app.d @@ -0,0 +1,50 @@ +import common; +import test_registry_helper; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.regex; + +void main () { + auto testRegistry = TestRegistry("../extra/issue1336-registry"); + immutable registryArgs = [ + "--skip-registry=all", + "--registry=http://localhost:" ~ testRegistry.port, + ]; + + if (exists("test")) rmdirRecurse("test"); + if (spawnProcess([dub, "init", "--non-interactive", "--format=json", "test"]).wait != 0) + die("Dub init failed"); + chdir("test"); + + write("source/app.d", q{import gitcompatibledubpackage.subdir.file; void main(){}}); + if (spawnProcess([dub, "add", "gitcompatibledubpackage"] ~ registryArgs).wait != 0) + die("Dub add failed"); + if (!readText("dub.json").matchFirst(`"gitcompatibledubpackage"\s*:\s*"~>1\.0\.4"`)) + die("dub add did not modify dub.json to reflect the new dependency"); + + { + auto p = spawnProcess([ + dub, "add", "gitcompatibledubpackage=1.0.2", "non-existing-issue1574-pkg=~>9.8.7", "--skip-registry=all"] + ); + if (p.wait != 0) + die("Dub add with version failed"); + + immutable dubJson = readText("dub.json"); + if (!dubJson.matchFirst(`"gitcompatibledubpackage"\s*:\s*"1\.0\.2"`)) + die("dub add did not modify gitcompatibledubpackage dependency"); + if (!dubJson.matchFirst(`"non-existing-issue1574-pkg"\s*:\s*"~>9\.8\.7"`)) + die("dub did not add a dependency on a non-existing package with --skip-registry=all"); + } + + { + auto p = spawnProcess([dub, "add", "foo@1.2.3", "gitcompatibledubpackage=~>a.b.c", "--skip-registry=all"]); + if (p.wait == 0) + die("Adding non-semver spec should error"); + if (readText("dub.json").canFind(`"foo"`)) + die("Failing add command should not write recipe file"); + } + +} diff --git a/test/issue1574-addcommand/test.config b/test/issue1574-addcommand/test.config new file mode 100644 index 0000000000..a7d966bb21 --- /dev/null +++ b/test/issue1574-addcommand/test.config @@ -0,0 +1,2 @@ +locks = test_registry +dc_backend = [dmd, ldc] \ No newline at end of file diff --git a/test/issue1636-betterC-dub-test.sh b/test/issue1636-betterC-dub-test.sh deleted file mode 100755 index f2062c6283..0000000000 --- a/test/issue1636-betterC-dub-test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd ${CURR_DIR}/issue1636-betterC-dub-test - -${DUB} test | grep -c "TEST_WAS_RUN" > /dev/null diff --git a/test/issue1636-betterC-dub-test/.gitignore b/test/issue1636-betterC-dub-test/.gitignore index 53b683b0ab..20656516f1 100644 --- a/test/issue1636-betterC-dub-test/.gitignore +++ b/test/issue1636-betterC-dub-test/.gitignore @@ -1,4 +1,5 @@ -test -*.o -*.exe -.dub +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue1636-betterC-dub-test/.min_frontend b/test/issue1636-betterC-dub-test/.min_frontend deleted file mode 100644 index 67aaf4ad8d..0000000000 --- a/test/issue1636-betterC-dub-test/.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.078 diff --git a/test/issue1636-betterC-dub-test/.no_run b/test/issue1636-betterC-dub-test/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1636-betterC-dub-test/dub.json b/test/issue1636-betterC-dub-test/dub.json index afb1093ea2..26b5ba48bc 100644 --- a/test/issue1636-betterC-dub-test/dub.json +++ b/test/issue1636-betterC-dub-test/dub.json @@ -1,4 +1,8 @@ { - "name": "test", - "buildOptions": ["betterC"] + "name": "issue1636-betterC-dub-test", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue1636-betterC-dub-test/sample/dub.json b/test/issue1636-betterC-dub-test/sample/dub.json new file mode 100644 index 0000000000..afb1093ea2 --- /dev/null +++ b/test/issue1636-betterC-dub-test/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "test", + "buildOptions": ["betterC"] +} diff --git a/test/issue1636-betterC-dub-test/source/lib.d b/test/issue1636-betterC-dub-test/sample/source/lib.d similarity index 100% rename from test/issue1636-betterC-dub-test/source/lib.d rename to test/issue1636-betterC-dub-test/sample/source/lib.d diff --git a/test/issue1636-betterC-dub-test/source/app.d b/test/issue1636-betterC-dub-test/source/app.d new file mode 100644 index 0000000000..f427ed6bf8 --- /dev/null +++ b/test/issue1636-betterC-dub-test/source/app.d @@ -0,0 +1,16 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + // FIXME: DFLAGS disable unittests: https://github.com/dlang/dub/pull/3060 + environment.remove("DFLAGS"); + + auto p = teeProcess([dub, "test"], Redirect.stdout, null, Config.none, "sample"); + p.wait; + if (!p.stdout.canFind("TEST_WAS_RUN")) + die("Tests weren't run"); +} diff --git a/test/issue1645-dflags-build.sh b/test/issue1645-dflags-build.sh deleted file mode 100755 index 5fbcb1e351..0000000000 --- a/test/issue1645-dflags-build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# If DFLAGS are not processed, dub for library would fail -DFLAGS="-w" $DUB build --root="$CURR_DIR"/1-staticLib-simple --build=plain -if DFLAGS="-asfdsf" $DUB build --root="$CURR_DIR"/1-staticLib-simple --build=plain 2>/dev/null; then - echo "Should not accept this DFLAGS"; - false # fail -fi -$DUB build --root="$CURR_DIR"/1-staticLib-simple --build=plain --build=plain diff --git a/test/issue1645-dflags-build/dub.json b/test/issue1645-dflags-build/dub.json new file mode 100644 index 0000000000..fadc05736b --- /dev/null +++ b/test/issue1645-dflags-build/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1645-dflags-build", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1645-dflags-build/source/app.d b/test/issue1645-dflags-build/source/app.d new file mode 100644 index 0000000000..c0c3e57bb8 --- /dev/null +++ b/test/issue1645-dflags-build/source/app.d @@ -0,0 +1,23 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + immutable testDir = "../1-staticLib-simple"; + + // If DFLAGS are not processed, dub for library would fail + auto p = spawnProcess([dub, "build", "--build=plain"], ["DFLAGS": "-w"], Config.none, testDir); + if (p.wait != 0) + die("Dub build with sane DFLAGS failed"); + + p = spawnProcess([dub, "build", "--build=plain"], ["DFLAGS": "-asfdsf"], Config.none, testDir); + if (p.wait == 0) + die("Dub build with insafe DFLAGS succeeded"); + + p = spawnProcess([dub, "build", "--build=plain", "--build=plain"], null, Config.none, testDir); + if (p.wait != 0) + die("Dub build with multiple --build=plain failed"); +} diff --git a/test/issue1645-dflags-build/test.config b/test/issue1645-dflags-build/test.config new file mode 100644 index 0000000000..2987a7647a --- /dev/null +++ b/test/issue1645-dflags-build/test.config @@ -0,0 +1 @@ +locks = 1-staticLib-simple \ No newline at end of file diff --git a/test/issue1651-custom-dub-init-type.sh b/test/issue1651-custom-dub-init-type.sh deleted file mode 100755 index 0efafa9297..0000000000 --- a/test/issue1651-custom-dub-init-type.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -DIR=$(dirname "${BASH_SOURCE[0]}") -packname="custom-dub-init-type-sample" - -$DUB remove custom-dub-init-dubpackage --non-interactive 2>/dev/null || true -$DUB init -n $packname --format sdl -t custom-dub-init-dubpackage --skip-registry=all --registry=file://"$DIR"/issue1651-custom-dub-init-type -- --foo=bar - -function cleanup { - rm -rf $packname -} - -if [ ! -e $packname/dub.sdl ]; then # it failed - cleanup - die $LINENO 'No dub.sdl file has been generated.' -fi - -cd $packname -if ! { ${DUB} 2>&1 || true; } | grep -cF 'foo=bar'; then - cd .. - cleanup - die $LINENO 'Custom init type.' -fi -cd .. -cleanup diff --git a/test/issue1651-custom-dub-init-type/.gitignore b/test/issue1651-custom-dub-init-type/.gitignore new file mode 100644 index 0000000000..27a97c99bf --- /dev/null +++ b/test/issue1651-custom-dub-init-type/.gitignore @@ -0,0 +1,3 @@ +/sample/** +!/sample/ +!/sample/*.zip diff --git a/test/issue1651-custom-dub-init-type/.no_build b/test/issue1651-custom-dub-init-type/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1651-custom-dub-init-type/.no_run b/test/issue1651-custom-dub-init-type/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1651-custom-dub-init-type/.no_test b/test/issue1651-custom-dub-init-type/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1651-custom-dub-init-type/dub.json b/test/issue1651-custom-dub-init-type/dub.json new file mode 100644 index 0000000000..202445f5a8 --- /dev/null +++ b/test/issue1651-custom-dub-init-type/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1651-custom-dub-init-type", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1651-custom-dub-init-type/custom-dub-init-dubpackage-1.0.1.zip b/test/issue1651-custom-dub-init-type/sample/custom-dub-init-dubpackage-1.0.1.zip similarity index 100% rename from test/issue1651-custom-dub-init-type/custom-dub-init-dubpackage-1.0.1.zip rename to test/issue1651-custom-dub-init-type/sample/custom-dub-init-dubpackage-1.0.1.zip diff --git a/test/issue1651-custom-dub-init-type/source/app.d b/test/issue1651-custom-dub-init-type/source/app.d new file mode 100644 index 0000000000..167bfad49b --- /dev/null +++ b/test/issue1651-custom-dub-init-type/source/app.d @@ -0,0 +1,39 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + execute([dub, "remove", "custom-dub-init-dubpackage", "--non-interactive"]); + + if (exists("test")) rmdirRecurse("test"); + + { + auto p = spawnProcess([ + dub, + "init", + "-n", + "test", + "--format=sdl", + "-t", "custom-dub-init-dubpackage", + "--skip-registry=all", + "--registry=file://" ~ getcwd().buildPath("sample"), + "--", + "--foo=bar", + ]); + if (p.wait != 0) + die("dub init -t failed"); + } + + if (!exists("test/dub.sdl")) + die("No dub.sdl file has been generated"); + + { + auto p = teeProcess([dub], Redirect.stdout, null, Config.none, "test"); + p.wait; + if (!p.stdout.canFind("--foo=bar")) + die("Custom init type failed"); + } +} diff --git a/test/issue1691-build-subpkg.sh b/test/issue1691-build-subpkg.sh deleted file mode 100755 index ea700687fa..0000000000 --- a/test/issue1691-build-subpkg.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -$DUB build --root="$CURR_DIR/issue1691-build-subpkg" :subpkg diff --git a/test/issue1691-build-subpkg/.gitignore b/test/issue1691-build-subpkg/.gitignore index 1ba396039a..8ff0570708 100644 --- a/test/issue1691-build-subpkg/.gitignore +++ b/test/issue1691-build-subpkg/.gitignore @@ -1,15 +1,9 @@ -.dub -docs.json -__dummy.html -docs/ -/issue1691-build-subpkg -issue1691-build-subpkg.so -issue1691-build-subpkg.dylib -issue1691-build-subpkg.dll -issue1691-build-subpkg.a -issue1691-build-subpkg.lib -issue1691-build-subpkg-test-* -*.exe -*.o -*.obj -*.lst +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/source/ +!/sample/source/*.d +!/sample/subpkg/ +!/sample/subpkg/dub.sdl +!/sample/subpkg/source/ +!/sample/subpkg/source/*.d \ No newline at end of file diff --git a/test/issue1691-build-subpkg/.no_build b/test/issue1691-build-subpkg/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1691-build-subpkg/dub.json b/test/issue1691-build-subpkg/dub.json new file mode 100644 index 0000000000..46510c1c11 --- /dev/null +++ b/test/issue1691-build-subpkg/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1691-build-subpkg", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1691-build-subpkg/dub.sdl b/test/issue1691-build-subpkg/sample/dub.sdl similarity index 100% rename from test/issue1691-build-subpkg/dub.sdl rename to test/issue1691-build-subpkg/sample/dub.sdl diff --git a/test/1-sourceLib-simple/.no_build b/test/issue1691-build-subpkg/sample/source/app.d similarity index 100% rename from test/1-sourceLib-simple/.no_build rename to test/issue1691-build-subpkg/sample/source/app.d diff --git a/test/issue1691-build-subpkg/subpkg/dub.sdl b/test/issue1691-build-subpkg/sample/subpkg/dub.sdl similarity index 100% rename from test/issue1691-build-subpkg/subpkg/dub.sdl rename to test/issue1691-build-subpkg/sample/subpkg/dub.sdl diff --git a/test/issue1691-build-subpkg/subpkg/source/subpkg.d b/test/issue1691-build-subpkg/sample/subpkg/source/subpkg.d similarity index 100% rename from test/issue1691-build-subpkg/subpkg/source/subpkg.d rename to test/issue1691-build-subpkg/sample/subpkg/source/subpkg.d diff --git a/test/issue1691-build-subpkg/source/app.d b/test/issue1691-build-subpkg/source/app.d index e69de29bb2..0473bdaa57 100644 --- a/test/issue1691-build-subpkg/source/app.d +++ b/test/issue1691-build-subpkg/source/app.d @@ -0,0 +1,8 @@ +import common; + +import std.process; + +void main () { + if (spawnProcess([dub, "build", "--root=sample", ":subpkg"]).wait != 0) + die("dub build subpackage failed"); +} diff --git a/test/issue1739-project-settings-file.sh b/test/issue1739-project-settings-file.sh deleted file mode 100755 index efc4f3dbba..0000000000 --- a/test/issue1739-project-settings-file.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR} -echo "{\"defaultArchitecture\": \"foo\"}" > "dub.settings.json" - -function cleanup { - rm "dub.settings.json" -} - -trap cleanup EXIT - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unsupported architecture: foo"; then - die $LINENO 'DUB did not find the project configuration with an adjacent architecture.' -fi - diff --git a/test/issue1739-project-settings-file/.gitignore b/test/issue1739-project-settings-file/.gitignore new file mode 100644 index 0000000000..c1917c4843 --- /dev/null +++ b/test/issue1739-project-settings-file/.gitignore @@ -0,0 +1,3 @@ +/sample/** +!/sample +!/sample/single.d diff --git a/test/issue1739-project-settings-file/dub.json b/test/issue1739-project-settings-file/dub.json new file mode 100644 index 0000000000..a4edb88656 --- /dev/null +++ b/test/issue1739-project-settings-file/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1739-project-settings-file", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1739-project-settings-file/sample/single.d b/test/issue1739-project-settings-file/sample/single.d new file mode 100644 index 0000000000..4e6e05716f --- /dev/null +++ b/test/issue1739-project-settings-file/sample/single.d @@ -0,0 +1,2 @@ +/+ dub.sdl: name "issue1739-project-settings-file-test +/ +void main () {} diff --git a/test/issue1739-project-settings-file/source/app.d b/test/issue1739-project-settings-file/source/app.d new file mode 100644 index 0000000000..28c79caec6 --- /dev/null +++ b/test/issue1739-project-settings-file/source/app.d @@ -0,0 +1,16 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + write("dub.settings.json", `{"defaultArchitecture": "foo"}`); + + auto p = teeProcess([dub, "describe", "--single", "single.d"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("Unsupported architecture: foo")) + die("DUB did not find the project configuration with an adjacent architecture."); +} diff --git a/test/issue1773-lint.sh b/test/issue1773-lint.sh deleted file mode 100755 index 5a95f51a8f..0000000000 --- a/test/issue1773-lint.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue1773-lint -rm -rf report.json - -if ! { ${DUB} lint || true; } | grep -cF "Parameter args is never used."; then - die $LINENO 'DUB lint did not find expected warning.' -fi - -${DUB} lint --report-file report.json -if ! grep -c -e "Parameter args is never used." report.json; then - die $LINENO 'Linter report did not contain expected warning.' -fi diff --git a/test/issue1773-lint/.gitignore b/test/issue1773-lint/.gitignore index 304e9559a5..20656516f1 100644 --- a/test/issue1773-lint/.gitignore +++ b/test/issue1773-lint/.gitignore @@ -1,8 +1,5 @@ -.dub -docs.json -__dummy.html -docs/ -*.exe -*.o -*.obj -*.lst +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue1773-lint/.no_build b/test/issue1773-lint/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1773-lint/dub.json b/test/issue1773-lint/dub.json index 016de7e97a..50ec3d0975 100644 --- a/test/issue1773-lint/dub.json +++ b/test/issue1773-lint/dub.json @@ -1,3 +1,8 @@ { - "name": "test" -} \ No newline at end of file + "name": "issue1773-lint", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1773-lint/sample/dub.json b/test/issue1773-lint/sample/dub.json new file mode 100644 index 0000000000..5f6ad1f446 --- /dev/null +++ b/test/issue1773-lint/sample/dub.json @@ -0,0 +1,3 @@ +{ + "name": "test" +} diff --git a/test/issue1773-lint/sample/source/app.d b/test/issue1773-lint/sample/source/app.d new file mode 100644 index 0000000000..e1edea8d2b --- /dev/null +++ b/test/issue1773-lint/sample/source/app.d @@ -0,0 +1,4 @@ +void main(string[] args) +{ + +} \ No newline at end of file diff --git a/test/issue1773-lint/source/app.d b/test/issue1773-lint/source/app.d index e1edea8d2b..6b8d77b256 100644 --- a/test/issue1773-lint/source/app.d +++ b/test/issue1773-lint/source/app.d @@ -1,4 +1,23 @@ -void main(string[] args) -{ +import common; -} \ No newline at end of file +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio : stdout; + +void main () { + chdir("sample"); + if (exists("report.json")) remove("report.json"); + + auto p = teeProcess([dub, "lint"], Redirect.stdout); + p.wait; + if (!p.stdout.canFind("Parameter args is never used.")) + die("DUB lint did not find expected warning."); + + if (spawnProcess([dub, "lint", "--report-file", "report.json"]).wait != 0) + die("Dub lint --report-file failed"); + + if (!readText("report.json").canFind("Parameter args is never used.")) + die("Linter report did not contain expected warning."); +} diff --git a/test/issue1775/.gitignore b/test/issue1775/.gitignore new file mode 100644 index 0000000000..33c406f88c --- /dev/null +++ b/test/issue1775/.gitignore @@ -0,0 +1 @@ +!/issue1775.marker \ No newline at end of file diff --git a/test/issue1775/.no_run b/test/issue1775/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1775/.no_test b/test/issue1775/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1775/dub.json b/test/issue1775/dub.json index f1273ef2b6..2820cd2753 100644 --- a/test/issue1775/dub.json +++ b/test/issue1775/dub.json @@ -1,5 +1,5 @@ { - "name": "test", + "name": "issue1775", "targetName": "test-application", "preBuildCommands-posix": [ "[ -f issue1775.marker ]" ], "preBuildCommands-windows": [ "if not exist issue1775.marker exit /b 1" ] diff --git a/test/issue1788-incomplete-string-import-override/.gitignore b/test/issue1788-incomplete-string-import-override/.gitignore new file mode 100644 index 0000000000..1cfb69524b --- /dev/null +++ b/test/issue1788-incomplete-string-import-override/.gitignore @@ -0,0 +1,3 @@ +!/b +!/c +!/views \ No newline at end of file diff --git a/test/issue1788-incomplete-string-import-override/b/dub.sdl b/test/issue1788-incomplete-string-import-override/b/dub.sdl index ad65ed5946..5c685b44a8 100644 --- a/test/issue1788-incomplete-string-import-override/b/dub.sdl +++ b/test/issue1788-incomplete-string-import-override/b/dub.sdl @@ -1 +1 @@ -name "b" +name "issue1788-b" diff --git a/test/issue1788-incomplete-string-import-override/c/dub.sdl b/test/issue1788-incomplete-string-import-override/c/dub.sdl index 1ed791a15b..0b01efcb96 100644 --- a/test/issue1788-incomplete-string-import-override/c/dub.sdl +++ b/test/issue1788-incomplete-string-import-override/c/dub.sdl @@ -1 +1 @@ -name "c" +name "issue1788-c" diff --git a/test/issue1788-incomplete-string-import-override/dub.sdl b/test/issue1788-incomplete-string-import-override/dub.sdl index 41999718ad..470241040e 100644 --- a/test/issue1788-incomplete-string-import-override/dub.sdl +++ b/test/issue1788-incomplete-string-import-override/dub.sdl @@ -1,4 +1,4 @@ -name "a" +name "issue1788-a" -dependency "b" path="b" -dependency "c" path="c" +dependency "issue1788-b" path="b" +dependency "issue1788-c" path="c" diff --git a/test/issue1856-build-unittest.sh b/test/issue1856-build-unittest.sh deleted file mode 100755 index 2819b31c31..0000000000 --- a/test/issue1856-build-unittest.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -TMPDIR=$(mktemp -d "$(basename "$0").XXXXXX") - -function cleanup { - rm -rf "$TMPDIR" -} -trap cleanup EXIT - -# no unittest config -cat > "$TMPDIR/no_ut.d" < "$TMPDIR/partial_ut.d" < "$TMPDIR/partial_ut2.d" < "$TMPDIR/full_ut.d" <&1 || true; } | grep -cF " -lowmem " > /dev/null; then - die $LINENO 'DUB build with lowmem did not find -lowmem option.' -fi - -if ! { ${DUB} test --root ${DIR}/issue1867-lowmem -v -f 2>&1 || true; } | grep -cF " -lowmem " > /dev/null; then - die $LINENO 'DUB test with lowmem did not find -lowmem option.' -fi - -if ! { ${DUB} run --root ${DIR}/issue1867-lowmem -v -f 2>&1 || true; } | grep -cF " -lowmem " > /dev/null; then - die $LINENO 'DUB test with lowmem did not find -lowmem option.' -fi - -if ! { ${DUB} describe --root ${DIR}/issue1867-lowmem --data=options --data-list --verror 2>&1 || true; } | grep -cF "lowmem" > /dev/null; then - die $LINENO 'DUB describe --data=options --data-list with lowmem did not find lowmem option.' -fi diff --git a/test/issue1867-lowmem/.gitignore b/test/issue1867-lowmem/.gitignore index 3b21cd57ad..a923a39e94 100644 --- a/test/issue1867-lowmem/.gitignore +++ b/test/issue1867-lowmem/.gitignore @@ -1,15 +1,6 @@ -.dub -docs.json -__dummy.html -docs/ -/issue1867-lowmem -issue1867-lowmem.so -issue1867-lowmem.dylib -issue1867-lowmem.dll -issue1867-lowmem.a -issue1867-lowmem.lib -issue1867-lowmem-test-* -*.exe -*.o -*.obj -*.lst +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/dub.settings.json +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue1867-lowmem/.no_build b/test/issue1867-lowmem/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1867-lowmem/.no_run b/test/issue1867-lowmem/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1867-lowmem/.no_test b/test/issue1867-lowmem/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue1867-lowmem/dub.json b/test/issue1867-lowmem/dub.json new file mode 100644 index 0000000000..f5ad805598 --- /dev/null +++ b/test/issue1867-lowmem/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue1867-lowmem", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue1867-lowmem/dub.sdl b/test/issue1867-lowmem/dub.sdl deleted file mode 100644 index 2cf20c897f..0000000000 --- a/test/issue1867-lowmem/dub.sdl +++ /dev/null @@ -1 +0,0 @@ -name "issue1867-lowmem" diff --git a/test/issue1867-lowmem/sample/dub.sdl b/test/issue1867-lowmem/sample/dub.sdl new file mode 100644 index 0000000000..4d7c353344 --- /dev/null +++ b/test/issue1867-lowmem/sample/dub.sdl @@ -0,0 +1 @@ +name "issue1867-lowmem" \ No newline at end of file diff --git a/test/issue1867-lowmem/dub.settings.json b/test/issue1867-lowmem/sample/dub.settings.json similarity index 100% rename from test/issue1867-lowmem/dub.settings.json rename to test/issue1867-lowmem/sample/dub.settings.json diff --git a/test/issue97-targettype-none/a/source/app.d b/test/issue1867-lowmem/sample/source/app.d similarity index 100% rename from test/issue97-targettype-none/a/source/app.d rename to test/issue1867-lowmem/sample/source/app.d diff --git a/test/issue1867-lowmem/source/app.d b/test/issue1867-lowmem/source/app.d index c3eec7f2dc..f126de8fef 100644 --- a/test/issue1867-lowmem/source/app.d +++ b/test/issue1867-lowmem/source/app.d @@ -1,6 +1,30 @@ -import std.stdio; +import common; -void main() -{ - writeln("Edit source/app.d to start your project."); +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + if (!execute([dub, "build", "--root=sample", "-v", "-f"]).output.canFind(" -lowmem ")) + die("DUB build with lowmem did not find -lowmem option."); + + if (!execute([dub, "test", "--root=sample", "-v", "-f"]).output.canFind(" -lowmem ")) + die("DUB test with lowmem did not find -lowmem option."); + + if (!execute([dub, "run", "--root=sample", "-v", "-f"]).output.canFind(" -lowmem ")) + die("DUB test with lowmem did not find -lowmem option."); + + immutable describeCmd = [ + dub, + "describe", + "--root=sample", + "--data=options", + "--data-list", + "--verror" + ]; + auto p = teeProcess(describeCmd); + p.wait; + if (!p.stdout.canFind("lowmem")) + die("DUB describe --data=options --data-list with lowmem did not find lowmem option."); } diff --git a/test/issue2012-dc-env/.gitignore b/test/issue2012-dc-env/.gitignore new file mode 100644 index 0000000000..d4f3007567 --- /dev/null +++ b/test/issue2012-dc-env/.gitignore @@ -0,0 +1,3 @@ +/sample/* +!/sample +!/sample/app.d \ No newline at end of file diff --git a/test/issue2012-dc-env/.no_build b/test/issue2012-dc-env/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2012-dc-env/app.d b/test/issue2012-dc-env/app.d deleted file mode 100644 index 4b1f4d1067..0000000000 --- a/test/issue2012-dc-env/app.d +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env dub -/+ dub.sdl: - name "app" -+/ - -import std.format; - -void main(string[] args) -{ - version (LDC) - immutable expected = "ldc2"; - version (DigitalMars) - immutable expected = "dmd"; - version (GNU) - immutable expected = "gdc"; - - assert(expected == args[1], format!"Expected '%s' but got '%s'"(expected, args[1])); -} diff --git a/test/issue2012-dc-env/dub.json b/test/issue2012-dc-env/dub.json new file mode 100644 index 0000000000..88be28ad1d --- /dev/null +++ b/test/issue2012-dc-env/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2012-dc-env", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2012-dc-env/sample/app.d b/test/issue2012-dc-env/sample/app.d new file mode 100644 index 0000000000..84b3f349a2 --- /dev/null +++ b/test/issue2012-dc-env/sample/app.d @@ -0,0 +1,26 @@ +#!/usr/bin/env dub +/+ dub.sdl: + name "app" ++/ + +import std.stdio; +import std.format; +import std.path; +import std.regex; + +int main(string[] args) +{ + version (LDC) + immutable expected = "ldmd|ldc"; + version (DigitalMars) + immutable expected = "dmd"; + version (GNU) + immutable expected = "gdmd|gdc"; + + immutable dc = args[1]; + immutable dcBase = dc.baseName; + if (dcBase.matchFirst(expected)) return 0; + + writefln("[FAIL]: Expected '%s' but DC is '%s'", expected, dcBase); + return 1; +} diff --git a/test/issue2012-dc-env/source/app.d b/test/issue2012-dc-env/source/app.d new file mode 100644 index 0000000000..6e84adb377 --- /dev/null +++ b/test/issue2012-dc-env/source/app.d @@ -0,0 +1,11 @@ +import common; + +import std.process; + +void main () { + immutable dc = environment["DC"]; + + auto p = spawnProcess([dub, "app.d", dc], null, Config.none, "sample"); + if (p.wait != 0) + die("Running the program failed"); +} diff --git a/test/issue2046-ignored-optional-with-path/.gitignore b/test/issue2046-ignored-optional-with-path/.gitignore new file mode 100644 index 0000000000..2441e92ab1 --- /dev/null +++ b/test/issue2046-ignored-optional-with-path/.gitignore @@ -0,0 +1,8 @@ +/sample/* +!/sample/ +!/sample/dub.json +!/sample/dub.selections.json-nofoo +!/sample/dub.selections.json-usefoo +!/sample/libbar/ +!/sample/libfoo/ +!/sample/source/ diff --git a/test/issue2046-ignored-optional-with-path/.no_build b/test/issue2046-ignored-optional-with-path/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2046-ignored-optional-with-path/.no_run b/test/issue2046-ignored-optional-with-path/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2046-ignored-optional-with-path/.no_test b/test/issue2046-ignored-optional-with-path/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2046-ignored-optional-with-path/dub.json b/test/issue2046-ignored-optional-with-path/dub.json index ef1f533e7a..7f5b3a6da6 100644 --- a/test/issue2046-ignored-optional-with-path/dub.json +++ b/test/issue2046-ignored-optional-with-path/dub.json @@ -1,6 +1,8 @@ { - "name": "issue2046", + "name": "issue2046-ignored-optional-with-path", "dependencies": { - "libbar": "*" + "common": { + "path": "../common" + } } } diff --git a/test/issue2046-ignored-optional-with-path/sample/dub.json b/test/issue2046-ignored-optional-with-path/sample/dub.json new file mode 100644 index 0000000000..ef1f533e7a --- /dev/null +++ b/test/issue2046-ignored-optional-with-path/sample/dub.json @@ -0,0 +1,6 @@ +{ + "name": "issue2046", + "dependencies": { + "libbar": "*" + } +} diff --git a/test/issue2046-ignored-optional-with-path/dub.selections.json-nofoo b/test/issue2046-ignored-optional-with-path/sample/dub.selections.json-nofoo similarity index 100% rename from test/issue2046-ignored-optional-with-path/dub.selections.json-nofoo rename to test/issue2046-ignored-optional-with-path/sample/dub.selections.json-nofoo diff --git a/test/issue2046-ignored-optional-with-path/dub.selections.json-usefoo b/test/issue2046-ignored-optional-with-path/sample/dub.selections.json-usefoo similarity index 100% rename from test/issue2046-ignored-optional-with-path/dub.selections.json-usefoo rename to test/issue2046-ignored-optional-with-path/sample/dub.selections.json-usefoo diff --git a/test/issue2046-ignored-optional-with-path/libbar/dub.json b/test/issue2046-ignored-optional-with-path/sample/libbar/dub.json similarity index 100% rename from test/issue2046-ignored-optional-with-path/libbar/dub.json rename to test/issue2046-ignored-optional-with-path/sample/libbar/dub.json diff --git a/test/issue2046-ignored-optional-with-path/libbar/source/libbar/bar.d b/test/issue2046-ignored-optional-with-path/sample/libbar/source/libbar/bar.d similarity index 100% rename from test/issue2046-ignored-optional-with-path/libbar/source/libbar/bar.d rename to test/issue2046-ignored-optional-with-path/sample/libbar/source/libbar/bar.d diff --git a/test/issue2046-ignored-optional-with-path/libfoo/dub.json b/test/issue2046-ignored-optional-with-path/sample/libfoo/dub.json similarity index 100% rename from test/issue2046-ignored-optional-with-path/libfoo/dub.json rename to test/issue2046-ignored-optional-with-path/sample/libfoo/dub.json diff --git a/test/issue2046-ignored-optional-with-path/libfoo/source/libfoo/foo.d b/test/issue2046-ignored-optional-with-path/sample/libfoo/source/libfoo/foo.d similarity index 100% rename from test/issue2046-ignored-optional-with-path/libfoo/source/libfoo/foo.d rename to test/issue2046-ignored-optional-with-path/sample/libfoo/source/libfoo/foo.d diff --git a/test/issue2046-ignored-optional-with-path/sample/source/app.d b/test/issue2046-ignored-optional-with-path/sample/source/app.d new file mode 100644 index 0000000000..fcf2da6574 --- /dev/null +++ b/test/issue2046-ignored-optional-with-path/sample/source/app.d @@ -0,0 +1,6 @@ +import libbar.bar; + +void main() +{ + bar(); +} diff --git a/test/issue2046-ignored-optional-with-path/source/app.d b/test/issue2046-ignored-optional-with-path/source/app.d index fcf2da6574..213a7b0c7c 100644 --- a/test/issue2046-ignored-optional-with-path/source/app.d +++ b/test/issue2046-ignored-optional-with-path/source/app.d @@ -1,6 +1,22 @@ -import libbar.bar; +import common; -void main() -{ - bar(); +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + chdir("sample"); + + copy("dub.selections.json-nofoo", "dub.selections.json"); + auto p = teeProcess([dub, "-f"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + if (!p.stdout.canFind("no-foo")) + die("DUB didn't ignore the optional dependency when it wasn't present in dub.selections.json"); + + copy("dub.selections.json-usefoo", "dub.selections.json"); + p = teeProcess([dub, "-f"], Redirect.stdout | Redirect.stderrToStdout); + if (!p.stdout.canFind("use-foo")) + die("DUB didn't ignore the optional dependency when it wasn't present in dub.selections.json"); } diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails.d b/test/issue2051_running_unittests_from_dub_single_file_packages_fails.d deleted file mode 100644 index daa6ae870d..0000000000 --- a/test/issue2051_running_unittests_from_dub_single_file_packages_fails.d +++ /dev/null @@ -1,103 +0,0 @@ -/+ dub.sdl: - name "issue2051" - +/ - -import std.algorithm : any; -import std.conv : text; -import std.file : tempDir; -import std.stdio : File, writeln; -import std.string : lineSplitter; -import std.path : buildPath, buildNormalizedPath; -import std.process : environment, executeShell; - -auto executeCommand(string command) -{ - import std.exception : enforce; - - auto dub = executeShell(command); - writeln("--- dub output:"); - foreach(line; dub.output.lineSplitter) - writeln("\t", line); - writeln("--- end of dub output"); - - return dub.status; -} - -int main() -{ - auto dub = environment.get("DUB"); - if (!dub.length) - dub = buildPath(".", "bin", "dub"); - - string destinationDirectory = tempDir; - // remove any ending slahes (which can for some reason be added at the end by tempDir, which fails on OSX) https://issues.dlang.org/show_bug.cgi?id=22738 - destinationDirectory = buildNormalizedPath(destinationDirectory); - - string filename; - // check if the single file package with dependency compiles and runs - { - filename = destinationDirectory.buildPath("issue2051_success.d"); - auto f = File(filename, "w"); - f.write( -`#!/usr/bin/env dub -/+ dub.sdl: - name "issue2051" - dependency "taggedalgebraic" version="~>0.11.0" -+/ - -version(unittest) {} -else void main() -{ -} - -unittest -{ - import taggedalgebraic; - - static union Base { - int i; - string str; - } - - auto dummy = TaggedAlgebraic!Base(1721); - assert(dummy == 1721); -} -` ); - } - - const rc1 = text(dub, " test --single \"", filename, "\"").executeCommand; - if (rc1) - writeln("\nError. Unittests failed."); - else - writeln("\nOk. Unittest passed."); - - // Check if dub `test` command runs unittests for single file package - { - filename = destinationDirectory.buildPath("issue2051_fail.d"); - auto f = File(filename, "w"); - f.write( -`#!/usr/bin/env dub -/+ dub.sdl: - name "issue2051" -+/ - -version(unittest) {} -else void main() -{ -} - -unittest -{ - assert(0); -} -` ); - } - - const rc2 = text(dub, " test --single \"", filename, "\"").executeCommand; - if (rc2) - writeln("\nOk. Unittests failed."); - else - writeln("\nError. Unittest passed."); - - return rc1 | !rc2; -} diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails/.gitignore b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/.gitignore new file mode 100644 index 0000000000..c67e247b8a --- /dev/null +++ b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/.gitignore @@ -0,0 +1,2 @@ +!/single_success.d +!/single_failure.d diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails/dub.json b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/dub.json new file mode 100644 index 0000000000..8d2ec2a4f6 --- /dev/null +++ b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2051_running_unittests_from_dub_single_file_packages_fails", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_failure.d b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_failure.d new file mode 100644 index 0000000000..a1dbeeb30b --- /dev/null +++ b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_failure.d @@ -0,0 +1,14 @@ +#!/usr/bin/env dub +/+ dub.sdl: + name "issue2051-failure" ++/ + +version(unittest) {} +else void main() +{ +} + +unittest +{ + assert(0); +} diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_success.d b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_success.d new file mode 100644 index 0000000000..60a978b082 --- /dev/null +++ b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/single_success.d @@ -0,0 +1,23 @@ +#!/usr/bin/env dub +/+ dub.sdl: + name "issue2051-success" + dependency "taggedalgebraic" version="~>0.11.0" ++/ + +version(unittest) {} +else void main() +{ +} + +unittest +{ + import taggedalgebraic; + + static union Base { + int i; + string str; + } + + auto dummy = TaggedAlgebraic!Base(1721); + assert(dummy == 1721); +} diff --git a/test/issue2051_running_unittests_from_dub_single_file_packages_fails/source/app.d b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/source/app.d new file mode 100644 index 0000000000..0551a0f78e --- /dev/null +++ b/test/issue2051_running_unittests_from_dub_single_file_packages_fails/source/app.d @@ -0,0 +1,17 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + // DFLAGS disable unittests: https://github.com/dlang/dub/pull/3060 + environment.remove("DFLAGS"); + + if (spawnProcess([dub, "test", "--single", "single_success.d"]).wait != 0) + die("Unittest should have passed"); + + if (spawnProcess([dub, "test", "--single", "single_failure.d"]).wait == 0) + die("Unittest should have failed"); +} diff --git a/test/issue2085-target-none-visuald.sh b/test/issue2085-target-none-visuald.sh deleted file mode 100755 index 8012f5ac19..0000000000 --- a/test/issue2085-target-none-visuald.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd "${CURR_DIR}/issue2085-target-none-visuald" || die "Could not cd." - -"$DUB" generate visuald - -if grep -c -e \"\" .dub/root.visualdproj; then - die $LINENO 'Regression of issue #2085.' -fi diff --git a/test/issue2085-target-none-visuald/.gitignore b/test/issue2085-target-none-visuald/.gitignore new file mode 100644 index 0000000000..2f019e7f82 --- /dev/null +++ b/test/issue2085-target-none-visuald/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/sub/ +!/sample/sub/** diff --git a/test/issue2085-target-none-visuald/.no_build b/test/issue2085-target-none-visuald/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2085-target-none-visuald/.no_run b/test/issue2085-target-none-visuald/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2085-target-none-visuald/dub.json b/test/issue2085-target-none-visuald/dub.json index 70862f5c05..4aeab2a824 100644 --- a/test/issue2085-target-none-visuald/dub.json +++ b/test/issue2085-target-none-visuald/dub.json @@ -1,10 +1,8 @@ { - "name": "root", - "targetType": "none", - "dependencies": { - "root:sub": "*" - }, - "subPackages": [ - "sub" - ] + "name": "issue2085-target-none-visuald", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue2085-target-none-visuald/sample/dub.json b/test/issue2085-target-none-visuald/sample/dub.json new file mode 100644 index 0000000000..70862f5c05 --- /dev/null +++ b/test/issue2085-target-none-visuald/sample/dub.json @@ -0,0 +1,10 @@ +{ + "name": "root", + "targetType": "none", + "dependencies": { + "root:sub": "*" + }, + "subPackages": [ + "sub" + ] +} diff --git a/test/issue2085-target-none-visuald/sub/dub.json b/test/issue2085-target-none-visuald/sample/sub/dub.json similarity index 100% rename from test/issue2085-target-none-visuald/sub/dub.json rename to test/issue2085-target-none-visuald/sample/sub/dub.json diff --git a/test/issue2085-target-none-visuald/sample/sub/source/app.d b/test/issue2085-target-none-visuald/sample/sub/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue2085-target-none-visuald/sample/sub/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue2085-target-none-visuald/source/app.d b/test/issue2085-target-none-visuald/source/app.d new file mode 100644 index 0000000000..029c777835 --- /dev/null +++ b/test/issue2085-target-none-visuald/source/app.d @@ -0,0 +1,14 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + if (spawnProcess([dub, "generate", "visuald"], null, Config.none, "sample").wait != 0) + die("Dub generate failed"); + + if (readText("sample/.dub/root.visualdproj").canFind(``)) + die("Regression of issue #2085."); +} diff --git a/test/issue2086-copyfiles-subpackage-targetpath.sh b/test/issue2086-copyfiles-subpackage-targetpath.sh deleted file mode 100755 index 9502f8cda4..0000000000 --- a/test/issue2086-copyfiles-subpackage-targetpath.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd "${CURR_DIR}/issue2086-copyfiles-subpackage-targetpath" || die "Could not cd." - -rm -f "sub/to_be_deployed.txt" - -"$DUB" build -./sub/sub diff --git a/test/issue2086-copyfiles-subpackage-targetpath/.gitignore b/test/issue2086-copyfiles-subpackage-targetpath/.gitignore new file mode 100644 index 0000000000..438f2ab5c8 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/.gitignore @@ -0,0 +1,9 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/sub/ +!/sample/sub/dub.json +!/sample/sub/files/ +!/sample/sub/files/* +!/sample/sub/source/ +!/sample/sub/source/* diff --git a/test/issue2086-copyfiles-subpackage-targetpath/.no_run b/test/issue2086-copyfiles-subpackage-targetpath/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2086-copyfiles-subpackage-targetpath/.no_test b/test/issue2086-copyfiles-subpackage-targetpath/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2086-copyfiles-subpackage-targetpath/dub.json b/test/issue2086-copyfiles-subpackage-targetpath/dub.json index 70862f5c05..d033f348b7 100644 --- a/test/issue2086-copyfiles-subpackage-targetpath/dub.json +++ b/test/issue2086-copyfiles-subpackage-targetpath/dub.json @@ -1,10 +1,8 @@ { - "name": "root", - "targetType": "none", - "dependencies": { - "root:sub": "*" - }, - "subPackages": [ - "sub" - ] + "name": "issue2086-copyfiles-subpackage-targetpath", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sample/dub.json b/test/issue2086-copyfiles-subpackage-targetpath/sample/dub.json new file mode 100644 index 0000000000..70862f5c05 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/sample/dub.json @@ -0,0 +1,10 @@ +{ + "name": "root", + "targetType": "none", + "dependencies": { + "root:sub": "*" + }, + "subPackages": [ + "sub" + ] +} diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json b/test/issue2086-copyfiles-subpackage-targetpath/sample/sub/dub.json similarity index 100% rename from test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json rename to test/issue2086-copyfiles-subpackage-targetpath/sample/sub/dub.json diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/files/to_be_deployed.txt b/test/issue2086-copyfiles-subpackage-targetpath/sample/sub/files/to_be_deployed.txt similarity index 100% rename from test/issue2086-copyfiles-subpackage-targetpath/sub/files/to_be_deployed.txt rename to test/issue2086-copyfiles-subpackage-targetpath/sample/sub/files/to_be_deployed.txt diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/source/app.d b/test/issue2086-copyfiles-subpackage-targetpath/sample/sub/source/app.d similarity index 100% rename from test/issue2086-copyfiles-subpackage-targetpath/sub/source/app.d rename to test/issue2086-copyfiles-subpackage-targetpath/sample/sub/source/app.d diff --git a/test/issue2086-copyfiles-subpackage-targetpath/source/app.d b/test/issue2086-copyfiles-subpackage-targetpath/source/app.d new file mode 100644 index 0000000000..4ddf277f86 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/source/app.d @@ -0,0 +1,18 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + immutable path = "sub/to_be_deployed.txt"; + if (path.exists) path.remove; + + if (spawnProcess([dub, "build"]).wait != 0) + die("Dub build falied"); + if (spawnProcess("./sub/sub").wait != 0) + die("Running the subpackage failed"); +} diff --git a/test/issue2190-unset-TEMP.script.d b/test/issue2190-unset-TEMP.script.d deleted file mode 100644 index 398695346e..0000000000 --- a/test/issue2190-unset-TEMP.script.d +++ /dev/null @@ -1,51 +0,0 @@ -/+ dub.json: { - "name": "issue2190_unset_TEMP" -} +/ - -module issue2190_unset_TEMP.script; - -int main() -{ - import std.stdio; - import std.algorithm; - import std.path; - import std.process; - - const dir = __FILE_FULL_PATH__.dirName(); - - // doesn't matter, just pick something - const file = buildPath(dir, "single-file-sdl-default-name.d"); - - const dub = environment.get("DUB", buildPath(dirName(dir), "bin", "dub.exe")); - - int exitCode; - - void runTest(scope const string[] cmd) - { - const result = execute(cmd); - - if (result.status || result.output.canFind("Failed")) - { - writefln("\n> %-(%s %)", cmd); - writeln("==========================================================="); - writeln(result.output); - writeln("==========================================================="); - writeln("Last command failed with exit code ", result.status, '\n'); - exitCode = 1; - } - } - - environment.remove("TEMP"); - - // only guaranteed to be there on Windows - // See: runDubCommandLine in commandline - version(Windows) - { - runTest([ - dub, "build", - "--single", file, - ]); - } - - return exitCode; -} diff --git a/test/issue2190-unset-TEMP/.gitignore b/test/issue2190-unset-TEMP/.gitignore new file mode 100644 index 0000000000..96ae139c5d --- /dev/null +++ b/test/issue2190-unset-TEMP/.gitignore @@ -0,0 +1 @@ +!/single.d diff --git a/test/issue2190-unset-TEMP/dub.json b/test/issue2190-unset-TEMP/dub.json new file mode 100644 index 0000000000..9df4e85855 --- /dev/null +++ b/test/issue2190-unset-TEMP/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2190-unset-TEMP", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2190-unset-TEMP/single.d b/test/issue2190-unset-TEMP/single.d new file mode 100644 index 0000000000..9a6a0e2b30 --- /dev/null +++ b/test/issue2190-unset-TEMP/single.d @@ -0,0 +1,10 @@ +/++dub.sdl: + name "issue2190-single" ++/ +module single; + +void main() +{ + import std.stdio; + writeln("Hello, world!"); +} diff --git a/test/issue2190-unset-TEMP/source/app.d b/test/issue2190-unset-TEMP/source/app.d new file mode 100644 index 0000000000..63dc31a289 --- /dev/null +++ b/test/issue2190-unset-TEMP/source/app.d @@ -0,0 +1,13 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + environment.remove("TEMP"); + + if (spawnProcess([dub, "build", "--single", "single.d"]).wait != 0) + die("dub build with unset TEMP failed"); +} diff --git a/test/issue2190-unset-TEMP/test.config b/test/issue2190-unset-TEMP/test.config new file mode 100644 index 0000000000..9aae66f369 --- /dev/null +++ b/test/issue2190-unset-TEMP/test.config @@ -0,0 +1 @@ +os = windows \ No newline at end of file diff --git a/test/issue2192-environment-variables.sh b/test/issue2192-environment-variables.sh deleted file mode 100755 index df862ed9c0..0000000000 --- a/test/issue2192-environment-variables.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if [ -n "${DUB_PACKAGE-}" ]; then - die $LINENO '$DUB_PACKAGE must not be set when running this test!' -fi - -if ! { $DUB build --force --root "$CURR_DIR/issue2192-environment-variables" --skip-registry=all; }; then - die $LINENO 'Failed to build package with built-in environment variables.' -fi - -if [ -s "$CURR_DIR/issue2192-environment-variables/package.txt" ]; then - rm "$CURR_DIR/issue2192-environment-variables/package.txt" -else - die $LINENO 'Expected generated package.txt file is missing.' -fi - -OUTPUT=$($DUB describe --root "$CURR_DIR/issue2192-environment-variables" --skip-registry=all --data=pre-build-commands --data-list) -if [ "$OUTPUT" != "echo 'issue2192-environment-variables' > package.txt" ]; then - die $LINENO 'describe did not contain subtituted values or the correct package name' -fi diff --git a/test/issue2192-environment-variables/.gitignore b/test/issue2192-environment-variables/.gitignore new file mode 100644 index 0000000000..d4a7b052d4 --- /dev/null +++ b/test/issue2192-environment-variables/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue2192-environment-variables/.no_run b/test/issue2192-environment-variables/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2192-environment-variables/dub.json b/test/issue2192-environment-variables/dub.json new file mode 100644 index 0000000000..5fb9e09855 --- /dev/null +++ b/test/issue2192-environment-variables/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2192-environment-variables", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2192-environment-variables/dub.sdl b/test/issue2192-environment-variables/sample/dub.sdl similarity index 100% rename from test/issue2192-environment-variables/dub.sdl rename to test/issue2192-environment-variables/sample/dub.sdl diff --git a/test/issue2192-environment-variables/source/lib.d b/test/issue2192-environment-variables/sample/source/lib.d similarity index 100% rename from test/issue2192-environment-variables/source/lib.d rename to test/issue2192-environment-variables/sample/source/lib.d diff --git a/test/issue2192-environment-variables/source/app.d b/test/issue2192-environment-variables/source/app.d new file mode 100644 index 0000000000..623ca7994a --- /dev/null +++ b/test/issue2192-environment-variables/source/app.d @@ -0,0 +1,26 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.string; + +void main () { + environment.remove("DUB_PACKAGE"); + immutable expectedPath = "sample/package.txt"; + if (exists(expectedPath)) remove(expectedPath); + + if (spawnProcess([dub, "build", "--force", "--root=sample", "--skip-registry=all"]).wait != 0) + die("Failed to build package with built-in environment variables."); + + if (!exists(expectedPath)) + die("Expected generated package.txt file is missing."); + if (readText(expectedPath).length == 0) + die("Expected generated package.txt file is empty."); + + auto p = teeProcess([dub, "describe", "--root=sample", "--skip-registry=all", "--data=pre-build-commands", "--data-list"]); + p.wait; + if (p.stdout.chomp != `echo 'issue2192-environment-variables' > package.txt`) + die("describe did not contain subtituted values or the correct package name"); +} diff --git a/test/issue2234-copy-read-only-files.script.d b/test/issue2234-copy-read-only-files.script.d deleted file mode 100644 index 9383e9020f..0000000000 --- a/test/issue2234-copy-read-only-files.script.d +++ /dev/null @@ -1,128 +0,0 @@ -/+ dub.json: { -"name": "issue2234_copy_read_only_files" -} +/ - -/* -When DUB copies read-only files to the targetPath, the read-only flag must be -removed. If not, any subsequent copy operations will fail. - -Version control systems such as Git Large File Storage typically mark binary -files as read-only, to prevent simultaneous edits in unmergeable formats. -*/ - -module issue2234_copy_read_only_files.script; - -import - std.algorithm.searching, - std.algorithm.iteration, - std.stdio, std.process, std.path, std.file; - -int main() -{ - const project_dir = buildPath(__FILE_FULL_PATH__.dirName, "issue2234-copy-read-only-files"); - const deployment_dir = buildPath(project_dir, "bin"); - auto deployables = dirEntries(buildPath(project_dir, "files"), "*", SpanMode.depth).filter!isFile; - - // Prepare environment. - if (deployment_dir.exists) - { - foreach (entry; dirEntries(deployment_dir, "*", SpanMode.depth)) - { - if (entry.isDir) - entry.rmdir; - else - { - entry.makeWritable; - entry.remove; - } - } - deployment_dir.rmdir; - } - foreach (ref f; deployables) - f.makeReadOnly; - - // Execute test. - const dub = environment.get("DUB", buildPath(__FILE_FULL_PATH__.dirName.dirName, "bin", "dub.exe")); - const cmd = [dub, "build", "--build=release"]; - const result = execute(cmd, null, Config.none, size_t.max, project_dir); - if (result.status || result.output.canFind("Failed")) - { - writefln("\n> %-(%s %)", cmd); - writeln("==========================================================="); - writeln(result.output); - writeln("==========================================================="); - writeln("Last command failed with exit code ", result.status, '\n'); - return 1; - } - - foreach (deployed; dirEntries(deployment_dir, "*", SpanMode.depth).filter!isFile) - if (!isWritable(deployed)) - { - writeln(deployed, " is expected to be writable, but it is not."); - return 1; - } - - return 0; -} - -void makeReadOnly(string name) -{ - version (Windows) - { - import core.sys.windows.windows; - - name.setAttributes(name.getAttributes() | FILE_ATTRIBUTE_READONLY); - } - else version (Posix) - { - import core.sys.posix.sys.stat; - - name.setAttributes(name.getAttributes() & ~(S_IWUSR | S_IWGRP | S_IWOTH)); - } - else - static assert("Needs implementation."); - - import std.exception; - import std.stdio; - assertThrown!ErrnoException(File(name, "w")); -} - -void makeWritable(string name) -{ - version (Windows) - { - import core.sys.windows.windows; - - name.setAttributes(name.getAttributes() & ~FILE_ATTRIBUTE_READONLY); - } - else version (Posix) - { - import core.sys.posix.sys.stat; - - name.setAttributes(name.getAttributes() | S_IWUSR); - } - else - static assert("Needs implementation."); - - import std.exception; - import std.stdio; - assertNotThrown!ErrnoException(File(name, "w")); -} - -bool isWritable(string name) -{ - version (Windows) - { - import core.sys.windows.windows; - - return (name.getAttributes() & FILE_ATTRIBUTE_READONLY) == 0; - } - else version (Posix) - { - import core.sys.posix.sys.stat; - - return (name.getAttributes() & S_IWUSR) != 0; - } - else - static assert("Needs implementation."); -} diff --git a/test/issue2234-copy-read-only-files/.gitignore b/test/issue2234-copy-read-only-files/.gitignore index ba077a4031..7b5e5bd459 100644 --- a/test/issue2234-copy-read-only-files/.gitignore +++ b/test/issue2234-copy-read-only-files/.gitignore @@ -1 +1,7 @@ -bin +/sample/** +!/sample/ +!/sample/dub.json +!/sample/files/ +!/sample/files/** +!/sample/source +!/sample/source/* diff --git a/test/issue2234-copy-read-only-files/dub.json b/test/issue2234-copy-read-only-files/dub.json index f911f1d1dc..3f19f7b615 100644 --- a/test/issue2234-copy-read-only-files/dub.json +++ b/test/issue2234-copy-read-only-files/dub.json @@ -1,8 +1,8 @@ { - "name": "issue2234_copy_read_only_files", - "copyFiles": [ - "files/to_be_deployed.bin", - "files/images" - ], - "targetPath": "bin" + "name": "issue2234-copy-read-only-files", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue2234-copy-read-only-files/sample/dub.json b/test/issue2234-copy-read-only-files/sample/dub.json new file mode 100644 index 0000000000..f911f1d1dc --- /dev/null +++ b/test/issue2234-copy-read-only-files/sample/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2234_copy_read_only_files", + "copyFiles": [ + "files/to_be_deployed.bin", + "files/images" + ], + "targetPath": "bin" +} diff --git a/test/issue2234-copy-read-only-files/files/images/to_be_deployed.img b/test/issue2234-copy-read-only-files/sample/files/images/to_be_deployed.img similarity index 100% rename from test/issue2234-copy-read-only-files/files/images/to_be_deployed.img rename to test/issue2234-copy-read-only-files/sample/files/images/to_be_deployed.img diff --git a/test/issue2234-copy-read-only-files/files/to_be_deployed.bin b/test/issue2234-copy-read-only-files/sample/files/to_be_deployed.bin similarity index 100% rename from test/issue2234-copy-read-only-files/files/to_be_deployed.bin rename to test/issue2234-copy-read-only-files/sample/files/to_be_deployed.bin diff --git a/test/issue2234-copy-read-only-files/sample/source/app.d b/test/issue2234-copy-read-only-files/sample/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue2234-copy-read-only-files/sample/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue2234-copy-read-only-files/source/app.d b/test/issue2234-copy-read-only-files/source/app.d index ab73b3a234..2a981b36dd 100644 --- a/test/issue2234-copy-read-only-files/source/app.d +++ b/test/issue2234-copy-read-only-files/source/app.d @@ -1 +1,98 @@ -void main() {} +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + immutable deploymentDir = "sample/bin"; + auto deployables = dirEntries("sample/files", SpanMode.depth).filter!isFile; + + if (deploymentDir.exists) { + foreach (entry; dirEntries(deploymentDir, SpanMode.depth)) + if (entry.isDir) + entry.rmdir; + else { + entry.makeWritable; + entry.remove; + } + deploymentDir.rmdirRecurse; + } + + foreach (ref f; deployables) + f.makeReadOnly; + + if (spawnProcess([dub, "build", "--build=release"], null, Config.none, "sample").wait != 0) + die("Dub build failed"); + + foreach (deployed; dirEntries(deploymentDir, SpanMode.depth).filter!isFile) + if (!isWritable(deployed)) + die(deployed, " is expected to be writable, but it is not."); +} + +void makeReadOnly(string name) +{ + version (Windows) + { + import core.sys.windows.windows; + + name.setAttributes(name.getAttributes() | FILE_ATTRIBUTE_READONLY); + } + else version (Posix) + { + import core.sys.posix.sys.stat; + + name.setAttributes(name.getAttributes() & ~(S_IWUSR | S_IWGRP | S_IWOTH)); + } + else + static assert(false, "Needs implementation."); + + // This fails on posix when run as root. Just assume that the + // functions above work. + version(none) { + import std.exception; + import std.stdio; + assertThrown!ErrnoException(File(name, "w")); + } +} + +void makeWritable(string name) +{ + version (Windows) + { + import core.sys.windows.windows; + + name.setAttributes(name.getAttributes() & ~FILE_ATTRIBUTE_READONLY); + } + else version (Posix) + { + import core.sys.posix.sys.stat; + + name.setAttributes(name.getAttributes() | S_IWUSR); + } + else + static assert(false, "Needs implementation."); + + import std.exception; + import std.stdio; + assertNotThrown!ErrnoException(File(name, "w")); +} + +bool isWritable(string name) +{ + version (Windows) + { + import core.sys.windows.windows; + + return (name.getAttributes() & FILE_ATTRIBUTE_READONLY) == 0; + } + else version (Posix) + { + import core.sys.posix.sys.stat; + + return (name.getAttributes() & S_IWUSR) != 0; + } + else + static assert(false, "Needs implementation."); +} diff --git a/test/issue2258-dynLib-exe-dep/.no_build_dmd b/test/issue2258-dynLib-exe-dep/.no_build_dmd deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2258-dynLib-exe-dep/.no_build_gdc b/test/issue2258-dynLib-exe-dep/.no_build_gdc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2258-dynLib-exe-dep/dub.json b/test/issue2258-dynLib-exe-dep/dub.json index 30a9f4b5cb..ccb2e071c2 100644 --- a/test/issue2258-dynLib-exe-dep/dub.json +++ b/test/issue2258-dynLib-exe-dep/dub.json @@ -1,5 +1,5 @@ { - "name": "dynlib-exe-dep", + "name": "issue2258-dynlib-exe-dep", "targetType": "executable", "dependencies": { "dynlib-simple": { "path": "../1-dynLib-simple/" } diff --git a/test/issue2258-dynLib-exe-dep/test.config b/test/issue2258-dynLib-exe-dep/test.config new file mode 100644 index 0000000000..062eb71078 --- /dev/null +++ b/test/issue2258-dynLib-exe-dep/test.config @@ -0,0 +1,2 @@ +dc_backend = ldc +locks = 1-dynLib-simple \ No newline at end of file diff --git a/test/issue2262-exact-cached-version-match.sh b/test/issue2262-exact-cached-version-match.sh deleted file mode 100755 index faa5e5b764..0000000000 --- a/test/issue2262-exact-cached-version-match.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname ${BASH_SOURCE[0]})/common.sh - -PACK_PATH="$CURR_DIR"/issue2262-exact-cached-version-match - -# make sure that there are no left-over selections files -rm -f $PACK_PATH/dub.selections.json - -# make sure that there are no cached versions of the dependency -dub remove gitcompatibledubpackage@* -n || true - -# build normally, should select 1.0.4 -if ! ${DUB} build --root $PACK_PATH | grep "gitcompatibledubpackage 1\.0\.4:"; then - die $LINENO 'The initial build failed.' -fi -dub remove gitcompatibledubpackage@* -n || true - -# build with git dependency to a specific commit -cat > $PACK_PATH/dub.selections.json << EOF -{ - "fileVersion": 1, - "versions": { - "gitcompatibledubpackage": { - "repository": "git+https://github.com/dlang-community/gitcompatibledubpackage.git", - "version": "ccb31bf6a655437176ec02e04c2305a8c7c90d67" - } - } -} -EOF -if ! ${DUB} build --root $PACK_PATH | grep "gitcompatibledubpackage 1\.0\.4+commit\.2\.gccb31bf:"; then - die $LINENO 'The build with a specific commit failed.' -fi - -# select 1.0.4 again -cat > $PACK_PATH/dub.selections.json << EOF -{ - "fileVersion": 1, - "versions": { - "gitcompatibledubpackage": "1.0.4" - } -} -EOF -if ! ${DUB} build --root $PACK_PATH | grep "gitcompatibledubpackage 1\.0\.4:"; then - die $LINENO 'The second 1.0.4 build failed.' -fi - -# clean up -rm -f $PACK_PATH/dub.selections.json diff --git a/test/issue2262-exact-cached-version-match/.gitignore b/test/issue2262-exact-cached-version-match/.gitignore new file mode 100644 index 0000000000..983d10db3b --- /dev/null +++ b/test/issue2262-exact-cached-version-match/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample +!/sample/dub.sdl +!/sample/source/ +!/sample/source/**.d \ No newline at end of file diff --git a/test/issue2262-exact-cached-version-match/.no_build b/test/issue2262-exact-cached-version-match/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2262-exact-cached-version-match/dub.json b/test/issue2262-exact-cached-version-match/dub.json new file mode 100644 index 0000000000..c9efe6912d --- /dev/null +++ b/test/issue2262-exact-cached-version-match/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2262-exact-cached-version-match", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2262-exact-cached-version-match/dub.sdl b/test/issue2262-exact-cached-version-match/sample/dub.sdl similarity index 100% rename from test/issue2262-exact-cached-version-match/dub.sdl rename to test/issue2262-exact-cached-version-match/sample/dub.sdl diff --git a/test/issue2262-exact-cached-version-match/sample/source/app.d b/test/issue2262-exact-cached-version-match/sample/source/app.d new file mode 100644 index 0000000000..ab73b3a234 --- /dev/null +++ b/test/issue2262-exact-cached-version-match/sample/source/app.d @@ -0,0 +1 @@ +void main() {} diff --git a/test/issue2262-exact-cached-version-match/source/app.d b/test/issue2262-exact-cached-version-match/source/app.d index ab73b3a234..92a5d00796 100644 --- a/test/issue2262-exact-cached-version-match/source/app.d +++ b/test/issue2262-exact-cached-version-match/source/app.d @@ -1 +1,54 @@ -void main() {} +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + // make sure that there are no left-over selections files + if (exists("dub.selections.json")) remove("dub.selections.json"); + + // make sure that there are no cached versions of the dependency + // dub remove fails to remove the git package on windows + if (exists(dubHome)) rmdirRecurse(dubHome); + + // build normally, should select 1.0.4 + auto p = teeProcess([dub, "build"]); + if (p.wait != 0 || !p.stdout.canFind(`gitcompatibledubpackage 1.0.4:`)) + die("The initial build failed."); + + spawnProcess([dub, "remove", "gitcompatibledubpackage@*", "-n"]).wait; + + // build with git dependency to a specific commit + write("dub.selections.json", ` +{ + "fileVersion": 1, + "versions": { + "gitcompatibledubpackage": { + "repository": "git+https://github.com/dlang-community/gitcompatibledubpackage.git", + "version": "ccb31bf6a655437176ec02e04c2305a8c7c90d67" + } + } +} +`); + p = teeProcess([dub, "build"]); + if (p.wait != 0 || !p.stdout.canFind(`gitcompatibledubpackage 1.0.4+commit.2.gccb31bf:`)) { + die("The build with a specific commit failed."); + } + + // select 1.0.4 again + write("dub.selections.json", ` +{ + "fileVersion": 1, + "versions": { + "gitcompatibledubpackage": "1.0.4" + } +} +`); + p = teeProcess([dub, "build"]); + if (p.wait != 0 || !p.stdout.canFind(`gitcompatibledubpackage 1.0.4:`)) + die("The second 1.0.4 build failed."); +} diff --git a/test/issue2348-postbuildcommands.script.d b/test/issue2348-postbuildcommands.script.d deleted file mode 100644 index a65a280f1e..0000000000 --- a/test/issue2348-postbuildcommands.script.d +++ /dev/null @@ -1,30 +0,0 @@ -/+ dub.sdl: -name "issue2348" -buildType "test" { - buildOptions "syntaxOnly" - postBuildCommands "echo xxx" -} -+/ -module issue2348; - -import std.process; -import std.stdio; -import std.algorithm; -import std.path; - -int main() -{ - const dub = environment.get("DUB", buildPath(__FILE_FULL_PATH__.dirName.dirName, "bin", "dub.exe")); - const cmd = [dub, "build", "--build=test", "--single", __FILE_FULL_PATH__]; - const result = execute(cmd, null, Config.none, size_t.max, __FILE_FULL_PATH__.dirName); - if (result.status || result.output.canFind("Failed")) - { - writefln("\n> %-(%s %)", cmd); - writeln("==========================================================="); - writeln(result.output); - writeln("==========================================================="); - writeln("Last command failed with exit code ", result.status, '\n'); - return 1; - } - return 0; -} diff --git a/test/issue2348-postbuildcommands/.gitignore b/test/issue2348-postbuildcommands/.gitignore new file mode 100644 index 0000000000..96ae139c5d --- /dev/null +++ b/test/issue2348-postbuildcommands/.gitignore @@ -0,0 +1 @@ +!/single.d diff --git a/test/issue2348-postbuildcommands/dub.json b/test/issue2348-postbuildcommands/dub.json new file mode 100644 index 0000000000..d14f11e433 --- /dev/null +++ b/test/issue2348-postbuildcommands/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2348-postbuildcommands", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2348-postbuildcommands/single.d b/test/issue2348-postbuildcommands/single.d new file mode 100644 index 0000000000..c3292c9245 --- /dev/null +++ b/test/issue2348-postbuildcommands/single.d @@ -0,0 +1,7 @@ +/+ dub.sdl: +name "issue2348-single" +buildType "test" { + buildOptions "syntaxOnly" + postBuildCommands "echo xxx" +} ++/ diff --git a/test/issue2348-postbuildcommands/source/app.d b/test/issue2348-postbuildcommands/source/app.d new file mode 100644 index 0000000000..6515d9086b --- /dev/null +++ b/test/issue2348-postbuildcommands/source/app.d @@ -0,0 +1,8 @@ +import common; + +import std.process; + +void main () { + if (spawnProcess([dub, "build", "--build=test", "--single", "single.d"]).wait != 0) + die("Dub build failed"); +} diff --git a/test/issue2377-dynLib-dep-extra-files.script.d b/test/issue2377-dynLib-dep-extra-files.script.d deleted file mode 100644 index 4eb90ec4bd..0000000000 --- a/test/issue2377-dynLib-dep-extra-files.script.d +++ /dev/null @@ -1,135 +0,0 @@ -/+ dub.sdl: -name "issue2377_dynlib_dep_extra_files" -+/ - -module issue2377_dynlib_dep_extra_files.script; - -import std.exception : enforce; -import std.file; -import std.path; - -version (DigitalMars) version (Windows) version = DMD_Windows; -version (DMD_Windows) { - void main() { - import std.stdio; - writeln("WARNING: skipping test '" ~ __FILE_FULL_PATH__.baseName ~ "' with DMD on Windows."); - } -} else: - -void main() { - import std.process : environment; - - version (Windows) enum exeExt = ".exe"; - else enum exeExt = ""; - const dub = environment.get("DUB", buildPath(__FILE_FULL_PATH__.dirName.dirName, "bin", "dub"~exeExt)); - - enum testDir = buildPath(__FILE_FULL_PATH__.dirName, "issue2377-dynLib-dep-extra-files"); - - // 1. `parent` as root package (depending on dynamic/static dep1, which depends on dynamic/static dep2) - chdir(buildPath(testDir, "parent")); - if (exists("output")) - rmdirRecurse("output"); - - // 1.1 dynlib config - run(dub ~ " build -c dynlib"); - chdir("output/dynlib"); - assertDynLibExists("parent"); - assertDynLibExists("dep1"); - assertDynLibExists("dep2"); - version (Windows) { - assertFileExists("parent.pdb"); - assertFileExists("parent.lib"); - assertFileExists("parent.exp"); - assertFileExists("dep1.pdb"); - assertFileExists("dep1.lib"); - assertFileExists("dep1.exp"); - assertFileExists("dep2.pdb"); - assertFileExists("dep2.lib"); - assertFileExists("dep2.exp"); - } - chdir("../.."); - - // 1.2 dynlib_static config - run(dub ~ " build -c dynlib_static"); - chdir("output/dynlib_static"); - assertDynLibExists("parent"); - version (Windows) { - assertFileExists("parent.pdb"); - assertFileExists("parent.lib"); - assertFileExists("parent.exp"); - } - enforce(!canFindFiles("*dep*"), "unexpected dependency files in statically linked dynlib output dir"); - chdir("../.."); - - // 1.3 exe_static config - run(dub ~ " build -c exe_static"); - chdir("output/exe_static"); - version (Windows) run(`.\parent.exe`); - else run("./parent"); - version (Windows) { - assertFileExists("parent.pdb"); - enforce(!exists("parent.lib"), "unexpected import .lib for executable"); - enforce(!exists("parent.exp"), "unexpected .exp file for executable"); - } - enforce(!canFindFiles("*dep*"), "unexpected dependency files in statically linked executable output dir"); - chdir("../.."); - - // 1.4 exe_dynamic config - run(dub ~ " build -c exe_dynamic"); - chdir("output/exe_dynamic"); - version (Windows) run(`.\parent.exe`); - else run(`LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH:-}" ./parent`); - assertDynLibExists("dep1"); - assertDynLibExists("dep2"); - version (Windows) { - assertFileExists("dep1.pdb"); - assertFileExists("dep2.pdb"); - enforce(!canFindFiles("*.lib"), "unexpected import libs in dynamically linked executable output dir"); - enforce(!canFindFiles("*.exp"), "unexpected .exp files in dynamically linked executable output dir"); - } - chdir("../.."); - - // 2. `framework` as root package (targetType `none`) - chdir(buildPath(testDir, "framework")); - run(dub ~ " build"); - assertDynLibExists("dep1"); - assertDynLibExists("dep2"); - version (Windows) { - assertFileExists("dep1.pdb"); - assertFileExists("dep1.lib"); - assertFileExists("dep1.exp"); - assertFileExists("dep2.pdb"); - assertFileExists("dep2.lib"); - assertFileExists("dep2.exp"); - } -} - -void run(string command) { - import std.process; - const status = spawnShell(command).wait(); - enforce(status == 0, "command '" ~ command ~ "' failed"); -} - -void assertFileExists(string path) { - enforce(exists(path), "expected file '" ~ path ~ "' not found"); -} - -void assertDynLibExists(string name) { - version (Windows) { - enum prefix = ""; - enum suffix = ".dll"; - } else version (OSX) { - enum prefix = "lib"; - enum suffix = ".dylib"; - } else { - enum prefix = "lib"; - enum suffix = ".so"; - } - - assertFileExists(prefix ~ name ~ suffix); -} - -bool canFindFiles(string pattern) { - auto entries = dirEntries(".", pattern, SpanMode.shallow); - return !entries.empty(); -} diff --git a/test/issue2377-dynLib-dep-extra-files/.gitignore b/test/issue2377-dynLib-dep-extra-files/.gitignore index 5d658ecbfb..9779939c7e 100644 --- a/test/issue2377-dynLib-dep-extra-files/.gitignore +++ b/test/issue2377-dynLib-dep-extra-files/.gitignore @@ -1 +1,9 @@ -/parent/output/ +/sample/** +!/sample/ +!/sample/parent/ +!/sample/dep1/ +!/sample/dep2/ +!/sample/framework/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/*.d \ No newline at end of file diff --git a/test/issue2377-dynLib-dep-extra-files/.no_build b/test/issue2377-dynLib-dep-extra-files/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2377-dynLib-dep-extra-files/dub.json b/test/issue2377-dynLib-dep-extra-files/dub.json new file mode 100644 index 0000000000..42f1d99985 --- /dev/null +++ b/test/issue2377-dynLib-dep-extra-files/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2377-dynLib-dep-extra-files", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2377-dynLib-dep-extra-files/dep1/dub.sdl b/test/issue2377-dynLib-dep-extra-files/sample/dep1/dub.sdl similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/dep1/dub.sdl rename to test/issue2377-dynLib-dep-extra-files/sample/dep1/dub.sdl diff --git a/test/issue2377-dynLib-dep-extra-files/dep1/source/dep1.d b/test/issue2377-dynLib-dep-extra-files/sample/dep1/source/dep1.d similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/dep1/source/dep1.d rename to test/issue2377-dynLib-dep-extra-files/sample/dep1/source/dep1.d diff --git a/test/issue2377-dynLib-dep-extra-files/dep2/dub.sdl b/test/issue2377-dynLib-dep-extra-files/sample/dep2/dub.sdl similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/dep2/dub.sdl rename to test/issue2377-dynLib-dep-extra-files/sample/dep2/dub.sdl diff --git a/test/issue2377-dynLib-dep-extra-files/dep2/source/dep2.d b/test/issue2377-dynLib-dep-extra-files/sample/dep2/source/dep2.d similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/dep2/source/dep2.d rename to test/issue2377-dynLib-dep-extra-files/sample/dep2/source/dep2.d diff --git a/test/issue2377-dynLib-dep-extra-files/framework/dub.sdl b/test/issue2377-dynLib-dep-extra-files/sample/framework/dub.sdl similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/framework/dub.sdl rename to test/issue2377-dynLib-dep-extra-files/sample/framework/dub.sdl diff --git a/test/issue2377-dynLib-dep-extra-files/parent/dub.sdl b/test/issue2377-dynLib-dep-extra-files/sample/parent/dub.sdl similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/parent/dub.sdl rename to test/issue2377-dynLib-dep-extra-files/sample/parent/dub.sdl diff --git a/test/issue2377-dynLib-dep-extra-files/parent/source/app.d b/test/issue2377-dynLib-dep-extra-files/sample/parent/source/app.d similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/parent/source/app.d rename to test/issue2377-dynLib-dep-extra-files/sample/parent/source/app.d diff --git a/test/issue2377-dynLib-dep-extra-files/parent/source/parent.d b/test/issue2377-dynLib-dep-extra-files/sample/parent/source/parent.d similarity index 100% rename from test/issue2377-dynLib-dep-extra-files/parent/source/parent.d rename to test/issue2377-dynLib-dep-extra-files/sample/parent/source/parent.d diff --git a/test/issue2377-dynLib-dep-extra-files/source/app.d b/test/issue2377-dynLib-dep-extra-files/source/app.d new file mode 100644 index 0000000000..2090cf0f78 --- /dev/null +++ b/test/issue2377-dynLib-dep-extra-files/source/app.d @@ -0,0 +1,129 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + version (DigitalMars) version (Windows) + skip("dmd on windows"); + + chdir("sample/parent"); + if (exists("output")) + rmdirRecurse("output"); + + + // 1.1 dynlib config + if (spawnProcess([dub, "build", "-c", "dynlib"]).wait != 0) + die("`dub build -c dynlib` failed"); + chdir("output/dynlib"); + assertDynLibExists("parent"); + assertDynLibExists("dep1"); + assertDynLibExists("dep2"); + version (Windows) { + assertFileExists("parent.pdb"); + assertFileExists("parent.lib"); + version(none) assertFileExists("parent.exp"); + assertFileExists("dep1.pdb"); + assertFileExists("dep1.lib"); + version(none) assertFileExists("dep1.exp"); + assertFileExists("dep2.pdb"); + assertFileExists("dep2.lib"); + version(none) assertFileExists("dep2.exp"); + } + chdir("../.."); + + // 1.2 dynlib_static config + if (spawnProcess([dub, "build", "-c", "dynlib_static"]).wait != 0) + die("`dub build -c dynlib_static` failed"); + chdir("output/dynlib_static"); + assertDynLibExists("parent"); + version (Windows) { + assertFileExists("parent.pdb"); + assertFileExists("parent.lib"); + version(none) assertFileExists("parent.exp"); + } + if (canFindFiles("*dep*")) + die("unexpected dependency files in statically linked dynlib output dir"); + chdir("../.."); + + // 1.3 exe_static config + if (spawnProcess([dub, "build", "-c", "exe_static"]).wait != 0) + die("`dub build -c exe_static` failed"); + chdir("output/exe_static"); + if (spawnProcess(["./parent"]).wait != 0) + die("Running the parent failed"); + version (Windows) { + assertFileExists("parent.pdb"); + if (exists("parent.lib")) + die("unexpected import .lib for executable"); + version (none) if (exists("parent.exp")) + die("unexpected .exp file for executable"); + } + if (canFindFiles("*dep*")) + die("unexpected dependency files in statically linked executable output dir"); + chdir("../.."); + + // 1.4 exe_dynamic config + if (spawnProcess([dub, "build", "-c", "exe_dynamic"]).wait != 0) + die("`dub build -c exe_dynamic` failed"); + chdir("output/exe_dynamic"); + + string[string] env; + version (Posix) env["LD_LIBRARY_PATH"] = ".:" ~ environment.get("LD_LIBRARY_PATH", ""); + if (spawnProcess(["./parent"], env).wait != 0) + die("Running the parent failed"); + assertDynLibExists("dep1"); + assertDynLibExists("dep2"); + version (Windows) { + assertFileExists("dep1.pdb"); + assertFileExists("dep2.pdb"); + if (canFindFiles("*.lib")) + die("unexpected import libs in dynamically linked executable output dir"); + version (none) if (canFindFiles("*.exp")) + die("unexpected import libs in dynamically linked executable output dir"); + } + chdir("../.."); + + // 2. `framework` as root package (targetType `none`) + chdir("../framework"); + if (spawnProcess([dub, "build"]).wait != 0) + die("`dub build` failed for framework"); + assertDynLibExists("dep1"); + assertDynLibExists("dep2"); + version (Windows) { + assertFileExists("dep1.pdb"); + assertFileExists("dep1.lib"); + version(none) assertFileExists("dep1.exp"); + assertFileExists("dep2.pdb"); + assertFileExists("dep2.lib"); + version(none) assertFileExists("dep2.exp"); + } +} + + +void assertFileExists(string path) { + if (!exists(path)) + die("Expected file '", path, "' not found"); +} + +void assertDynLibExists(string name) { + version (Windows) { + enum prefix = ""; + enum suffix = ".dll"; + } else version (OSX) { + enum prefix = "lib"; + enum suffix = ".dylib"; + } else { + enum prefix = "lib"; + enum suffix = ".so"; + } + + assertFileExists(prefix ~ name ~ suffix); +} + +bool canFindFiles(string pattern) { + auto entries = dirEntries(".", pattern, SpanMode.shallow); + return !entries.empty(); +} diff --git a/test/issue2448/.gitignore b/test/issue2448/.gitignore new file mode 100644 index 0000000000..67d836f5bb --- /dev/null +++ b/test/issue2448/.gitignore @@ -0,0 +1 @@ +!/ext/ \ No newline at end of file diff --git a/test/issue2448/dub.json b/test/issue2448/dub.json index 76c561cf2d..d98360313d 100644 --- a/test/issue2448/dub.json +++ b/test/issue2448/dub.json @@ -1,5 +1,5 @@ { - "name": "use-source-files", + "name": "issue2448-use-source-files", "description": "Example of using source files.", "sourceFiles": ["ext/*.d"] } diff --git a/test/issue2452/.no_test b/test/issue2452/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2452/dub.json b/test/issue2452/dub.json index 1260386dc2..3816cdd773 100644 --- a/test/issue2452/dub.json +++ b/test/issue2452/dub.json @@ -1,5 +1,5 @@ { - "name": "generated-sources-and-source-files-without-glob", + "name": "issue2452-generated-sources-and-source-files-without-glob", "description": "Example of using pre generate commands and sourceFiles without glob.", "sourceFiles": ["ext/fortytwo.d"], "preGenerateCommands-posix": [ diff --git a/test/issue2574-mistyping-commands.sh b/test/issue2574-mistyping-commands.sh deleted file mode 100755 index b239a2a1fb..0000000000 --- a/test/issue2574-mistyping-commands.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -$DUB upfrade 2>&1 >/dev/null && die $LINENO '"dub upfrade" should not succeed' - -if [ "$($DUB upfrade 2>&1 | grep -Fc "Unknown command: upfrade")" != "1" ]; then - die $LINENO 'Missing Unknown command line' -fi - -if [ "$($DUB upfrade 2>&1 | grep -Fc "Did you mean 'upgrade'?")" != "1" ]; then - die $LINENO 'Missing upgrade suggestion' -fi - -if [ "$($DUB upfrade 2>&1 | grep -Fc "build")" != "0" ]; then - die $LINENO 'Did not expect to see build as a suggestion and did not want a full list of commands' -fi diff --git a/test/issue2574-mistyping-commands/dub.json b/test/issue2574-mistyping-commands/dub.json new file mode 100644 index 0000000000..43de296b56 --- /dev/null +++ b/test/issue2574-mistyping-commands/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2574-mistyping-commands", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2574-mistyping-commands/source/app.d b/test/issue2574-mistyping-commands/source/app.d new file mode 100644 index 0000000000..960d1fe33e --- /dev/null +++ b/test/issue2574-mistyping-commands/source/app.d @@ -0,0 +1,21 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + auto p = teeProcess([dub, "upfrade"], Redirect.stdout | Redirect.stderrToStdout); + if (p.wait == 0) + die(`"dub upfrade" should not succeed`); + + if (!p.stdout.canFind("Unknown command: upfrade")) + die("Missing Unknown command line"); + + if (!p.stdout.canFind("Did you mean 'upgrade'?")) + die("Missing upgrade suggestion"); + + if (p.stdout.canFind("build")) + die("Did not expect to see build as a suggestion and did not want a full list of commands"); +} diff --git a/test/issue2587-subpackage-dependency-resolution.sh b/test/issue2587-subpackage-dependency-resolution.sh deleted file mode 100755 index bee14545c3..0000000000 --- a/test/issue2587-subpackage-dependency-resolution.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd "${CURR_DIR}/issue2587-subpackage-dependency-resolution/a" - -rm -f dub.selections.json -$DUB upgrade -v -$DUB run - -rm -f dub.selections.json -$DUB run diff --git a/test/issue2587-subpackage-dependency-resolution/.gitignore b/test/issue2587-subpackage-dependency-resolution/.gitignore new file mode 100644 index 0000000000..efecf2fea6 --- /dev/null +++ b/test/issue2587-subpackage-dependency-resolution/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/b/ +!/sample/c/ +!/sample/*/dub.json +!/sample/*/source/ +!/sample/*/source/*.d diff --git a/test/issue2587-subpackage-dependency-resolution/.no_build b/test/issue2587-subpackage-dependency-resolution/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2587-subpackage-dependency-resolution/.no_run b/test/issue2587-subpackage-dependency-resolution/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2587-subpackage-dependency-resolution/.no_test b/test/issue2587-subpackage-dependency-resolution/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2587-subpackage-dependency-resolution/a/.gitignore b/test/issue2587-subpackage-dependency-resolution/a/.gitignore deleted file mode 100644 index 7b9e404d30..0000000000 --- a/test/issue2587-subpackage-dependency-resolution/a/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -/a -a.so -a.dylib -a.dll -a.a -a.lib -a-test-* -*.exe -*.pdb -*.o -*.obj -*.lst diff --git a/test/issue2587-subpackage-dependency-resolution/b/.gitignore b/test/issue2587-subpackage-dependency-resolution/b/.gitignore deleted file mode 100644 index d699f7ef5a..0000000000 --- a/test/issue2587-subpackage-dependency-resolution/b/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -/b -b.so -b.dylib -b.dll -b.a -b.lib -b-test-* -*.exe -*.pdb -*.o -*.obj -*.lst diff --git a/test/issue2587-subpackage-dependency-resolution/c/.gitignore b/test/issue2587-subpackage-dependency-resolution/c/.gitignore deleted file mode 100644 index 7c7bbbd45b..0000000000 --- a/test/issue2587-subpackage-dependency-resolution/c/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -/c -c.so -c.dylib -c.dll -c.a -c.lib -c-test-* -*.exe -*.pdb -*.o -*.obj -*.lst diff --git a/test/issue2587-subpackage-dependency-resolution/dub.json b/test/issue2587-subpackage-dependency-resolution/dub.json new file mode 100644 index 0000000000..9e877a96e7 --- /dev/null +++ b/test/issue2587-subpackage-dependency-resolution/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2587-subpackage-dependency-resolution", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2587-subpackage-dependency-resolution/a/dub.json b/test/issue2587-subpackage-dependency-resolution/sample/a/dub.json similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/a/dub.json rename to test/issue2587-subpackage-dependency-resolution/sample/a/dub.json diff --git a/test/issue2587-subpackage-dependency-resolution/a/source/app.d b/test/issue2587-subpackage-dependency-resolution/sample/a/source/app.d similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/a/source/app.d rename to test/issue2587-subpackage-dependency-resolution/sample/a/source/app.d diff --git a/test/issue2587-subpackage-dependency-resolution/b/dub.json b/test/issue2587-subpackage-dependency-resolution/sample/b/dub.json similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/b/dub.json rename to test/issue2587-subpackage-dependency-resolution/sample/b/dub.json diff --git a/test/issue2587-subpackage-dependency-resolution/b/source/b.d b/test/issue2587-subpackage-dependency-resolution/sample/b/source/b.d similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/b/source/b.d rename to test/issue2587-subpackage-dependency-resolution/sample/b/source/b.d diff --git a/test/issue2587-subpackage-dependency-resolution/c/dub.json b/test/issue2587-subpackage-dependency-resolution/sample/c/dub.json similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/c/dub.json rename to test/issue2587-subpackage-dependency-resolution/sample/c/dub.json diff --git a/test/issue2587-subpackage-dependency-resolution/c/source/c.d b/test/issue2587-subpackage-dependency-resolution/sample/c/source/c.d similarity index 100% rename from test/issue2587-subpackage-dependency-resolution/c/source/c.d rename to test/issue2587-subpackage-dependency-resolution/sample/c/source/c.d diff --git a/test/issue2587-subpackage-dependency-resolution/source/app.d b/test/issue2587-subpackage-dependency-resolution/source/app.d new file mode 100644 index 0000000000..4ffafa1741 --- /dev/null +++ b/test/issue2587-subpackage-dependency-resolution/source/app.d @@ -0,0 +1,22 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample/a"); + if (exists("dub.selections.json")) remove("dub.selections.json"); + + if (spawnProcess([dub, "upgrade", "-v"]).wait != 0) + die("Dub upgrade failed"); + + if (spawnProcess([dub, "run"]).wait != 0) + die("Dub run after generating dub.selections.json failed"); + + remove("dub.selections.json"); + + if (spawnProcess([dub, "run"]).wait != 0) + die("Dub run without dub.selections.json failed"); +} diff --git a/test/issue2650-deprecated-modules/.no_build b/test/issue2650-deprecated-modules/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2650-deprecated-modules/.no_run b/test/issue2650-deprecated-modules/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2650-deprecated-modules/test.config b/test/issue2650-deprecated-modules/test.config new file mode 100644 index 0000000000..a911f5cd05 --- /dev/null +++ b/test/issue2650-deprecated-modules/test.config @@ -0,0 +1 @@ +dub_command = test \ No newline at end of file diff --git a/test/issue2684-recipe-file.sh b/test/issue2684-recipe-file.sh deleted file mode 100755 index 2567395464..0000000000 --- a/test/issue2684-recipe-file.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd ${CURR_DIR}/issue2684-recipe-file -${DUB} | grep -c "This was built using dub.json" > /dev/null -${DUB} --recipe=dubWithAnotherSource.json | grep -c "This was built using dubWithAnotherSource.json" > /dev/null \ No newline at end of file diff --git a/test/issue2684-recipe-file/.gitignore b/test/issue2684-recipe-file/.gitignore index 3de530e06c..9cdbcf5794 100644 --- a/test/issue2684-recipe-file/.gitignore +++ b/test/issue2684-recipe-file/.gitignore @@ -1,16 +1,8 @@ -.dub -docs.json -__dummy.html -docs/ -/issue2684-recipe-file -issue2684-recipe-file.so -issue2684-recipe-file.dylib -issue2684-recipe-file.dll -issue2684-recipe-file.a -issue2684-recipe-file.lib -issue2684-recipe-file-test-* -*.exe -*.pdb -*.o -*.obj -*.lst +/sample/** +!/sample/ +!/sample/dub.json +!/sample/dubWithAnotherSource.json +!/sample/source/ +!/sample/source/*.d +!/sample/anotherSource/ +!/sample/anotherSource/*.d diff --git a/test/issue2684-recipe-file/dub.json b/test/issue2684-recipe-file/dub.json index 17ac6ce424..20464aeda4 100644 --- a/test/issue2684-recipe-file/dub.json +++ b/test/issue2684-recipe-file/dub.json @@ -1,9 +1,8 @@ { - "authors": [ - "Hipreme" - ], - "copyright": "Copyright © 2023, Hipreme", - "description": "A minimal D application.", - "license": "public domain", - "name": "issue2684-recipe-file" -} \ No newline at end of file + "name": "issue2684-recipe-file", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2684-recipe-file/anotherSource/app.d b/test/issue2684-recipe-file/sample/anotherSource/app.d similarity index 100% rename from test/issue2684-recipe-file/anotherSource/app.d rename to test/issue2684-recipe-file/sample/anotherSource/app.d diff --git a/test/issue2684-recipe-file/sample/dub.json b/test/issue2684-recipe-file/sample/dub.json new file mode 100644 index 0000000000..17ac6ce424 --- /dev/null +++ b/test/issue2684-recipe-file/sample/dub.json @@ -0,0 +1,9 @@ +{ + "authors": [ + "Hipreme" + ], + "copyright": "Copyright © 2023, Hipreme", + "description": "A minimal D application.", + "license": "public domain", + "name": "issue2684-recipe-file" +} \ No newline at end of file diff --git a/test/issue2684-recipe-file/dubWithAnotherSource.json b/test/issue2684-recipe-file/sample/dubWithAnotherSource.json similarity index 100% rename from test/issue2684-recipe-file/dubWithAnotherSource.json rename to test/issue2684-recipe-file/sample/dubWithAnotherSource.json diff --git a/test/issue2684-recipe-file/sample/source/app.d b/test/issue2684-recipe-file/sample/source/app.d new file mode 100644 index 0000000000..022b7ee639 --- /dev/null +++ b/test/issue2684-recipe-file/sample/source/app.d @@ -0,0 +1,10 @@ +module app; +import std.stdio; + +void main() +{ + writeln("This was built using dub.json. +Try using the other configuration by calling dub with: +dub --recipe=dubWithAnotherSource.json +"); +} diff --git a/test/issue2684-recipe-file/source/app.d b/test/issue2684-recipe-file/source/app.d index 022b7ee639..a1a8737c4e 100644 --- a/test/issue2684-recipe-file/source/app.d +++ b/test/issue2684-recipe-file/source/app.d @@ -1,10 +1,23 @@ -module app; +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; import std.stdio; -void main() -{ - writeln("This was built using dub.json. -Try using the other configuration by calling dub with: -dub --recipe=dubWithAnotherSource.json -"); +void main () { + chdir("sample"); + + auto p = teeProcess([dub]); + if (p.wait != 0) + die("Plain dub invocation failed"); + if (!p.stdout.canFind("This was built using dub.json")) + die("The executable was not built with dub.json"); + + p = teeProcess([dub, "--recipe=dubWithAnotherSource.json"]); + if (p.wait != 0) + die("dub with custom recipe faile"); + if (!p.stdout.canFind("This was built using dubWithAnotherSource.json")) + die("The executable was not built with dubWithAnotherSource.json"); } diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/.gitignore b/test/issue2698-cimportpaths-broken-with-dmd-ldc/.gitignore new file mode 100644 index 0000000000..8d82cc87ab --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/.gitignore @@ -0,0 +1 @@ +!/c_headers \ No newline at end of file diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/test.config b/test/issue2698-cimportpaths-broken-with-dmd-ldc/test.config new file mode 100644 index 0000000000..76428d98bf --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/test.config @@ -0,0 +1 @@ +dc_backend = [dmd, ldc] \ No newline at end of file diff --git a/test/issue2840-build-collision.sh b/test/issue2840-build-collision.sh deleted file mode 100755 index 70ad1cb1b9..0000000000 --- a/test/issue2840-build-collision.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -pushd $(dirname "${BASH_SOURCE[0]}")/issue2840-build-collision -# Copy before building, as dub uses timestamp to check for rebuild -rm -rf nested/ && mkdir -p nested/ && cp -v build.d nested/ - -$DUB ./build.d $(pwd)/build.d -pushd nested -$DUB ./build.d $(pwd)/build.d -popd - -popd diff --git a/test/issue2840-build-collision/.gitignore b/test/issue2840-build-collision/.gitignore new file mode 100644 index 0000000000..69070a959e --- /dev/null +++ b/test/issue2840-build-collision/.gitignore @@ -0,0 +1,3 @@ +/sample/** +!/sample/ +!/sample/build.d diff --git a/test/issue2840-build-collision/.no_build b/test/issue2840-build-collision/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue2840-build-collision/dub.json b/test/issue2840-build-collision/dub.json new file mode 100644 index 0000000000..77837025e8 --- /dev/null +++ b/test/issue2840-build-collision/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue2840-build-collision", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue2840-build-collision/build.d b/test/issue2840-build-collision/sample/build.d similarity index 100% rename from test/issue2840-build-collision/build.d rename to test/issue2840-build-collision/sample/build.d diff --git a/test/issue2840-build-collision/source/app.d b/test/issue2840-build-collision/source/app.d new file mode 100644 index 0000000000..180a27e906 --- /dev/null +++ b/test/issue2840-build-collision/source/app.d @@ -0,0 +1,24 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + if (exists("nested")) rmdirRecurse("nested"); + mkdir("nested"); + copy("build.d", "nested/build.d"); + + if (spawnProcess([dub, "build.d", getcwd().buildPath("build.d")]).wait != 0) + die("Dub build from plain directory failed"); + + { + chdir("nested"); + scope(exit) chdir(".."); + + if (spawnProcess([dub, "build.d", getcwd().buildPath("build.d")]).wait != 0) + die("Dub build from nested directory failed"); + } +} diff --git a/test/issue346-redundant-flags.sh b/test/issue346-redundant-flags.sh deleted file mode 100755 index c6b27f2fba..0000000000 --- a/test/issue346-redundant-flags.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue346-redundant-flags -${DUB} build --bare --force --compiler=${DC} -a x86_64 -v main 2>&1 | { ! grep -e '-m64 -m64' -c; } diff --git a/test/issue346-redundant-flags/.gitignore b/test/issue346-redundant-flags/.gitignore new file mode 100644 index 0000000000..d2eeb714d6 --- /dev/null +++ b/test/issue346-redundant-flags/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/b/ +!/sample/main/ +!/sample/*/dub.json +!/sample/*/source/ +!/sample/*/source/*.d diff --git a/test/issue346-redundant-flags/.no_build b/test/issue346-redundant-flags/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue346-redundant-flags/.no_run b/test/issue346-redundant-flags/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue346-redundant-flags/.no_test b/test/issue346-redundant-flags/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue346-redundant-flags/dub.json b/test/issue346-redundant-flags/dub.json new file mode 100644 index 0000000000..a243fc6340 --- /dev/null +++ b/test/issue346-redundant-flags/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue346-redundant-flags", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue346-redundant-flags/a/dub.json b/test/issue346-redundant-flags/sample/a/dub.json similarity index 88% rename from test/issue346-redundant-flags/a/dub.json rename to test/issue346-redundant-flags/sample/a/dub.json index 5b911819d9..16c3d03c3a 100644 --- a/test/issue346-redundant-flags/a/dub.json +++ b/test/issue346-redundant-flags/sample/a/dub.json @@ -1,3 +1,3 @@ { "name": "a" -} \ No newline at end of file +} diff --git a/test/issue346-redundant-flags/a/source/a.d b/test/issue346-redundant-flags/sample/a/source/a.d similarity index 100% rename from test/issue346-redundant-flags/a/source/a.d rename to test/issue346-redundant-flags/sample/a/source/a.d diff --git a/test/issue346-redundant-flags/b/dub.json b/test/issue346-redundant-flags/sample/b/dub.json similarity index 88% rename from test/issue346-redundant-flags/b/dub.json rename to test/issue346-redundant-flags/sample/b/dub.json index 2824d72989..2697a7f0fc 100644 --- a/test/issue346-redundant-flags/b/dub.json +++ b/test/issue346-redundant-flags/sample/b/dub.json @@ -1,3 +1,3 @@ { "name": "b" -} \ No newline at end of file +} diff --git a/test/issue346-redundant-flags/b/source/b.d b/test/issue346-redundant-flags/sample/b/source/b.d similarity index 100% rename from test/issue346-redundant-flags/b/source/b.d rename to test/issue346-redundant-flags/sample/b/source/b.d diff --git a/test/issue346-redundant-flags/main/dub.json b/test/issue346-redundant-flags/sample/main/dub.json similarity index 97% rename from test/issue346-redundant-flags/main/dub.json rename to test/issue346-redundant-flags/sample/main/dub.json index 0160e794aa..8c72d54f37 100644 --- a/test/issue346-redundant-flags/main/dub.json +++ b/test/issue346-redundant-flags/sample/main/dub.json @@ -4,4 +4,4 @@ "a": {"path": "../a"}, "b": {"path": "../b"} } -} \ No newline at end of file +} diff --git a/test/issue346-redundant-flags/main/source/main.d b/test/issue346-redundant-flags/sample/main/source/main.d similarity index 100% rename from test/issue346-redundant-flags/main/source/main.d rename to test/issue346-redundant-flags/sample/main/source/main.d diff --git a/test/issue346-redundant-flags/source/app.d b/test/issue346-redundant-flags/source/app.d new file mode 100644 index 0000000000..cdb4265597 --- /dev/null +++ b/test/issue346-redundant-flags/source/app.d @@ -0,0 +1,19 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + chdir("sample"); + auto p = teeProcess([dub, "build", "--bare", "--force", "-a", "x86_64", "-v", "main"], Redirect.stdout | Redirect.stderrToStdout); + p.wait; + + if (p.stdout.canFind("-m64 -m64")) + die("Arch switch appeared twice"); + + if (p.wait != 0) + die("Dub build failed"); +} diff --git a/test/issue361-optional-deps.sh b/test/issue361-optional-deps.sh deleted file mode 100755 index db87794498..0000000000 --- a/test/issue361-optional-deps.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue361-optional-deps -rm -rf a/.dub -rm -rf a/b/.dub -rm -rf main1/.dub -rm -rf main2/.dub -rm -f main1/dub.selections.json - -${DUB} build --bare --compiler=${DC} main1 -echo "{" > cmp.tmp -echo " \"fileVersion\": 1," >> cmp.tmp -echo " \"versions\": {" >> cmp.tmp -echo " \"b\": \"~master\"" >> cmp.tmp -echo " }" >> cmp.tmp -echo "}" >> cmp.tmp -diff cmp.tmp main1/dub.selections.json - -${DUB} build --bare --compiler=${DC} main2 -echo "{" > cmp.tmp -echo " \"fileVersion\": 1," >> cmp.tmp -echo " \"versions\": {" >> cmp.tmp -echo " \"a\": \"~master\"" >> cmp.tmp -echo " }" >> cmp.tmp -echo "}" >> cmp.tmp -diff cmp.tmp main2/dub.selections.json diff --git a/test/issue361-optional-deps/.gitignore b/test/issue361-optional-deps/.gitignore new file mode 100644 index 0000000000..b9c0de52e5 --- /dev/null +++ b/test/issue361-optional-deps/.gitignore @@ -0,0 +1,12 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/b/ +!/sample/main1/ +!/sample/main2/ + +!/sample/*/dub.sdl +!/sample/*/src/ +!/sample/*/src/*.d + +!/sample/main2/dub.selections.json diff --git a/test/issue361-optional-deps/.no_build b/test/issue361-optional-deps/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue361-optional-deps/a/src/a.d b/test/issue361-optional-deps/a/src/a.d deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue361-optional-deps/b/src/b.d b/test/issue361-optional-deps/b/src/b.d deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue361-optional-deps/dub.json b/test/issue361-optional-deps/dub.json new file mode 100644 index 0000000000..93d1e3750d --- /dev/null +++ b/test/issue361-optional-deps/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue361-optional-deps", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue361-optional-deps/main1/src/main1.d b/test/issue361-optional-deps/main1/src/main1.d deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue361-optional-deps/main2/src/main2.d b/test/issue361-optional-deps/main2/src/main2.d deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue361-optional-deps/a/dub.sdl b/test/issue361-optional-deps/sample/a/dub.sdl similarity index 100% rename from test/issue361-optional-deps/a/dub.sdl rename to test/issue361-optional-deps/sample/a/dub.sdl diff --git a/test/1-staticLib-simple/.no_run b/test/issue361-optional-deps/sample/a/src/a.d similarity index 100% rename from test/1-staticLib-simple/.no_run rename to test/issue361-optional-deps/sample/a/src/a.d diff --git a/test/issue361-optional-deps/b/dub.sdl b/test/issue361-optional-deps/sample/b/dub.sdl similarity index 100% rename from test/issue361-optional-deps/b/dub.sdl rename to test/issue361-optional-deps/sample/b/dub.sdl diff --git a/test/2-dynLib-with-staticLib-dep/.no_build_gdc b/test/issue361-optional-deps/sample/b/src/b.d similarity index 100% rename from test/2-dynLib-with-staticLib-dep/.no_build_gdc rename to test/issue361-optional-deps/sample/b/src/b.d diff --git a/test/issue361-optional-deps/main1/dub.sdl b/test/issue361-optional-deps/sample/main1/dub.sdl similarity index 100% rename from test/issue361-optional-deps/main1/dub.sdl rename to test/issue361-optional-deps/sample/main1/dub.sdl diff --git a/test/2-dynLib-with-staticLib-dep/.no_run b/test/issue361-optional-deps/sample/main1/src/main1.d similarity index 100% rename from test/2-dynLib-with-staticLib-dep/.no_run rename to test/issue361-optional-deps/sample/main1/src/main1.d diff --git a/test/issue361-optional-deps/main2/dub.sdl b/test/issue361-optional-deps/sample/main2/dub.sdl similarity index 100% rename from test/issue361-optional-deps/main2/dub.sdl rename to test/issue361-optional-deps/sample/main2/dub.sdl diff --git a/test/issue361-optional-deps/main2/dub.selections.json b/test/issue361-optional-deps/sample/main2/dub.selections.json similarity index 100% rename from test/issue361-optional-deps/main2/dub.selections.json rename to test/issue361-optional-deps/sample/main2/dub.selections.json diff --git a/test/3-copyFiles/.no_test b/test/issue361-optional-deps/sample/main2/src/main2.d similarity index 100% rename from test/3-copyFiles/.no_test rename to test/issue361-optional-deps/sample/main2/src/main2.d diff --git a/test/issue361-optional-deps/source/app.d b/test/issue361-optional-deps/source/app.d new file mode 100644 index 0000000000..02d251cbdf --- /dev/null +++ b/test/issue361-optional-deps/source/app.d @@ -0,0 +1,52 @@ +import common; + +import std.algorithm; +import std.conv; +import std.file; +import std.path; +import std.process; +import std.range; +import std.stdio : File; +import std.string; + +void main () { + chdir("sample"); + + foreach (dir; ["a/.dub", "a/b/.dub", "main1/.dub", "main2/.dub"]) + if (exists(dir)) rmdirRecurse(dir); + if (exists("main1/dub.selections.json")) + remove("main1/dub.selections.json"); + + if (spawnProcess([dub, "build", "--bare", "main1"]).wait != 0) + die("dub build main1 failed"); + immutable exp1 = [ + `{`, + "\t\"fileVersion\": 1,", + "\t\"versions\": {", + "\t\t\"b\": \"~master\"", + "\t}", + "}", + ]; + foreach (got, exp; lockstep(File("main1/dub.selections.json").byLine, exp1)) { + got = got.chomp; + if (got != exp) + die("main1 test: got ", text([got]), " but expected ", text([exp])); + } + + + if (spawnProcess([dub, "build", "--bare", "main2"]).wait != 0) + die("dub build main2 failed"); + immutable exp2 = [ + `{`, + "\t\"fileVersion\": 1,", + "\t\"versions\": {", + "\t\t\"a\": \"~master\"", + "\t}", + "}", + ]; + foreach (got, exp; lockstep(File("main2/dub.selections.json").byLine, exp2)) { + got = got.chomp; + if (got != exp) + die("main2 test: got ", text([got]), " but expected ", text([exp])); + } +} diff --git a/test/issue502-root-import/source/app.d b/test/issue502-root-import/source/app.d index 9241919256..d4f19a6a4a 100644 --- a/test/issue502-root-import/source/app.d +++ b/test/issue502-root-import/source/app.d @@ -1,10 +1,6 @@ import gitcompatibledubpackage.subdir.file; void main(string[] args) -{ -} - -unittest { assert(!hasTheWorldExploded()); -} \ No newline at end of file +} diff --git a/test/issue564-invalid-upgrade-dependency.sh b/test/issue564-invalid-upgrade-dependency.sh deleted file mode 100755 index 19258cec2c..0000000000 --- a/test/issue564-invalid-upgrade-dependency.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue564-invalid-upgrade-dependency -rm -rf a-1.0.0/.dub -rm -rf a-1.1.0/.dub -rm -rf main/.dub -${DUB} build --bare --compiler=${DC} main diff --git a/test/issue564-invalid-upgrade-dependency/.gitignore b/test/issue564-invalid-upgrade-dependency/.gitignore new file mode 100644 index 0000000000..3ca9d49a5d --- /dev/null +++ b/test/issue564-invalid-upgrade-dependency/.gitignore @@ -0,0 +1,12 @@ +/sample/** +!/sample/ + +!/sample/a-1.0.0/ +!/sample/a-1.1.0/ +!/sample/main/ + +!/sample/*/dub.json +!/sample/*/source/ +!/sample/*/source/*.d + +!/sample/main/dub.selections.json diff --git a/test/issue564-invalid-upgrade-dependency/.no_build b/test/issue564-invalid-upgrade-dependency/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue564-invalid-upgrade-dependency/.no_run b/test/issue564-invalid-upgrade-dependency/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue564-invalid-upgrade-dependency/.no_test b/test/issue564-invalid-upgrade-dependency/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue564-invalid-upgrade-dependency/a-1.0.0/dub.json b/test/issue564-invalid-upgrade-dependency/a-1.0.0/dub.json deleted file mode 100644 index cc36ecba79..0000000000 --- a/test/issue564-invalid-upgrade-dependency/a-1.0.0/dub.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "a", - "version": "1.0.0", -} diff --git a/test/issue564-invalid-upgrade-dependency/dub.json b/test/issue564-invalid-upgrade-dependency/dub.json new file mode 100644 index 0000000000..f473ed411e --- /dev/null +++ b/test/issue564-invalid-upgrade-dependency/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue564-invalid-upgrade-dependency", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue564-invalid-upgrade-dependency/sample/a-1.0.0/dub.json b/test/issue564-invalid-upgrade-dependency/sample/a-1.0.0/dub.json new file mode 100644 index 0000000000..95ccbc3f9e --- /dev/null +++ b/test/issue564-invalid-upgrade-dependency/sample/a-1.0.0/dub.json @@ -0,0 +1,4 @@ +{ + "name": "a", + "version": "1.0.0" +} diff --git a/test/issue564-invalid-upgrade-dependency/a-1.0.0/source/a.d b/test/issue564-invalid-upgrade-dependency/sample/a-1.0.0/source/a.d similarity index 100% rename from test/issue564-invalid-upgrade-dependency/a-1.0.0/source/a.d rename to test/issue564-invalid-upgrade-dependency/sample/a-1.0.0/source/a.d diff --git a/test/issue564-invalid-upgrade-dependency/a-1.1.0/dub.json b/test/issue564-invalid-upgrade-dependency/sample/a-1.1.0/dub.json similarity index 100% rename from test/issue564-invalid-upgrade-dependency/a-1.1.0/dub.json rename to test/issue564-invalid-upgrade-dependency/sample/a-1.1.0/dub.json diff --git a/test/issue564-invalid-upgrade-dependency/a-1.1.0/source/a.d b/test/issue564-invalid-upgrade-dependency/sample/a-1.1.0/source/a.d similarity index 100% rename from test/issue564-invalid-upgrade-dependency/a-1.1.0/source/a.d rename to test/issue564-invalid-upgrade-dependency/sample/a-1.1.0/source/a.d diff --git a/test/issue564-invalid-upgrade-dependency/main/dub.json b/test/issue564-invalid-upgrade-dependency/sample/main/dub.json similarity index 100% rename from test/issue564-invalid-upgrade-dependency/main/dub.json rename to test/issue564-invalid-upgrade-dependency/sample/main/dub.json diff --git a/test/issue564-invalid-upgrade-dependency/main/dub.selections.json b/test/issue564-invalid-upgrade-dependency/sample/main/dub.selections.json similarity index 100% rename from test/issue564-invalid-upgrade-dependency/main/dub.selections.json rename to test/issue564-invalid-upgrade-dependency/sample/main/dub.selections.json diff --git a/test/issue564-invalid-upgrade-dependency/main/source/app.d b/test/issue564-invalid-upgrade-dependency/sample/main/source/app.d similarity index 100% rename from test/issue564-invalid-upgrade-dependency/main/source/app.d rename to test/issue564-invalid-upgrade-dependency/sample/main/source/app.d diff --git a/test/issue564-invalid-upgrade-dependency/source/app.d b/test/issue564-invalid-upgrade-dependency/source/app.d new file mode 100644 index 0000000000..c86d1a1599 --- /dev/null +++ b/test/issue564-invalid-upgrade-dependency/source/app.d @@ -0,0 +1,19 @@ +import common; + +import std.algorithm; +import std.conv; +import std.file; +import std.path; +import std.process; +import std.range; +import std.stdio; + +void main () { + chdir("sample"); + + foreach (dir; ["a-1.0.0/.dub", "a-1.1.0/.dub", "main/.dub"]) + if (exists(dir)) rmdirRecurse(dir); + + if (spawnProcess([dub, "build", "--bare", "main"]).wait != 0) + die("dub build failed"); +} diff --git a/test/issue586-subpack-dep.sh b/test/issue586-subpack-dep.sh deleted file mode 100755 index 306bca74b8..0000000000 --- a/test/issue586-subpack-dep.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue586-subpack-dep -rm -rf a/.dub -rm -rf a/b/.dub -rm -rf main/.dub -${DUB} build --bare --compiler=${DC} main -${DUB} run --bare --compiler=${DC} main diff --git a/test/issue586-subpack-dep/.gitignore b/test/issue586-subpack-dep/.gitignore new file mode 100644 index 0000000000..00bbbb7672 --- /dev/null +++ b/test/issue586-subpack-dep/.gitignore @@ -0,0 +1,10 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/a/ +!/sample/main/ +!/sample/a/b/ +!/sample/**/source/ +!/sample/**/source/**.d +!/sample/**/dub.sdl +!/sample/main/dub.selections.json diff --git a/test/issue586-subpack-dep/.no_build b/test/issue586-subpack-dep/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue586-subpack-dep/.no_run b/test/issue586-subpack-dep/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue586-subpack-dep/.no_test b/test/issue586-subpack-dep/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue586-subpack-dep/dub.json b/test/issue586-subpack-dep/dub.json new file mode 100644 index 0000000000..466a172199 --- /dev/null +++ b/test/issue586-subpack-dep/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue586-subpack-dep", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue586-subpack-dep/a/b/dub.sdl b/test/issue586-subpack-dep/sample/a/b/dub.sdl similarity index 100% rename from test/issue586-subpack-dep/a/b/dub.sdl rename to test/issue586-subpack-dep/sample/a/b/dub.sdl diff --git a/test/issue586-subpack-dep/a/b/source/b.d b/test/issue586-subpack-dep/sample/a/b/source/b.d similarity index 100% rename from test/issue586-subpack-dep/a/b/source/b.d rename to test/issue586-subpack-dep/sample/a/b/source/b.d diff --git a/test/issue586-subpack-dep/a/dub.sdl b/test/issue586-subpack-dep/sample/a/dub.sdl similarity index 100% rename from test/issue586-subpack-dep/a/dub.sdl rename to test/issue586-subpack-dep/sample/a/dub.sdl diff --git a/test/issue586-subpack-dep/a/source/a.d b/test/issue586-subpack-dep/sample/a/source/a.d similarity index 100% rename from test/issue586-subpack-dep/a/source/a.d rename to test/issue586-subpack-dep/sample/a/source/a.d diff --git a/test/issue586-subpack-dep/main/dub.sdl b/test/issue586-subpack-dep/sample/main/dub.sdl similarity index 100% rename from test/issue586-subpack-dep/main/dub.sdl rename to test/issue586-subpack-dep/sample/main/dub.sdl diff --git a/test/issue586-subpack-dep/main/dub.selections.json b/test/issue586-subpack-dep/sample/main/dub.selections.json similarity index 100% rename from test/issue586-subpack-dep/main/dub.selections.json rename to test/issue586-subpack-dep/sample/main/dub.selections.json diff --git a/test/issue586-subpack-dep/main/source/c.d b/test/issue586-subpack-dep/sample/main/source/c.d similarity index 100% rename from test/issue586-subpack-dep/main/source/c.d rename to test/issue586-subpack-dep/sample/main/source/c.d diff --git a/test/issue586-subpack-dep/source/app.d b/test/issue586-subpack-dep/source/app.d new file mode 100644 index 0000000000..f51e79da83 --- /dev/null +++ b/test/issue586-subpack-dep/source/app.d @@ -0,0 +1,19 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + foreach (dir; ["a/.dub", "a/b/.dub", "main/.dub"]) + if (exists(dir)) rmdirRecurse(dir); + + if (spawnProcess([dub, "build", "--bare", "main"]).wait != 0) + die("dub build failed"); + + if (spawnProcess([dub, "run", "--bare", "main"]).wait != 0) + die("dub run failed"); +} diff --git a/test/issue613-dynlib-pic.sh b/test/issue613-dynlib-pic.sh deleted file mode 100755 index b8fc5e702b..0000000000 --- a/test/issue613-dynlib-pic.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue613-dynlib-pic -rm -rf .dub -if [ "${DC}" = "dmd" ]; then - ${DUB} build --compiler=${DC} -else - echo "Skipping shared library test for ${DC}..." -fi diff --git a/test/issue613-dynlib-pic/.gitignore b/test/issue613-dynlib-pic/.gitignore deleted file mode 100644 index 433d26664a..0000000000 --- a/test/issue613-dynlib-pic/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.dub -docs.json -__dummy.html -*.o -*.obj diff --git a/test/issue613-dynlib-pic/.no_build b/test/issue613-dynlib-pic/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue613-dynlib-pic/.no_run b/test/issue613-dynlib-pic/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue613-dynlib-pic/.no_test b/test/issue613-dynlib-pic/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue613-dynlib-pic/source/app.d b/test/issue613-dynlib-pic/source/app.d index 8b92d48301..a4e9299d6b 100644 --- a/test/issue613-dynlib-pic/source/app.d +++ b/test/issue613-dynlib-pic/source/app.d @@ -1,4 +1,8 @@ +version (Windows) version (DigitalMars) { + import core.sys.windows.dll; + mixin SimpleDllMain; +} void test() { -} \ No newline at end of file +} diff --git a/test/issue613-dynlib-pic/test.config b/test/issue613-dynlib-pic/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/issue613-dynlib-pic/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/issue616-describe-vs-generate-commands.sh b/test/issue616-describe-vs-generate-commands.sh deleted file mode 100755 index c8127e53ce..0000000000 --- a/test/issue616-describe-vs-generate-commands.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd "$CURR_DIR"/issue616-describe-vs-generate-commands - -temp_file=$(mktemp $(basename $0).XXXXXX) - -function cleanup { - rm $temp_file -} - -trap cleanup EXIT - -if ! $DUB describe --compiler=$DC --data-list --data=target-name \ - > "$temp_file" 2>&1; then - die $LINENO 'Printing project data failed!' -fi - -# Create the expected output file to compare stdout against. -expected_file="$CURR_DIR/expected-issue616-output" -echo "preGenerateCommands: DUB_PACKAGES_USED=issue616-describe-vs-generate-commands,issue616-subpack,issue616-subsubpack" > "$expected_file" -echo "$CURR_DIR/issue616-describe-vs-generate-commands/src/" >> "$expected_file" -echo "$CURR_DIR/issue616-subpack/src/" >> "$expected_file" -echo "$CURR_DIR/issue616-subsubpack/src/" >> "$expected_file" -echo "issue616-describe-vs-generate-commands" >> "$expected_file" - -if ! diff "$expected_file" "$temp_file"; then - die $LINENO 'The stdout output did not match the expected output!' -fi diff --git a/test/issue616-describe-vs-generate-commands/.gitignore b/test/issue616-describe-vs-generate-commands/.gitignore new file mode 100644 index 0000000000..9102d96358 --- /dev/null +++ b/test/issue616-describe-vs-generate-commands/.gitignore @@ -0,0 +1,9 @@ +/sample/** +!/sample/ +!/sample/issue616-describe-vs-generate-commands/ +!/sample/issue616-subpack/ +!/sample/issue616-subsubpack/ +!/sample/*/dub.json +!/sample/*/*.sh +!/sample/*/src/ +!/sample/*/src/**.d diff --git a/test/issue616-describe-vs-generate-commands/.no_build b/test/issue616-describe-vs-generate-commands/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue616-describe-vs-generate-commands/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue616-describe-vs-generate-commands/dub.json b/test/issue616-describe-vs-generate-commands/dub.json index 8aec1eda06..db18220d62 100644 --- a/test/issue616-describe-vs-generate-commands/dub.json +++ b/test/issue616-describe-vs-generate-commands/dub.json @@ -1,11 +1,8 @@ { - "name": "issue616-describe-vs-generate-commands", - "targetType": "executable", - "preGenerateCommands-posix": ["cd $PACKAGE_DIR && ./do-preGenerateCommands.sh"], - "dependencies": { - "issue616-subpack": { - "version": "1.0", - "path": "../issue616-subpack" - } - } + "name": "issue616-describe-vs-generate-commands", + "dependencies": { + "common": { + "path": "../common" + } + } } diff --git a/test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh b/test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh similarity index 100% rename from test/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh rename to test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/do-preGenerateCommands.sh diff --git a/test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/dub.json b/test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/dub.json new file mode 100644 index 0000000000..8aec1eda06 --- /dev/null +++ b/test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/dub.json @@ -0,0 +1,11 @@ +{ + "name": "issue616-describe-vs-generate-commands", + "targetType": "executable", + "preGenerateCommands-posix": ["cd $PACKAGE_DIR && ./do-preGenerateCommands.sh"], + "dependencies": { + "issue616-subpack": { + "version": "1.0", + "path": "../issue616-subpack" + } + } +} diff --git a/test/issue616-describe-vs-generate-commands/src/dummy.d b/test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/src/dummy.d similarity index 100% rename from test/issue616-describe-vs-generate-commands/src/dummy.d rename to test/issue616-describe-vs-generate-commands/sample/issue616-describe-vs-generate-commands/src/dummy.d diff --git a/test/issue616-subpack/dub.json b/test/issue616-describe-vs-generate-commands/sample/issue616-subpack/dub.json similarity index 100% rename from test/issue616-subpack/dub.json rename to test/issue616-describe-vs-generate-commands/sample/issue616-subpack/dub.json diff --git a/test/issue616-subpack/src/dummy.d b/test/issue616-describe-vs-generate-commands/sample/issue616-subpack/src/dummy.d similarity index 100% rename from test/issue616-subpack/src/dummy.d rename to test/issue616-describe-vs-generate-commands/sample/issue616-subpack/src/dummy.d diff --git a/test/issue616-subsubpack/dub.json b/test/issue616-describe-vs-generate-commands/sample/issue616-subsubpack/dub.json similarity index 100% rename from test/issue616-subsubpack/dub.json rename to test/issue616-describe-vs-generate-commands/sample/issue616-subsubpack/dub.json diff --git a/test/issue616-subsubpack/src/dummy.d b/test/issue616-describe-vs-generate-commands/sample/issue616-subsubpack/src/dummy.d similarity index 100% rename from test/issue616-subsubpack/src/dummy.d rename to test/issue616-describe-vs-generate-commands/sample/issue616-subsubpack/src/dummy.d diff --git a/test/issue616-describe-vs-generate-commands/source/app.d b/test/issue616-describe-vs-generate-commands/source/app.d new file mode 100644 index 0000000000..dde221a091 --- /dev/null +++ b/test/issue616-describe-vs-generate-commands/source/app.d @@ -0,0 +1,47 @@ +import common; + +import std.algorithm; +import std.conv; +import std.file; +import std.path; +import std.process; +import std.range; +import std.string; + +void main () { + immutable baseDir = getcwd.buildPath("sample"); + chdir("sample/issue616-describe-vs-generate-commands"); + + auto p = teeProcess([dub, "describe", "--data-list", "--data=target-name"], + Redirect.stdout | Redirect.stderrToStdout); + if (p.wait != 0) + die("dub describe failed"); + const got = p.stdout.splitLines; + + string[] expected; + version(Posix) + expected ~= [ + `preGenerateCommands: DUB_PACKAGES_USED=issue616-describe-vs-generate-commands,issue616-subpack,issue616-subsubpack`, + baseDir.myBuildPath("issue616-describe-vs-generate-commands", "src", ""), + baseDir.myBuildPath("issue616-subpack", "src", ""), + baseDir.myBuildPath("issue616-subsubpack", "src", ""), + ]; + + expected ~= [ `issue616-describe-vs-generate-commands` ]; + + if (equal(got, expected)) return; + + foreach (g, e; lockstep(got, expected)) { + if (g == e) continue; + + log("Expected: ", text([e]), " but got ", text([g])); + } + die("dub describe output differs"); +} + +string myBuildPath(const(char)[][] segments...) { + immutable result = buildPath(segments); + if (segments[$ - 1] == "") + return result ~ dirSeparator; + return result; +} diff --git a/test/issue616-subpack/.no_build b/test/issue616-subpack/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue616-subpack/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue616-subsubpack/.no_build b/test/issue616-subsubpack/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue616-subsubpack/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue672-upgrade-optional.sh b/test/issue672-upgrade-optional.sh deleted file mode 100755 index a8f841c469..0000000000 --- a/test/issue672-upgrade-optional.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue672-upgrade-optional -rm -rf b/.dub -echo "{\"fileVersion\": 1,\"versions\": {\"dub\": \"1.5.0\"}}" > dub.selections.json -${DUB} upgrade - -if ! grep -c -e "\"dub\": \"1.6.0\"" dub.selections.json; then - die $LINENO 'Dependency not upgraded.' -fi diff --git a/test/issue672-upgrade-optional/.gitignore b/test/issue672-upgrade-optional/.gitignore new file mode 100644 index 0000000000..3ac140bc44 --- /dev/null +++ b/test/issue672-upgrade-optional/.gitignore @@ -0,0 +1,3 @@ +/sample/** +!/sample/ +!/sample/dub.sdl \ No newline at end of file diff --git a/test/issue672-upgrade-optional/.no_build b/test/issue672-upgrade-optional/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue672-upgrade-optional/dub.json b/test/issue672-upgrade-optional/dub.json new file mode 100644 index 0000000000..796750c274 --- /dev/null +++ b/test/issue672-upgrade-optional/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue672-upgrade-optional", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue672-upgrade-optional/dub.sdl b/test/issue672-upgrade-optional/dub.sdl deleted file mode 100644 index 28d82b17e0..0000000000 --- a/test/issue672-upgrade-optional/dub.sdl +++ /dev/null @@ -1,2 +0,0 @@ -name "b" -dependency "dub" version=">=1.5.0 <=1.6.0" optional=true diff --git a/test/issue672-upgrade-optional/dub.selections.json b/test/issue672-upgrade-optional/dub.selections.json deleted file mode 100644 index 099010013c..0000000000 --- a/test/issue672-upgrade-optional/dub.selections.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "fileVersion": 1, - "versions": { - "dub": "1.5.0" - } -} diff --git a/test/issue672-upgrade-optional/sample/dub.sdl b/test/issue672-upgrade-optional/sample/dub.sdl new file mode 100644 index 0000000000..d132f26f37 --- /dev/null +++ b/test/issue672-upgrade-optional/sample/dub.sdl @@ -0,0 +1,2 @@ +name "b" +dependency "dub" version=">=1.5.0 <=1.6.0" optional=true \ No newline at end of file diff --git a/test/issue672-upgrade-optional/source/app.d b/test/issue672-upgrade-optional/source/app.d new file mode 100644 index 0000000000..3e866c027b --- /dev/null +++ b/test/issue672-upgrade-optional/source/app.d @@ -0,0 +1,23 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + write("dub.selections.json", `{ + "fileVersion": 1, + "versions": { + "dub": "1.5.0", + } +} +`); + + if (spawnProcess([dub, "upgrade"]).wait != 0) + die("dub upgrade failed"); + + if (!readText("dub.selections.json").canFind(`"dub": "1.6.0"`)) + die("Dependency not upgraded"); +} diff --git a/test/issue674-concurrent-dub.sh b/test/issue674-concurrent-dub.sh deleted file mode 100755 index 8f59ab73a6..0000000000 --- a/test/issue674-concurrent-dub.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -TMPDIR=$(mktemp -d $(basename $0).XXXXXX) - -function cleanup { - rm -rf ${TMPDIR} -} -trap cleanup EXIT - -cd ${TMPDIR} && $DUB fetch --cache=local bloom & -pid1=$! -sleep 0.5 -cd ${TMPDIR} && $DUB fetch --cache=local bloom & -pid2=$! -wait $pid1 -wait $pid2 -[ -d ${TMPDIR}/.dub/packages/bloom* ] \ No newline at end of file diff --git a/test/issue674-concurrent-dub/dub.json b/test/issue674-concurrent-dub/dub.json new file mode 100644 index 0000000000..1b4b9968ad --- /dev/null +++ b/test/issue674-concurrent-dub/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue674-concurrent-dub", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue674-concurrent-dub/source/app.d b/test/issue674-concurrent-dub/source/app.d new file mode 100644 index 0000000000..91c3b56edf --- /dev/null +++ b/test/issue674-concurrent-dub/source/app.d @@ -0,0 +1,28 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import core.thread.osthread; +import core.time; + + +void main () { + immutable dub = environment["DUB"]; + + if (exists("test")) rmdirRecurse("test"); + mkdir("test"); + chdir("test"); + + immutable cmd = [dub, "fetch", "--cache=local", "bloom"]; + auto p1 = spawnProcess(cmd); + Thread.sleep(500.msecs); + auto p2 = spawnProcess(cmd); + + wait(p1); + wait(p2); + + if (!exists(".dub/packages/bloom")) + die("test/.dub/packages/bloom has not been created"); +} diff --git a/test/issue686-multiple-march.sh b/test/issue686-multiple-march.sh deleted file mode 100755 index 24b84b74a0..0000000000 --- a/test/issue686-multiple-march.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue686-multiple-march -${DUB} build --bare --force --compiler=${DC} -a x86_64 -v main 2>&1 | { ! grep -e '-m64 -m64' -c; } diff --git a/test/issue686-multiple-march/.gitignore b/test/issue686-multiple-march/.gitignore new file mode 100644 index 0000000000..f9686eb9e4 --- /dev/null +++ b/test/issue686-multiple-march/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a +!/sample/b +!/sample/main +!/sample/*/dub.json +!/sample/*/source/ +!/sample/*/source/**.d \ No newline at end of file diff --git a/test/issue686-multiple-march/.no_build b/test/issue686-multiple-march/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue686-multiple-march/.no_run b/test/issue686-multiple-march/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue686-multiple-march/.no_test b/test/issue686-multiple-march/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue686-multiple-march/dub.json b/test/issue686-multiple-march/dub.json new file mode 100644 index 0000000000..0e7939934d --- /dev/null +++ b/test/issue686-multiple-march/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue686-multiple-march", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue686-multiple-march/a/dub.json b/test/issue686-multiple-march/sample/a/dub.json similarity index 96% rename from test/issue686-multiple-march/a/dub.json rename to test/issue686-multiple-march/sample/a/dub.json index 341d1269bf..f277a21632 100644 --- a/test/issue686-multiple-march/a/dub.json +++ b/test/issue686-multiple-march/sample/a/dub.json @@ -3,4 +3,4 @@ "dependencies": { "b": {"path": "../b"} } -} \ No newline at end of file +} diff --git a/test/issue686-multiple-march/a/source/a.d b/test/issue686-multiple-march/sample/a/source/a.d similarity index 100% rename from test/issue686-multiple-march/a/source/a.d rename to test/issue686-multiple-march/sample/a/source/a.d diff --git a/test/issue686-multiple-march/b/dub.json b/test/issue686-multiple-march/sample/b/dub.json similarity index 88% rename from test/issue686-multiple-march/b/dub.json rename to test/issue686-multiple-march/sample/b/dub.json index 2824d72989..2697a7f0fc 100644 --- a/test/issue686-multiple-march/b/dub.json +++ b/test/issue686-multiple-march/sample/b/dub.json @@ -1,3 +1,3 @@ { "name": "b" -} \ No newline at end of file +} diff --git a/test/issue686-multiple-march/b/source/b.d b/test/issue686-multiple-march/sample/b/source/b.d similarity index 100% rename from test/issue686-multiple-march/b/source/b.d rename to test/issue686-multiple-march/sample/b/source/b.d diff --git a/test/issue686-multiple-march/main/dub.json b/test/issue686-multiple-march/sample/main/dub.json similarity index 97% rename from test/issue686-multiple-march/main/dub.json rename to test/issue686-multiple-march/sample/main/dub.json index 0160e794aa..8c72d54f37 100644 --- a/test/issue686-multiple-march/main/dub.json +++ b/test/issue686-multiple-march/sample/main/dub.json @@ -4,4 +4,4 @@ "a": {"path": "../a"}, "b": {"path": "../b"} } -} \ No newline at end of file +} diff --git a/test/issue686-multiple-march/main/source/main.d b/test/issue686-multiple-march/sample/main/source/main.d similarity index 100% rename from test/issue686-multiple-march/main/source/main.d rename to test/issue686-multiple-march/sample/main/source/main.d diff --git a/test/issue686-multiple-march/source/app.d b/test/issue686-multiple-march/source/app.d new file mode 100644 index 0000000000..22f50cbf32 --- /dev/null +++ b/test/issue686-multiple-march/source/app.d @@ -0,0 +1,21 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + auto p = teeProcess( + [dub, "build", "--bare", "--force", "-a", "x86_64", "-v", "main"], + Redirect.stdout | Redirect.stderrToStdout, + null, + Config.none, + "sample", + ); + if (p.wait != 0) + die("dub build failed"); + if (p.stdout.canFind("-m64 -m64")) + die("-m64 appeared twice in output"); +} diff --git a/test/issue754-path-selection-fail/.gitignore b/test/issue754-path-selection-fail/.gitignore new file mode 100644 index 0000000000..9a42dce86e --- /dev/null +++ b/test/issue754-path-selection-fail/.gitignore @@ -0,0 +1,5 @@ +!/dub.selections.json +!/a-*/ +!/a-*/dub.sdl +!/a-*/source/ +!/a-*/source/**.d \ No newline at end of file diff --git a/test/issue754-path-selection-fail/a-1.0/dub.sdl b/test/issue754-path-selection-fail/a-1.0/dub.sdl index 7ff9fa17ef..aaa02a9850 100644 --- a/test/issue754-path-selection-fail/a-1.0/dub.sdl +++ b/test/issue754-path-selection-fail/a-1.0/dub.sdl @@ -1,2 +1,2 @@ -name "a" +name "issue754-a" version "1.0.0" diff --git a/test/issue754-path-selection-fail/a-2.0/dub.sdl b/test/issue754-path-selection-fail/a-2.0/dub.sdl index 1cb3694109..d975a3379f 100644 --- a/test/issue754-path-selection-fail/a-2.0/dub.sdl +++ b/test/issue754-path-selection-fail/a-2.0/dub.sdl @@ -1,3 +1,3 @@ -name "a" +name "issue754-a" version "2.0.0" diff --git a/test/issue754-path-selection-fail/dub.sdl b/test/issue754-path-selection-fail/dub.sdl index b36515c259..5a67b99b2d 100644 --- a/test/issue754-path-selection-fail/dub.sdl +++ b/test/issue754-path-selection-fail/dub.sdl @@ -1,2 +1,2 @@ -name "test" -dependency "a" path="a-2.0" +name "issue754-test" +dependency "issue754-a" path="a-2.0" diff --git a/test/issue754-path-selection-fail/dub.selections.json b/test/issue754-path-selection-fail/dub.selections.json index 61e9539512..234f1cb42e 100644 --- a/test/issue754-path-selection-fail/dub.selections.json +++ b/test/issue754-path-selection-fail/dub.selections.json @@ -1,6 +1,6 @@ { "fileVersion": 1, "versions": { - "a": {"path": "a-1.0"} + "issue754-a": {"path": "a-1.0"} } } diff --git a/test/issue777-bogus-path-dependency/.gitignore b/test/issue777-bogus-path-dependency/.gitignore new file mode 100644 index 0000000000..ffae721d5f --- /dev/null +++ b/test/issue777-bogus-path-dependency/.gitignore @@ -0,0 +1,7 @@ +!/dub.selections.json +!/b/ +!/c/ +!/c-err/ +!/*/dub.sdl +!/*/source/ +!/*/source/**.d \ No newline at end of file diff --git a/test/issue777-bogus-path-dependency/b/dub.sdl b/test/issue777-bogus-path-dependency/b/dub.sdl index 7aff103f3d..89b9d49ccf 100644 --- a/test/issue777-bogus-path-dependency/b/dub.sdl +++ b/test/issue777-bogus-path-dependency/b/dub.sdl @@ -1,10 +1,10 @@ -name "b" +name "issue777-b" targetType "none" configuration "a" { - dependency "c" version="*" + dependency "issue777-c" version="*" } configuration "b" { - dependency "c" path="../c-err" + dependency "issue777-c" path="../c-err" } diff --git a/test/issue777-bogus-path-dependency/c-err/dub.sdl b/test/issue777-bogus-path-dependency/c-err/dub.sdl index 1ed791a15b..23bdb34d45 100644 --- a/test/issue777-bogus-path-dependency/c-err/dub.sdl +++ b/test/issue777-bogus-path-dependency/c-err/dub.sdl @@ -1 +1 @@ -name "c" +name "issue777-c" diff --git a/test/issue777-bogus-path-dependency/c/dub.sdl b/test/issue777-bogus-path-dependency/c/dub.sdl index 1ed791a15b..23bdb34d45 100644 --- a/test/issue777-bogus-path-dependency/c/dub.sdl +++ b/test/issue777-bogus-path-dependency/c/dub.sdl @@ -1 +1 @@ -name "c" +name "issue777-c" diff --git a/test/issue777-bogus-path-dependency/dub.sdl b/test/issue777-bogus-path-dependency/dub.sdl index 441587cc94..84781646cd 100644 --- a/test/issue777-bogus-path-dependency/dub.sdl +++ b/test/issue777-bogus-path-dependency/dub.sdl @@ -1,2 +1,2 @@ -name "test" -dependency "b" path="b" +name "issue777-test" +dependency "issue777-b" path="b" diff --git a/test/issue777-bogus-path-dependency/dub.selections.json b/test/issue777-bogus-path-dependency/dub.selections.json index a446d1f23f..acd8f7efeb 100644 --- a/test/issue777-bogus-path-dependency/dub.selections.json +++ b/test/issue777-bogus-path-dependency/dub.selections.json @@ -1,7 +1,7 @@ { "fileVersion": 1, "versions": { - "b": {"path":"b"}, - "c": {"path":"c"} + "issue777-b": {"path":"b"}, + "issue777-c": {"path":"c"} } } diff --git a/test/issue782-gtkd-pkg-config.sh b/test/issue782-gtkd-pkg-config.sh deleted file mode 100755 index 4b014ca4aa..0000000000 --- a/test/issue782-gtkd-pkg-config.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if [ $(uname) != "Linux" ]; then - echo "Skipping issue782-dtkd-pkg-config test on non-Linux platform..." -elif [ "${DC}" != "dmd" ]; then - echo "Skipping issue782-dtkd-pkg-config test for ${DC}..." -else - echo ${CURR_DIR-$(pwd)} - # the ${CURR_DIR-$(pwd)} allows running issue782-gtkd-pkg-config.sh stand-alone from the test directory - cd ${CURR_DIR-$(pwd)}/issue782-gtkd-pkg-config - rm -rf fake-gtkd/.dub - rm -f fake-gtkd/libfake-gtkd.so - rm -rf main/.dub - rm -f main/fake-gtkd-test - echo ${DUB} - cd fake-gtkd && ${DUB} build --compiler=${DC} - cd ../main - - # `run` needs to find the fake-gtkd shared library, so set LD_LIBRARY_PATH to where it is - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}${LD_LIBRARY_PATH:+:}$PWD/../fake-gtkd - # pkg-config needs to find our .pc file which is in $PWD/../fake-gtkd/pkgconfig, so set PKG_CONFIG_PATH accordingly - export PKG_CONFIG_PATH=$PWD/../fake-gtkd/pkgconfig - ${DUB} run --force --compiler=${DC} - cd .. - rm -rf fake-gtkd/.dub - rm fake-gtkd/libfake-gtkd.so - rm -rf main/.dub - rm main/fake-gtkd-test -fi diff --git a/test/issue782-gtkd-pkg-config.sh.min_frontend b/test/issue782-gtkd-pkg-config.sh.min_frontend deleted file mode 100644 index a7ad183ce7..0000000000 --- a/test/issue782-gtkd-pkg-config.sh.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.068 \ No newline at end of file diff --git a/test/issue782-gtkd-pkg-config/.gitignore b/test/issue782-gtkd-pkg-config/.gitignore new file mode 100644 index 0000000000..6e1ddc97c9 --- /dev/null +++ b/test/issue782-gtkd-pkg-config/.gitignore @@ -0,0 +1,10 @@ +/sample/** +!/sample/ +!/sample/main/ +!/sample/fake-gtkd/ +!/sample/*/dub.json +!/sample/*/src/ +!/sample/*/src/**.d + +!/sample/fake-gtkd/pkgconfig +!/sample/fake-gtkd/pkgconfig/fake-gtkd.pc diff --git a/test/issue782-gtkd-pkg-config/.no_build b/test/issue782-gtkd-pkg-config/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue782-gtkd-pkg-config/.no_run b/test/issue782-gtkd-pkg-config/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue782-gtkd-pkg-config/.no_test b/test/issue782-gtkd-pkg-config/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue782-gtkd-pkg-config/dub.json b/test/issue782-gtkd-pkg-config/dub.json new file mode 100644 index 0000000000..f283412daf --- /dev/null +++ b/test/issue782-gtkd-pkg-config/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue782-gtkd-pkg-config", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue782-gtkd-pkg-config/fake-gtkd/src/lib.d b/test/issue782-gtkd-pkg-config/fake-gtkd/src/lib.d deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue782-gtkd-pkg-config/fake-gtkd/dub.json b/test/issue782-gtkd-pkg-config/sample/fake-gtkd/dub.json similarity index 100% rename from test/issue782-gtkd-pkg-config/fake-gtkd/dub.json rename to test/issue782-gtkd-pkg-config/sample/fake-gtkd/dub.json diff --git a/test/issue782-gtkd-pkg-config/fake-gtkd/pkgconfig/fake-gtkd.pc b/test/issue782-gtkd-pkg-config/sample/fake-gtkd/pkgconfig/fake-gtkd.pc similarity index 77% rename from test/issue782-gtkd-pkg-config/fake-gtkd/pkgconfig/fake-gtkd.pc rename to test/issue782-gtkd-pkg-config/sample/fake-gtkd/pkgconfig/fake-gtkd.pc index 654ac32859..941ab59c7f 100644 --- a/test/issue782-gtkd-pkg-config/fake-gtkd/pkgconfig/fake-gtkd.pc +++ b/test/issue782-gtkd-pkg-config/sample/fake-gtkd/pkgconfig/fake-gtkd.pc @@ -8,5 +8,5 @@ Version: 1.0.0 #Requires: phobos2 # The "-L-defaultlib=libphobos2.so" and "-defaultlib=libphobos2.so" should both end up on the compiler (at link stage) invocation as "-defaultlib=libphobos2.so" # For this test, it doesn't hurt that they appear twice on the cmd line... -Libs: -L-L${libdir} -L-l:libfake-gtkd.so -L-l:libdl.so.2 -pthread -L-defaultlib=libphobos2.so -defaultlib=libphobos2.so +Libs: -L-L${libdir} -L-l:libfake-gtkd.so -L-ldl -pthread -L-defaultlib=libphobos2.so -defaultlib=libphobos2.so Cflags: -I${includedir} diff --git a/test/issue782-gtkd-pkg-config/fake-gtkd/src/fakegtkd.d b/test/issue782-gtkd-pkg-config/sample/fake-gtkd/src/fakegtkd.d similarity index 100% rename from test/issue782-gtkd-pkg-config/fake-gtkd/src/fakegtkd.d rename to test/issue782-gtkd-pkg-config/sample/fake-gtkd/src/fakegtkd.d diff --git a/test/cache-generated-test-config/.no_build b/test/issue782-gtkd-pkg-config/sample/fake-gtkd/src/lib.d similarity index 100% rename from test/cache-generated-test-config/.no_build rename to test/issue782-gtkd-pkg-config/sample/fake-gtkd/src/lib.d diff --git a/test/issue782-gtkd-pkg-config/main/dub.json b/test/issue782-gtkd-pkg-config/sample/main/dub.json similarity index 100% rename from test/issue782-gtkd-pkg-config/main/dub.json rename to test/issue782-gtkd-pkg-config/sample/main/dub.json diff --git a/test/issue782-gtkd-pkg-config/main/src/app.d b/test/issue782-gtkd-pkg-config/sample/main/src/app.d similarity index 100% rename from test/issue782-gtkd-pkg-config/main/src/app.d rename to test/issue782-gtkd-pkg-config/sample/main/src/app.d diff --git a/test/issue782-gtkd-pkg-config/source/app.d b/test/issue782-gtkd-pkg-config/source/app.d new file mode 100644 index 0000000000..ed3698a38c --- /dev/null +++ b/test/issue782-gtkd-pkg-config/source/app.d @@ -0,0 +1,33 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + foreach (dir; ["fake-gtkd/.dub", "main/.dub"]) + if (exists(dir)) rmdirRecurse(dir); + foreach (file; ["fake-gtkd/libfake-gtkd.so", "main/fake-gtkd-test"]) + if (exists(file)) remove(file); + if (spawnProcess([dub, "build"], null, Config.none, "fake-gtkd").wait != 0) + die("dub build fake-gtkd failed"); + + immutable ldPath = environment.get("LD_LIBRARY_PATH"); + immutable gtkdPath = getcwd.buildPath("fake-gtkd"); + immutable newLdPath = ldPath.length ? ldPath ~ ":" ~ gtkdPath : gtkdPath; + immutable pkgConfigPath = gtkdPath.buildPath("pkgconfig"); + + auto p = spawnProcess( + [dub, "-v", "run", "--force"], + [ "LD_LIBRARY_PATH": newLdPath, + "PKG_CONFIG_PATH": pkgConfigPath, + ], + Config.none, + "main", + ); + if (p.wait != 0) + die("dub run main failed"); +} diff --git a/test/issue782-gtkd-pkg-config/test.config b/test/issue782-gtkd-pkg-config/test.config new file mode 100644 index 0000000000..6d2e671548 --- /dev/null +++ b/test/issue782-gtkd-pkg-config/test.config @@ -0,0 +1,3 @@ +os = linux +# hardcoded -defaultlib=libphobos2.so +dc_backend = dmd \ No newline at end of file diff --git a/test/issue813-fixed-dependency.sh b/test/issue813-fixed-dependency.sh deleted file mode 100755 index bddf078840..0000000000 --- a/test/issue813-fixed-dependency.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue813-fixed-dependency -rm -rf main/.dub -rm -rf sub/.dub -rm -rf sub/sub/.dub -${DUB} build --bare --compiler=${DC} main diff --git a/test/issue813-fixed-dependency/.gitignore b/test/issue813-fixed-dependency/.gitignore new file mode 100644 index 0000000000..a1a74e20a1 --- /dev/null +++ b/test/issue813-fixed-dependency/.gitignore @@ -0,0 +1,10 @@ +/sample/** +!/sample/ +!/sample/main/ +!/sample/sub/ +!/sample/sub/sub +!/sample/**/dub.sdl +!/sample/**/src/ +!/sample/**/src/** + +!/sample/main/dub.selections.json \ No newline at end of file diff --git a/test/issue813-fixed-dependency/.no_build b/test/issue813-fixed-dependency/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue813-fixed-dependency/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue813-fixed-dependency/dub.json b/test/issue813-fixed-dependency/dub.json new file mode 100644 index 0000000000..51c955b746 --- /dev/null +++ b/test/issue813-fixed-dependency/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue813-fixed-dependency", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue813-fixed-dependency/main/dub.sdl b/test/issue813-fixed-dependency/sample/main/dub.sdl similarity index 100% rename from test/issue813-fixed-dependency/main/dub.sdl rename to test/issue813-fixed-dependency/sample/main/dub.sdl diff --git a/test/issue813-fixed-dependency/main/dub.selections.json b/test/issue813-fixed-dependency/sample/main/dub.selections.json similarity index 100% rename from test/issue813-fixed-dependency/main/dub.selections.json rename to test/issue813-fixed-dependency/sample/main/dub.selections.json diff --git a/test/issue813-fixed-dependency/main/src/app.d b/test/issue813-fixed-dependency/sample/main/src/app.d similarity index 100% rename from test/issue813-fixed-dependency/main/src/app.d rename to test/issue813-fixed-dependency/sample/main/src/app.d diff --git a/test/issue813-fixed-dependency/sub/dub.sdl b/test/issue813-fixed-dependency/sample/sub/dub.sdl similarity index 100% rename from test/issue813-fixed-dependency/sub/dub.sdl rename to test/issue813-fixed-dependency/sample/sub/dub.sdl diff --git a/test/issue813-fixed-dependency/sub/sub/dub.sdl b/test/issue813-fixed-dependency/sample/sub/sub/dub.sdl similarity index 100% rename from test/issue813-fixed-dependency/sub/sub/dub.sdl rename to test/issue813-fixed-dependency/sample/sub/sub/dub.sdl diff --git a/test/issue813-fixed-dependency/sub/sub/src/sub/test.d b/test/issue813-fixed-dependency/sample/sub/sub/src/sub/test.d similarity index 100% rename from test/issue813-fixed-dependency/sub/sub/src/sub/test.d rename to test/issue813-fixed-dependency/sample/sub/sub/src/sub/test.d diff --git a/test/issue813-fixed-dependency/source/app.d b/test/issue813-fixed-dependency/source/app.d new file mode 100644 index 0000000000..6297cadcb3 --- /dev/null +++ b/test/issue813-fixed-dependency/source/app.d @@ -0,0 +1,13 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + if (spawnProcess([dub, "build", "--bare", "main"]).wait != 0) + die("dub build failed"); +} diff --git a/test/issue813-pure-sub-dependency.sh b/test/issue813-pure-sub-dependency.sh deleted file mode 100755 index ec2291ebe3..0000000000 --- a/test/issue813-pure-sub-dependency.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue813-pure-sub-dependency -rm -rf main/.dub -rm -rf sub/.dub -rm -rf sub/sub/.dub -rm -f main/dub.selections.json -${DUB} build --bare --compiler=${DC} main diff --git a/test/issue813-pure-sub-dependency/.gitignore b/test/issue813-pure-sub-dependency/.gitignore new file mode 100644 index 0000000000..102fd13ab2 --- /dev/null +++ b/test/issue813-pure-sub-dependency/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/main/ +!/sample/sub/ +!/sample/sub/sub +!/sample/**/dub.sdl +!/sample/**/src/ +!/sample/**/src/** \ No newline at end of file diff --git a/test/issue813-pure-sub-dependency/.no_build b/test/issue813-pure-sub-dependency/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue813-pure-sub-dependency/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue813-pure-sub-dependency/dub.json b/test/issue813-pure-sub-dependency/dub.json new file mode 100644 index 0000000000..acbd6dfb20 --- /dev/null +++ b/test/issue813-pure-sub-dependency/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue813-pure-sub-dependency", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue813-pure-sub-dependency/main/dub.sdl b/test/issue813-pure-sub-dependency/sample/main/dub.sdl similarity index 100% rename from test/issue813-pure-sub-dependency/main/dub.sdl rename to test/issue813-pure-sub-dependency/sample/main/dub.sdl diff --git a/test/issue813-pure-sub-dependency/main/src/app.d b/test/issue813-pure-sub-dependency/sample/main/src/app.d similarity index 100% rename from test/issue813-pure-sub-dependency/main/src/app.d rename to test/issue813-pure-sub-dependency/sample/main/src/app.d diff --git a/test/issue813-pure-sub-dependency/sub/dub.sdl b/test/issue813-pure-sub-dependency/sample/sub/dub.sdl similarity index 100% rename from test/issue813-pure-sub-dependency/sub/dub.sdl rename to test/issue813-pure-sub-dependency/sample/sub/dub.sdl diff --git a/test/issue813-pure-sub-dependency/sub/sub/dub.sdl b/test/issue813-pure-sub-dependency/sample/sub/sub/dub.sdl similarity index 100% rename from test/issue813-pure-sub-dependency/sub/sub/dub.sdl rename to test/issue813-pure-sub-dependency/sample/sub/sub/dub.sdl diff --git a/test/issue813-pure-sub-dependency/sub/sub/src/sub/test.d b/test/issue813-pure-sub-dependency/sample/sub/sub/src/sub/test.d similarity index 100% rename from test/issue813-pure-sub-dependency/sub/sub/src/sub/test.d rename to test/issue813-pure-sub-dependency/sample/sub/sub/src/sub/test.d diff --git a/test/issue813-pure-sub-dependency/source/app.d b/test/issue813-pure-sub-dependency/source/app.d new file mode 100644 index 0000000000..6297cadcb3 --- /dev/null +++ b/test/issue813-pure-sub-dependency/source/app.d @@ -0,0 +1,13 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + if (spawnProcess([dub, "build", "--bare", "main"]).wait != 0) + die("dub build failed"); +} diff --git a/test/issue820-extra-fields-after-convert.sh b/test/issue820-extra-fields-after-convert.sh deleted file mode 100755 index 5e81e35a19..0000000000 --- a/test/issue820-extra-fields-after-convert.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -cd ${CURR_DIR}/1-exec-simple - -cp dub.json dub.json.bak -${DUB} convert -f sdl - -if grep -qe "version\|sourcePaths\|importPaths\|configuration" dub.sdl > /dev/null; then - mv dub.json.bak dub.json - rm dub.sdl - die $LINENO 'Conversion added extra fields.' -fi - -mv dub.json.bak dub.json -rm dub.sdl diff --git a/test/issue820-extra-fields-after-convert/.gitignore b/test/issue820-extra-fields-after-convert/.gitignore new file mode 100644 index 0000000000..9cab3c4594 --- /dev/null +++ b/test/issue820-extra-fields-after-convert/.gitignore @@ -0,0 +1,3 @@ +/sample/** +!/sample/ +!/sample/dub.json diff --git a/test/issue820-extra-fields-after-convert/dub.json b/test/issue820-extra-fields-after-convert/dub.json new file mode 100644 index 0000000000..59985a5666 --- /dev/null +++ b/test/issue820-extra-fields-after-convert/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue820-extra-fields-after-convert", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue820-extra-fields-after-convert/sample/dub.json b/test/issue820-extra-fields-after-convert/sample/dub.json new file mode 100644 index 0000000000..14f18baccd --- /dev/null +++ b/test/issue820-extra-fields-after-convert/sample/dub.json @@ -0,0 +1,4 @@ +{ + "name": "test", + "targetType": "executable" +} diff --git a/test/issue820-extra-fields-after-convert/source/app.d b/test/issue820-extra-fields-after-convert/source/app.d new file mode 100644 index 0000000000..5a912b2bdc --- /dev/null +++ b/test/issue820-extra-fields-after-convert/source/app.d @@ -0,0 +1,17 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + auto p = teeProcess([dub, "convert", "-s", "-f", "sdl"]); + if (p.wait != 0) + die("dub convert failed"); + if (p.stdout.canFind("version", "sourcePaths", "importPaths", "configuration")) { + die("Conversion added extra fields"); + } +} diff --git a/test/issue838-custom-cache-paths.sh b/test/issue838-custom-cache-paths.sh deleted file mode 100755 index da8e84adf5..0000000000 --- a/test/issue838-custom-cache-paths.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -CONFIG_FILE=$CURR_DIR/../etc/dub/settings.json - -mkdir $CURR_DIR/../etc && mkdir $CURR_DIR/../etc/dub || true -echo "{\"customCachePaths\": [\"$CURR_DIR/issue838-custom-cache-paths/cache\"]}" > $CONFIG_FILE - -trap "rm $CONFIG_FILE" EXIT - -if ! { $DUB build --root "$CURR_DIR/issue838-custom-cache-paths" --skip-registry=all; }; then - die $LINENO 'Failed to build package with custom cache path for dependencies.' -fi diff --git a/test/issue838-custom-cache-paths/.gitignore b/test/issue838-custom-cache-paths/.gitignore new file mode 100644 index 0000000000..3430c6a327 --- /dev/null +++ b/test/issue838-custom-cache-paths/.gitignore @@ -0,0 +1,7 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/source/ +!/sample/source/*.d +!/sample/cache/ +!/sample/cache/** \ No newline at end of file diff --git a/test/issue838-custom-cache-paths/.no_build b/test/issue838-custom-cache-paths/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue838-custom-cache-paths/dub.json b/test/issue838-custom-cache-paths/dub.json new file mode 100644 index 0000000000..a73abe6f49 --- /dev/null +++ b/test/issue838-custom-cache-paths/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue838-custom-cache-paths", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue838-custom-cache-paths/cache/foo/1.0.0/foo/dub.sdl b/test/issue838-custom-cache-paths/sample/cache/foo/1.0.0/foo/dub.sdl similarity index 100% rename from test/issue838-custom-cache-paths/cache/foo/1.0.0/foo/dub.sdl rename to test/issue838-custom-cache-paths/sample/cache/foo/1.0.0/foo/dub.sdl diff --git a/test/issue838-custom-cache-paths/dub.sdl b/test/issue838-custom-cache-paths/sample/dub.sdl similarity index 100% rename from test/issue838-custom-cache-paths/dub.sdl rename to test/issue838-custom-cache-paths/sample/dub.sdl diff --git a/test/issue838-custom-cache-paths/sample/source/app.d b/test/issue838-custom-cache-paths/sample/source/app.d new file mode 100644 index 0000000000..919810306a --- /dev/null +++ b/test/issue838-custom-cache-paths/sample/source/app.d @@ -0,0 +1,3 @@ +void main() +{ +} diff --git a/test/issue838-custom-cache-paths/source/app.d b/test/issue838-custom-cache-paths/source/app.d index 919810306a..5828345998 100644 --- a/test/issue838-custom-cache-paths/source/app.d +++ b/test/issue838-custom-cache-paths/source/app.d @@ -1,3 +1,22 @@ -void main() -{ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + chdir("sample"); + + import std.json; + immutable jsonPath = JSONValue(getcwd.buildPath("cache")).toString(); + + File("dub.settings.json", "w").writefln(`{ +"customCachePaths": [ %s ] +}`, + jsonPath); + + if (spawnProcess([dub, "build", "--skip-registry=all"]).wait != 0) + die("Failed to build package with custom cache path for dependencies."); } diff --git a/test/issue877-auto-fetch-package-on-run.sh b/test/issue877-auto-fetch-package-on-run.sh deleted file mode 100755 index ddaea8a3bd..0000000000 --- a/test/issue877-auto-fetch-package-on-run.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -set -eu -o pipefail -set -x -$DUB remove 'gitcompatibledubpackage@*' || true - -# check whether the interactive run mode works -echo "y" | $DUB run gitcompatibledubpackage | grep "Hello DUB" -$DUB remove gitcompatibledubpackage - -! (echo "n" | $DUB run gitcompatibledubpackage | grep "Hello DUB") -! $DUB remove gitcompatibledubpackage - -# check -y -$DUB run --yes gitcompatibledubpackage | grep "Hello DUB" -$DUB remove gitcompatibledubpackage - -# check --yes -$DUB run -y gitcompatibledubpackage | grep "Hello DUB" -$DUB remove gitcompatibledubpackage - -(! $DUB run --non-interactive gitcompatibledubpackage || true) 2>&1 | \ - grep "Failed to find.*gitcompatibledubpackage.*locally" - -# check supplying versions directly -dub_log="$($DUB run gitcompatibledubpackage@1.0.3)" -echo "$dub_log" | grep "Hello DUB" -echo "$dub_log" | grep "Fetching.*1.0.3" -$DUB remove gitcompatibledubpackage - -# check supplying an invalid version -(! $DUB run gitcompatibledubpackage@0.42.43 || true) 2>&1 | \ - grep 'No package gitcompatibledubpackage was found matching the dependency 0[.]42[.]43' - -! $DUB remove gitcompatibledubpackage diff --git a/test/issue877-auto-fetch-package-on-run/dub.json b/test/issue877-auto-fetch-package-on-run/dub.json new file mode 100644 index 0000000000..ea9c3e3cb8 --- /dev/null +++ b/test/issue877-auto-fetch-package-on-run/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue877-auto-fetch-package-on-run", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue877-auto-fetch-package-on-run/source/app.d b/test/issue877-auto-fetch-package-on-run/source/app.d new file mode 100644 index 0000000000..5bbf185659 --- /dev/null +++ b/test/issue877-auto-fetch-package-on-run/source/app.d @@ -0,0 +1,100 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.regex; +import std.stdio; + +void main () { + execute([dub, "remove", "gitcompatibledubpackage@*"]); + + // check whether the interactive run mode works + { + auto p = teeProcess([dub, "run", "gitcompatibledubpackage"], + Redirect.stdin | Redirect.stdout); + p.stdin.writeln("y"); + p.stdin.close(); + if (p.wait != 0) + die("dub run failed"); + if (!p.stdout.canFind("Hello DUB")) + die("Didn't find 'Hello DUB' in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait != 0) + die("Couldn't remove gitcompatibledubpackage"); + } + + { + auto p = teeProcess([dub, "run", "gitcompatibledubpackage"], + Redirect.stdin | Redirect.stdout); + p.stdin.writeln("n"); + p.stdin.close(); + if (p.wait == 0) + die("dub run succeeded"); + if (p.stdout.canFind("Hello DUB")) + die("Found 'Hello DUB' in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait == 0) + die("gitcompatibledubpackage should not have been installed"); + } + + // check --yes + { + auto p = teeProcess([dub, "run", "--yes", "gitcompatibledubpackage"], + Redirect.stdout); + if (p.wait != 0) + die("dub run failed"); + if (!p.stdout.canFind("Hello DUB")) + die("Didn't find 'Hello DUB' in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait != 0) + die("Couldn't remove gitcompatibledubpackage"); + } + + // check -y + { + auto p = teeProcess([dub, "run", "-y", "gitcompatibledubpackage"], + Redirect.stdout); + if (p.wait != 0) + die("dub run failed"); + if (!p.stdout.canFind("Hello DUB")) + die("Didn't find 'Hello DUB' in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait != 0) + die("Couldn't remove gitcompatibledubpackage"); + } + + { + auto p = teeProcess([dub, "run", "--non-interactive", "gitcompatibledubpackage"], + Redirect.stdout | Redirect.stderrToStdout); + if (p.wait == 0) + die("dub run shouldn't have succeeded"); + if (!p.stdout.matchFirst(`Failed to find.*gitcompatibledubpackage.*locally`)) + die("Didn't find expected line in output"); + } + + // check supplying versions directly + { + auto p = teeProcess([dub, "run", "gitcompatibledubpackage@1.0.3"], + Redirect.stdout); + if (p.wait != 0) + die("dub run failed"); + + if (!p.stdout.canFind("Hello DUB")) + die("Didn't find 'Hello DUB' in output"); + if (!p.stdout.matchFirst(`Fetching.*1.0.3`)) + die("Didn't find Fetching line in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait != 0) + die("Couldn't remove gitcompatibledubpackage"); + } + + // check supplying an invalid version + { + auto p = teeProcess([dub, "run", "gitcompatibledubpackage@0.42.43"], + Redirect.stdout | Redirect.stderrToStdout); + if (p.pid.wait == 0) + die("dub run succeeded"); + + if (!p.stdout.canFind("No package gitcompatibledubpackage was found matching the dependency 0.42.43")) + die("Didn't find expected line in output"); + if (spawnProcess([dub, "remove", "gitcompatibledubpackage"]).wait == 0) + die("gitcompatibledubpackage should not have been installed"); + } +} diff --git a/test/issue884-init-defer-file-creation.sh b/test/issue884-init-defer-file-creation.sh deleted file mode 100755 index 7ffab211c9..0000000000 --- a/test/issue884-init-defer-file-creation.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -TMPDIR=${CURR_DIR}tmppack -echo $TMPDIR - -mkdir ${TMPDIR} -cd ${TMPDIR} - -# kill dub init during interactive mode -mkfifo in -${DUB} init < in & -sleep 1 -kill $! -rm in - -# ensure that no files are left behind -NFILES_PLUS_ONE=`ls -la | wc -l` - -cd ${CURR_DIR} -rm -r ${TMPDIR} - -# ignore sum + "." + ".." -if [ ${NFILES_PLUS_ONE} -gt 3 ]; then - die $LINENO 'Aborted dub init left spurious files around.' -fi diff --git a/test/issue884-init-defer-file-creation/dub.json b/test/issue884-init-defer-file-creation/dub.json new file mode 100644 index 0000000000..a1aad980ec --- /dev/null +++ b/test/issue884-init-defer-file-creation/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue884-init-defer-file-creation", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue884-init-defer-file-creation/source/app.d b/test/issue884-init-defer-file-creation/source/app.d new file mode 100644 index 0000000000..8178de3a45 --- /dev/null +++ b/test/issue884-init-defer-file-creation/source/app.d @@ -0,0 +1,25 @@ +import common; + +import core.thread.osthread; +import core.time; +import std.algorithm; +import std.file; +import std.path; +import std.range; +import std.process; + +void main () { + if (exists("test")) rmdirRecurse("test"); + mkdir("test"); + chdir("test"); + auto p = pipeProcess([dub, "init"], Redirect.stdin); + scope(exit) p.pid.wait; + + Thread.sleep(1.seconds); + p.pid.kill; + p.stdin.close(); + + immutable filesCount = dirEntries(".", SpanMode.shallow).walkLength; + if (filesCount > 0) + die("Aborted dub init left spurious files around."); +} diff --git a/test/issue895-local-configuration.sh b/test/issue895-local-configuration.sh deleted file mode 100755 index 7ce00bb2f6..0000000000 --- a/test/issue895-local-configuration.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -if [ -e /var/lib/dub/settings.json ]; then - die $LINENO 'Found existing system wide DUB configuration. Aborting.' -fi - -if [ -e ~/.dub/settings.json ]; then - die $LINENO 'Found existing user wide DUB configuration. Aborting.' -fi - -cd ${CURR_DIR} -mkdir -p ../etc/dub -echo "{\"defaultCompiler\": \"foo\"}" > ../etc/dub/settings.json -echo "Empty file named foo." > ../bin/foo - -function cleanup { - rm -r ../etc -} - -trap cleanup EXIT - -unset DC - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $(dirname $CURR_DIR)/bin/foo"; then - rm ../bin/foo - die $LINENO 'DUB did not find the local configuration with an adjacent compiler.' -fi - -echo "{\"defaultCompiler\": \"$CURR_DIR/foo\"}" > ../etc/dub/settings.json -mv ../bin/foo $CURR_DIR - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $CURR_DIR/foo"; then - rm $CURR_DIR/foo - die $LINENO 'DUB did not find a locally-configured compiler with an absolute path.' -fi - -echo "{\"defaultCompiler\": \"~/.dub/foo\"}" > ../etc/dub/settings.json -mv $CURR_DIR/foo ~/.dub/ - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: "; then - rm ~/.dub/foo - die $LINENO 'DUB did not find a locally-configured compiler with a tilde-prefixed path.' -fi - -echo "{\"defaultCompiler\": \"\$DUB_BINARY_PATH/../foo\"}" > ../etc/dub/settings.json -mv ~/.dub/foo .. - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $(dirname $CURR_DIR)/bin/../foo"; then - rm ../foo - die $LINENO 'DUB did not find a locally-configured compiler with a DUB-relative path.' -fi - -echo "{\"defaultCompiler\": \"../foo\"}" > ../etc/dub/settings.json - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "defaultCompiler specified in a DUB config file cannot use an unqualified relative path"; then - rm ../foo - die $LINENO 'DUB did not error properly for a locally-configured compiler with a relative path.' -fi - -rm ../etc/dub/settings.json -echo "Empty file named ldc2." > ../bin/ldc2 - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Failed to execute '$(dirname $CURR_DIR)/bin/ldc2'"; then - rm ../bin/ldc2 - die $LINENO 'DUB did not find ldc2 adjacent to it.' -fi - -echo "{\"defaultCompiler\": \"foo\"}" > ../etc/dub/settings.json -rm ../bin/ldc2 -export PATH=$(dirname $CURR_DIR)${PATH:+:$PATH} - -if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: foo"; then - rm ../foo - die $LINENO 'DUB did not find a locally-configured compiler in its PATH.' -fi - -rm ../foo diff --git a/test/issue895-local-configuration/.gitignore b/test/issue895-local-configuration/.gitignore new file mode 100644 index 0000000000..20656516f1 --- /dev/null +++ b/test/issue895-local-configuration/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue895-local-configuration/dub.json b/test/issue895-local-configuration/dub.json new file mode 100644 index 0000000000..bf1646c784 --- /dev/null +++ b/test/issue895-local-configuration/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue895-local-configuration", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue895-local-configuration/sample/dub.json b/test/issue895-local-configuration/sample/dub.json new file mode 100644 index 0000000000..e4ed6862ac --- /dev/null +++ b/test/issue895-local-configuration/sample/dub.json @@ -0,0 +1,3 @@ +{ + "name": "sample" +} diff --git a/test/issue895-local-configuration/sample/source/app.d b/test/issue895-local-configuration/sample/source/app.d new file mode 100644 index 0000000000..d66321b3c5 --- /dev/null +++ b/test/issue895-local-configuration/sample/source/app.d @@ -0,0 +1 @@ +void main () {} diff --git a/test/issue895-local-configuration/source/app.d b/test/issue895-local-configuration/source/app.d new file mode 100644 index 0000000000..1b6b95870e --- /dev/null +++ b/test/issue895-local-configuration/source/app.d @@ -0,0 +1,104 @@ +import common; + +import std.algorithm; +import std.file; +import std.json; +import std.path; +import std.process; +import std.stdio : File; + +void main () { + chdir("sample"); + environment.remove("DC"); + immutable dubDir = dub.dirName; + + { + immutable path = dubDir.buildPath("foo"); + immutable configPath = "foo"; + immutable needle = "Unknown compiler: " ~ absolutePath(path); + immutable errorMessage = "DUB did not find the local configuration with an adjacent compiler."; + + testCase(path, configPath, needle, errorMessage); + } + + { + immutable path = getcwd.buildPath("foo"); + immutable configPath = path; + immutable needle = "Unknown compiler: " ~ path; + immutable errorMessage = "DUB did not find a locally-configured compiler with an absolute path."; + + testCase(path, configPath, needle, errorMessage); + } + + version(Posix) + {{ + immutable path = getcwd.buildPath("foo"); + immutable configPath = "~/foo"; + immutable needle = "Unknown compiler: "; + immutable errorMessage = "DUB did not find a locally-configured compiler with a tilde-prefixed path."; + + testCase(path, configPath, needle, errorMessage, ["HOME": getcwd]); + }} + + { + immutable path = getcwd.buildPath("foo"); + + immutable relPath = relativePath(path, dubDir); + immutable configPath = "$DUB_BINARY_PATH".buildPath(relPath); + + immutable needle = "Unknown compiler: " ~ dubDir.buildPath(relPath); + immutable errorMessage = "DUB did not find a locally-configured compiler with a DUB-relative path."; + + testCase(path, configPath, needle, errorMessage); + } + + { + immutable path = null; + immutable configPath = "../foo"; + immutable needle = "defaultCompiler specified in a DUB config file cannot use an unqualified relative path"; + immutable errorMessage = "DUB did not error properly for a locally-configured compiler with a relative path."; + + testCase(path, configPath, needle, errorMessage); + } + + { + immutable path = dubDir.buildPath("ldc2"); + immutable configPath = null; + version(Posix) + immutable needle = "Failed to execute '" ~ absolutePath(path) ~ "'"; + else + immutable needle = `Failed to spawn process "` ~ absolutePath(path) ~ `.exe"`; + immutable errorMessage = "DUB did not find ldc2 adjacent to it."; + + testCase(path, configPath, needle, errorMessage); + } + + { + immutable path = getcwd.buildPath("foo"); + immutable configPath = "foo"; + immutable needle = "Unknown compiler: foo"; + immutable errorMessage = "DUB did not find a locally-configured compiler in its PATH."; + + testCase(path, configPath, needle, errorMessage, ["PATH": getcwd ~ pathSeparator ~ environment["PATH"]]); + } +} + +void testCase(string path, string configPath, string needle, string errorMessage, const string[string] env = null) { + immutable cmd = [ dub, "describe", "--data=main-source-file" ]; + + if (path) + path ~= DotExe; + + if (path) write(path, "An empty file"); + scope(exit) if (path) remove(path); + + if (configPath) + File("dub.settings.json", "w").writefln(`{ "defaultCompiler": %s }`, JSONValue(configPath).toString()); + // leave dub.settings.json in the test dir when it fails + scope(success) if (configPath) remove("dub.settings.json"); + + auto p = teeProcess(cmd, Redirect.stdout | Redirect.stderrToStdout, env); + p.wait; + if (!p.stdout.canFind(needle)) + die(errorMessage); +} diff --git a/test/issue895-local-configuration/test.config b/test/issue895-local-configuration/test.config new file mode 100644 index 0000000000..6a17d7e370 --- /dev/null +++ b/test/issue895-local-configuration/test.config @@ -0,0 +1,5 @@ +# Adding ldc2 to bin/dub may be picked up by other tests +# +# Requiring that DC is an absolute path when passed +# to the test runner would solve it +must_be_run_alone = true \ No newline at end of file diff --git a/test/issue923-subpackage-deps.sh b/test/issue923-subpackage-deps.sh deleted file mode 100755 index f3be79c4fa..0000000000 --- a/test/issue923-subpackage-deps.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue923-subpackage-deps -rm -rf main/.dub -rm -rf a/.dub -rm -rf b/.dub -rm -f main/dub.selections.json -${DUB} build --bare --compiler=${DC} main - - -if ! grep -c -e \"b\" main/dub.selections.json; then - die $LINENO 'Dependency b not resolved.' -fi diff --git a/test/issue923-subpackage-deps/.gitignore b/test/issue923-subpackage-deps/.gitignore new file mode 100644 index 0000000000..04a5b7003d --- /dev/null +++ b/test/issue923-subpackage-deps/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/b/ +!/sample/main/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/*.d \ No newline at end of file diff --git a/test/issue923-subpackage-deps/.no_build b/test/issue923-subpackage-deps/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue923-subpackage-deps/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue923-subpackage-deps/dub.json b/test/issue923-subpackage-deps/dub.json new file mode 100644 index 0000000000..7de3456821 --- /dev/null +++ b/test/issue923-subpackage-deps/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue923-subpackage-deps", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue923-subpackage-deps/a/dub.sdl b/test/issue923-subpackage-deps/sample/a/dub.sdl similarity index 100% rename from test/issue923-subpackage-deps/a/dub.sdl rename to test/issue923-subpackage-deps/sample/a/dub.sdl diff --git a/test/issue923-subpackage-deps/b/dub.sdl b/test/issue923-subpackage-deps/sample/b/dub.sdl similarity index 100% rename from test/issue923-subpackage-deps/b/dub.sdl rename to test/issue923-subpackage-deps/sample/b/dub.sdl diff --git a/test/issue923-subpackage-deps/b/source/b.d b/test/issue923-subpackage-deps/sample/b/source/b.d similarity index 100% rename from test/issue923-subpackage-deps/b/source/b.d rename to test/issue923-subpackage-deps/sample/b/source/b.d diff --git a/test/issue923-subpackage-deps/main/dub.sdl b/test/issue923-subpackage-deps/sample/main/dub.sdl similarity index 100% rename from test/issue923-subpackage-deps/main/dub.sdl rename to test/issue923-subpackage-deps/sample/main/dub.sdl diff --git a/test/issue923-subpackage-deps/main/source/app.d b/test/issue923-subpackage-deps/sample/main/source/app.d similarity index 100% rename from test/issue923-subpackage-deps/main/source/app.d rename to test/issue923-subpackage-deps/sample/main/source/app.d diff --git a/test/issue923-subpackage-deps/source/app.d b/test/issue923-subpackage-deps/source/app.d new file mode 100644 index 0000000000..ec9d135432 --- /dev/null +++ b/test/issue923-subpackage-deps/source/app.d @@ -0,0 +1,17 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + if (exists("main/dub.selections.json")) remove("main/dub.selections.json"); + + if (spawnProcess([dub, "build", "--bare", "main"]).wait != 0) + die("dub build failed"); + + if (!readText("main/dub.selections.json").canFind(`"b"`)) + die("Dependency b not resolved."); +} diff --git a/test/issue934-path-dep.sh b/test/issue934-path-dep.sh deleted file mode 100755 index 387521bfa5..0000000000 --- a/test/issue934-path-dep.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue934-path-dep -rm -rf main/.dub -rm -rf a/.dub -rm -rf b/.dub -rm -f main/dub.selections.json -cd main -${DUB} build --compiler=${DC} diff --git a/test/issue934-path-dep/.gitignore b/test/issue934-path-dep/.gitignore new file mode 100644 index 0000000000..04a5b7003d --- /dev/null +++ b/test/issue934-path-dep/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/a/ +!/sample/b/ +!/sample/main/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/*.d \ No newline at end of file diff --git a/test/issue934-path-dep/.no_build b/test/issue934-path-dep/.no_build deleted file mode 100644 index 8d1c8b69c3..0000000000 --- a/test/issue934-path-dep/.no_build +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/issue934-path-dep/dub.json b/test/issue934-path-dep/dub.json new file mode 100644 index 0000000000..6ecf7947a5 --- /dev/null +++ b/test/issue934-path-dep/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue934-path-dep", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue934-path-dep/a/dub.sdl b/test/issue934-path-dep/sample/a/dub.sdl similarity index 100% rename from test/issue934-path-dep/a/dub.sdl rename to test/issue934-path-dep/sample/a/dub.sdl diff --git a/test/issue934-path-dep/b/dub.sdl b/test/issue934-path-dep/sample/b/dub.sdl similarity index 100% rename from test/issue934-path-dep/b/dub.sdl rename to test/issue934-path-dep/sample/b/dub.sdl diff --git a/test/issue934-path-dep/b/source/b.d b/test/issue934-path-dep/sample/b/source/b.d similarity index 100% rename from test/issue934-path-dep/b/source/b.d rename to test/issue934-path-dep/sample/b/source/b.d diff --git a/test/issue934-path-dep/main/dub.sdl b/test/issue934-path-dep/sample/main/dub.sdl similarity index 100% rename from test/issue934-path-dep/main/dub.sdl rename to test/issue934-path-dep/sample/main/dub.sdl diff --git a/test/issue934-path-dep/main/source/app.d b/test/issue934-path-dep/sample/main/source/app.d similarity index 100% rename from test/issue934-path-dep/main/source/app.d rename to test/issue934-path-dep/sample/main/source/app.d diff --git a/test/issue934-path-dep/source/app.d b/test/issue934-path-dep/source/app.d new file mode 100644 index 0000000000..1b40df4d33 --- /dev/null +++ b/test/issue934-path-dep/source/app.d @@ -0,0 +1,14 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample/main"); + if (exists("dub.selections.json")) remove("dub.selections.json"); + + if (spawnProcess([dub, "build"]).wait != 0) + die("dub build failed"); +} diff --git a/test/issue959-path-based-subpack-dep/.gitignore b/test/issue959-path-based-subpack-dep/.gitignore new file mode 100644 index 0000000000..bbbb3d8d57 --- /dev/null +++ b/test/issue959-path-based-subpack-dep/.gitignore @@ -0,0 +1,2 @@ +!/main.d +!/foo/ \ No newline at end of file diff --git a/test/issue959-path-based-subpack-dep/dub.sdl b/test/issue959-path-based-subpack-dep/dub.sdl index 727af608d1..bdc609e138 100644 --- a/test/issue959-path-based-subpack-dep/dub.sdl +++ b/test/issue959-path-based-subpack-dep/dub.sdl @@ -1,6 +1,6 @@ -name "bar" +name "issue959-bar" mainSourceFile "main.d" targetType "executable" -dependency "foo" path="foo" -dependency "foo:baz" path="foo" +dependency "issue959-foo" path="foo" +dependency "issue959-foo:baz" path="foo" diff --git a/test/issue959-path-based-subpack-dep/foo/dub.sdl b/test/issue959-path-based-subpack-dep/foo/dub.sdl index 8266250569..bd21f66f4b 100644 --- a/test/issue959-path-based-subpack-dep/foo/dub.sdl +++ b/test/issue959-path-based-subpack-dep/foo/dub.sdl @@ -1,8 +1,8 @@ -name "foo" +name "issue959-foo" targetType "sourceLibrary" subPackage { name "baz" targetType "sourceLibrary" - dependency "foo" path="." + dependency "issue959-foo" path="." } diff --git a/test/issue97-targettype-none-nodeps/.fail_build b/test/issue97-targettype-none-nodeps/.fail_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none-nodeps/.gitignore b/test/issue97-targettype-none-nodeps/.gitignore index 433d26664a..5f87b5c0cc 100644 --- a/test/issue97-targettype-none-nodeps/.gitignore +++ b/test/issue97-targettype-none-nodeps/.gitignore @@ -1,5 +1,2 @@ -.dub -docs.json -__dummy.html -*.o -*.obj +!/a/ +!/b/ \ No newline at end of file diff --git a/test/issue97-targettype-none-nodeps/.no_run b/test/issue97-targettype-none-nodeps/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none-nodeps/dub.sdl b/test/issue97-targettype-none-nodeps/dub.sdl index 75bd0bd22a..f9c0cd47ce 100644 --- a/test/issue97-targettype-none-nodeps/dub.sdl +++ b/test/issue97-targettype-none-nodeps/dub.sdl @@ -1,4 +1,4 @@ -name "issue97-targettype-none" +name "issue97-targettype-none-nodeps" targetType "none" subPackage "./a/" subPackage "./b/" diff --git a/test/issue97-targettype-none-nodeps/test.config b/test/issue97-targettype-none-nodeps/test.config new file mode 100644 index 0000000000..e516be9d29 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/test.config @@ -0,0 +1,2 @@ +expect_nonzero = true +dub_command = build \ No newline at end of file diff --git a/test/issue97-targettype-none-onerecipe/.gitignore b/test/issue97-targettype-none-onerecipe/.gitignore index 433d26664a..02a14fb564 100644 --- a/test/issue97-targettype-none-onerecipe/.gitignore +++ b/test/issue97-targettype-none-onerecipe/.gitignore @@ -1,5 +1,2 @@ -.dub -docs.json -__dummy.html -*.o -*.obj +!/a/ +!/b/ diff --git a/test/issue97-targettype-none-onerecipe/.no_run b/test/issue97-targettype-none-onerecipe/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none-onerecipe/.no_test b/test/issue97-targettype-none-onerecipe/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none-onerecipe/dub.sdl b/test/issue97-targettype-none-onerecipe/dub.sdl index 0914715d26..3b855ecda1 100644 --- a/test/issue97-targettype-none-onerecipe/dub.sdl +++ b/test/issue97-targettype-none-onerecipe/dub.sdl @@ -1,7 +1,7 @@ -name "issue97-targettype-none" +name "issue97-targettype-none-onerecipe" targetType "none" -dependency "issue97-targettype-none:a" version="*" -dependency "issue97-targettype-none:b" version="*" +dependency "issue97-targettype-none-onerecipe:a" version="*" +dependency "issue97-targettype-none-onerecipe:b" version="*" subPackage { name "a" targetType "executable" diff --git a/test/issue97-targettype-none-onerecipe/test.config b/test/issue97-targettype-none-onerecipe/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/issue97-targettype-none.sh b/test/issue97-targettype-none.sh deleted file mode 100755 index 9017321808..0000000000 --- a/test/issue97-targettype-none.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -e - -${DUB} build --root ${CURR_DIR}/issue97-targettype-none 2>&1 || true - -BUILD_CACHE_A="$HOME/.dub/cache/issue97-targettype-none/~master/+a/build/" -BUILD_CACHE_B="$HOME/.dub/cache/issue97-targettype-none/~master/+b/build/" - -if [ ! -d $BUILD_CACHE_A ]; then - echo "Generated 'a' subpackage build artifact not found!" 1>&2 - exit 1 -fi -if [ ! -d $BUILD_CACHE_B ]; then - echo "Generated 'b' subpackage build artifact not found!" 1>&2 - exit 1 -fi - -${DUB} clean --root ${CURR_DIR}/issue97-targettype-none 2>&1 - -# make sure both sub-packages are cleaned -if [ -d $BUILD_CACHE_A ]; then - echo "Generated 'a' subpackage build artifact were not cleaned!" 1>&2 - exit 1 -fi -if [ -d $BUILD_CACHE_B ]; then - echo "Generated 'b' subpackage build artifact were not cleaned!" 1>&2 - exit 1 -fi diff --git a/test/issue97-targettype-none/.gitignore b/test/issue97-targettype-none/.gitignore new file mode 100644 index 0000000000..4bcd49768d --- /dev/null +++ b/test/issue97-targettype-none/.gitignore @@ -0,0 +1,8 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/a/ +!/sample/b/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/*.d diff --git a/test/issue97-targettype-none/.no_build b/test/issue97-targettype-none/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none/.no_run b/test/issue97-targettype-none/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue97-targettype-none/dub.json b/test/issue97-targettype-none/dub.json new file mode 100644 index 0000000000..8ce9d92e08 --- /dev/null +++ b/test/issue97-targettype-none/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue97-targettype-none", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue97-targettype-none/a/dub.sdl b/test/issue97-targettype-none/sample/a/dub.sdl similarity index 100% rename from test/issue97-targettype-none/a/dub.sdl rename to test/issue97-targettype-none/sample/a/dub.sdl diff --git a/test/issue97-targettype-none/b/source/app.d b/test/issue97-targettype-none/sample/a/source/app.d similarity index 100% rename from test/issue97-targettype-none/b/source/app.d rename to test/issue97-targettype-none/sample/a/source/app.d diff --git a/test/issue97-targettype-none/b/dub.sdl b/test/issue97-targettype-none/sample/b/dub.sdl similarity index 100% rename from test/issue97-targettype-none/b/dub.sdl rename to test/issue97-targettype-none/sample/b/dub.sdl diff --git a/test/issue97-targettype-none/sample/b/source/app.d b/test/issue97-targettype-none/sample/b/source/app.d new file mode 100644 index 0000000000..c3eec7f2dc --- /dev/null +++ b/test/issue97-targettype-none/sample/b/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none/dub.sdl b/test/issue97-targettype-none/sample/dub.sdl similarity index 100% rename from test/issue97-targettype-none/dub.sdl rename to test/issue97-targettype-none/sample/dub.sdl diff --git a/test/issue97-targettype-none/source/app.d b/test/issue97-targettype-none/source/app.d new file mode 100644 index 0000000000..87d43a3ba4 --- /dev/null +++ b/test/issue97-targettype-none/source/app.d @@ -0,0 +1,27 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + spawnProcess([dub, "build", "--root=sample"]).wait; + immutable pkgBuildCache = dubHome.buildPath("cache", "issue97-targettype-none", "~master"); + immutable buildCacheA = pkgBuildCache.buildPath("+a", "build"); + immutable buildCacheB = pkgBuildCache.buildPath("+b", "build"); + + if (!exists(buildCacheA)) + die("Generated 'a' subpackage build artifact not found!"); + if (!exists(buildCacheB)) + die("Generated 'b' subpackage build artifact not found!"); + + if (spawnProcess([dub, "clean", "--root=sample"]).wait != 0) + die("dub clean fialed"); + + // make sure both sub-packages are cleaned + if (exists(buildCacheA)) + die("Generated 'a' subpackage build artifact were not cleaned!"); + if (exists(buildCacheB)) + die("Generated 'b' subpackage build artifact were not cleaned!"); +} diff --git a/test/issue990-download-optional-selected.sh b/test/issue990-download-optional-selected.sh deleted file mode 100755 index 36fd4ad5bc..0000000000 --- a/test/issue990-download-optional-selected.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/issue990-download-optional-selected -${DUB} clean -${DUB} remove gitcompatibledubpackage -n 2>/dev/null || true -${DUB} run diff --git a/test/issue990-download-optional-selected/.gitignore b/test/issue990-download-optional-selected/.gitignore new file mode 100644 index 0000000000..014d651c9e --- /dev/null +++ b/test/issue990-download-optional-selected/.gitignore @@ -0,0 +1,6 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/dub.selections.json +!/sample/source/ +!/sample/source/*.d diff --git a/test/issue990-download-optional-selected/.no_build b/test/issue990-download-optional-selected/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/issue990-download-optional-selected/dub.json b/test/issue990-download-optional-selected/dub.json new file mode 100644 index 0000000000..0786eca99b --- /dev/null +++ b/test/issue990-download-optional-selected/dub.json @@ -0,0 +1,8 @@ +{ + "name": "issue990-download-optional-selected", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/issue990-download-optional-selected/dub.sdl b/test/issue990-download-optional-selected/sample/dub.sdl similarity index 100% rename from test/issue990-download-optional-selected/dub.sdl rename to test/issue990-download-optional-selected/sample/dub.sdl diff --git a/test/issue990-download-optional-selected/dub.selections.json b/test/issue990-download-optional-selected/sample/dub.selections.json similarity index 100% rename from test/issue990-download-optional-selected/dub.selections.json rename to test/issue990-download-optional-selected/sample/dub.selections.json diff --git a/test/issue990-download-optional-selected/sample/source/app.d b/test/issue990-download-optional-selected/sample/source/app.d new file mode 100644 index 0000000000..49eeacb116 --- /dev/null +++ b/test/issue990-download-optional-selected/sample/source/app.d @@ -0,0 +1,6 @@ +import gitcompatibledubpackage.subdir.file; + +void main() +{ + assert(!hasTheWorldExploded); +} diff --git a/test/issue990-download-optional-selected/source/app.d b/test/issue990-download-optional-selected/source/app.d index 49eeacb116..dbc8507c23 100644 --- a/test/issue990-download-optional-selected/source/app.d +++ b/test/issue990-download-optional-selected/source/app.d @@ -1,6 +1,16 @@ -import gitcompatibledubpackage.subdir.file; +import common; -void main() -{ - assert(!hasTheWorldExploded); +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + if (spawnProcess([dub, "clean"]).wait != 0) + die("dub clean failed"); + spawnProcess([dub, "remove", "gitcompatibledubpackage", "-n"]).wait; + if (spawnProcess([dub, "run"]).wait != 0) + die("dub run failed"); } diff --git a/test/mutex-main-1/.no_run b/test/mutex-main-1/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-1/.no_test b/test/mutex-main-1/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-1/dub.json b/test/mutex-main-1/dub.json index 882df72339..b07edb61af 100644 --- a/test/mutex-main-1/dub.json +++ b/test/mutex-main-1/dub.json @@ -1,6 +1,6 @@ { "description": "A minimal D application.", - "name": "mutex-main", + "name": "mutex-main-1", "targetType": "executable", "configurations": [ diff --git a/test/mutex-main-1/test.config b/test/mutex-main-1/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/mutex-main-1/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/mutex-main-2/.no_run b/test/mutex-main-2/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-2/.no_test b/test/mutex-main-2/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-2/dub.json b/test/mutex-main-2/dub.json index 6ca022b94f..9dd31b6e56 100644 --- a/test/mutex-main-2/dub.json +++ b/test/mutex-main-2/dub.json @@ -1,6 +1,6 @@ { "description": "A minimal D application.", - "name": "mutex-main", + "name": "mutex-main-2", "targetType": "executable", "configurations": [ diff --git a/test/mutex-main-2/test.config b/test/mutex-main-2/test.config new file mode 100644 index 0000000000..4c5009d257 --- /dev/null +++ b/test/mutex-main-2/test.config @@ -0,0 +1 @@ +dub_command = build \ No newline at end of file diff --git a/test/mutex-main-3/.fail_build b/test/mutex-main-3/.fail_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-3/.no_run b/test/mutex-main-3/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-3/.no_test b/test/mutex-main-3/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/mutex-main-3/dub.json b/test/mutex-main-3/dub.json index c5db1fa204..6bb9620175 100644 --- a/test/mutex-main-3/dub.json +++ b/test/mutex-main-3/dub.json @@ -1,6 +1,6 @@ { "description": "A minimal D application.", - "name": "mutex-main", + "name": "mutex-main-3", "targetType": "executable", "configurations": [ diff --git a/test/mutex-main-3/test.config b/test/mutex-main-3/test.config new file mode 100644 index 0000000000..dad3cd7683 --- /dev/null +++ b/test/mutex-main-3/test.config @@ -0,0 +1,2 @@ +dub_command = build +expect_nonzero = true \ No newline at end of file diff --git a/test/path-subpackage-ref/.gitignore b/test/path-subpackage-ref/.gitignore new file mode 100644 index 0000000000..516f998760 --- /dev/null +++ b/test/path-subpackage-ref/.gitignore @@ -0,0 +1 @@ +!/subpack \ No newline at end of file diff --git a/test/path-subpackage-ref/dub.json b/test/path-subpackage-ref/dub.json index 4c40d06b0a..3f953affa8 100644 --- a/test/path-subpackage-ref/dub.json +++ b/test/path-subpackage-ref/dub.json @@ -1,7 +1,7 @@ { - "name": "test", + "name": "path-subpackage-ref", "dependencies": { - "test:subpack": "*" + "path-subpackage-ref:subpack": "*" }, "subPackages": [ "subpack/" diff --git a/test/pr1549-dub-exe-var.sh b/test/pr1549-dub-exe-var.sh deleted file mode 100755 index 52d41558a0..0000000000 --- a/test/pr1549-dub-exe-var.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env bash -set -e - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -PR1549=$CURR_DIR/pr1549-dub-exe-var - -${DUB} build --root ${PR1549} -OUTPUT=$(${PR1549}/test-application) - -if [[ "$OUTPUT" != "modified code" ]]; then die $LINENO "\$DUB build variable was (likely) not evaluated correctly"; fi diff --git a/test/pr1549-dub-exe-var/.gitignore b/test/pr1549-dub-exe-var/.gitignore index 964cd1d970..517a80f7ea 100644 --- a/test/pr1549-dub-exe-var/.gitignore +++ b/test/pr1549-dub-exe-var/.gitignore @@ -1,2 +1,6 @@ -setmsg -setmsg.exe +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/setmsg.d +!/sample/source/ +!/sample/source/*.d diff --git a/test/pr1549-dub-exe-var/.no_build b/test/pr1549-dub-exe-var/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/pr1549-dub-exe-var/dub.json b/test/pr1549-dub-exe-var/dub.json new file mode 100644 index 0000000000..6c3ecbf345 --- /dev/null +++ b/test/pr1549-dub-exe-var/dub.json @@ -0,0 +1,8 @@ +{ + "name": "pr1549-dub-exe-var", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/pr1549-dub-exe-var/dub.sdl b/test/pr1549-dub-exe-var/sample/dub.sdl similarity index 100% rename from test/pr1549-dub-exe-var/dub.sdl rename to test/pr1549-dub-exe-var/sample/dub.sdl diff --git a/test/pr1549-dub-exe-var/setmsg.d b/test/pr1549-dub-exe-var/sample/setmsg.d similarity index 100% rename from test/pr1549-dub-exe-var/setmsg.d rename to test/pr1549-dub-exe-var/sample/setmsg.d diff --git a/test/pr1549-dub-exe-var/sample/source/app.d b/test/pr1549-dub-exe-var/sample/source/app.d new file mode 100644 index 0000000000..e143585e53 --- /dev/null +++ b/test/pr1549-dub-exe-var/sample/source/app.d @@ -0,0 +1,5 @@ +import std.stdio; + +void main() { + writeln("unmodified code"); +} diff --git a/test/pr1549-dub-exe-var/source/app.d b/test/pr1549-dub-exe-var/source/app.d index e143585e53..da35d392a9 100644 --- a/test/pr1549-dub-exe-var/source/app.d +++ b/test/pr1549-dub-exe-var/source/app.d @@ -1,5 +1,19 @@ -import std.stdio; +import common; -void main() { - writeln("unmodified code"); +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.string; + +void main () { + if (spawnProcess([dub, "build", "--root", "sample"]).wait != 0) + die("dub build failed"); + + auto p = teeProcess(["sample/test-application"]); + if (p.wait != 0) + die("failed running the built application"); + + if (p.stdout.chomp != "modified code") + die("$DUB build variable was (likely) not evaluated correctly"); } diff --git a/test/pr2642-cache-db/.gitignore b/test/pr2642-cache-db/.gitignore deleted file mode 100644 index da01cd648d..0000000000 --- a/test/pr2642-cache-db/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dubhome/ -pr2642-cache-db diff --git a/test/pr2642-cache-db/.no_test b/test/pr2642-cache-db/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/pr2642-cache-db/dub.sdl b/test/pr2642-cache-db/dub.sdl index f9fca89bc8..5bd9c5c87c 100644 --- a/test/pr2642-cache-db/dub.sdl +++ b/test/pr2642-cache-db/dub.sdl @@ -1,2 +1,3 @@ name "pr2642-cache-db"; targetType "executable"; +dependency "common" path="../common"; diff --git a/test/pr2642-cache-db/source/test_cache_db.d b/test/pr2642-cache-db/source/test_cache_db.d index 28a2438ac5..fdd61c2169 100644 --- a/test/pr2642-cache-db/source/test_cache_db.d +++ b/test/pr2642-cache-db/source/test_cache_db.d @@ -1,5 +1,7 @@ module test_cache_db; +import common; + import std.path; import std.file; import std.process; @@ -8,50 +10,40 @@ import std.json; void main() { - const dubhome = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("dubhome"); - if (exists(dubhome)) + if (exists(dubHome)) { - rmdirRecurse(dubhome); + rmdirRecurse(dubHome); } - const string[string] env = [ - "DUB_HOME": dubhome, - ]; const fetchProgram = [ - environment["DUB"], + dub, "fetch", "gitcompatibledubpackage@1.0.4", ]; - auto dubFetch = spawnProcess(fetchProgram, stdin, stdout, stderr, env); + auto dubFetch = spawnProcess(fetchProgram); wait(dubFetch); const buildProgramLib = [ - environment["DUB"], + dub, "build", "--build=debug", "--config=lib", "gitcompatibledubpackage@1.0.4", ]; - auto dubBuild = spawnProcess(buildProgramLib, stdin, stdout, stderr, env); + auto dubBuild = spawnProcess(buildProgramLib); wait(dubBuild); const buildProgramExe = [ - environment["DUB"], + dub, "build", "--build=debug", "--config=exe", "gitcompatibledubpackage@1.0.4", ]; - dubBuild = spawnProcess(buildProgramExe, stdin, stdout, stderr, env); + dubBuild = spawnProcess(buildProgramExe); wait(dubBuild); - scope (success) - { - // leave dubhome in the tree for analysis in case of failure - rmdirRecurse(dubhome); - } - - const buildDbPath = buildNormalizedPath(dubhome, "cache", "gitcompatibledubpackage", "1.0.4", "db.json"); + const buildDbPath = buildNormalizedPath(dubHome, "cache", "gitcompatibledubpackage", "1.0.4", "db.json"); assert(exists(buildDbPath), buildDbPath ~ " should exist"); const buildDbStr = readText(buildDbPath); auto json = parseJSON(buildDbStr); diff --git a/test/pr2644-describe-artifact-path/.gitignore b/test/pr2644-describe-artifact-path/.gitignore deleted file mode 100644 index 0c7a7b4ca6..0000000000 --- a/test/pr2644-describe-artifact-path/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dubhome/ -pr2644-describe-artifact-path diff --git a/test/pr2644-describe-artifact-path/.no_test b/test/pr2644-describe-artifact-path/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/pr2644-describe-artifact-path/dub.sdl b/test/pr2644-describe-artifact-path/dub.sdl index 4bb325414d..e083eb2dba 100644 --- a/test/pr2644-describe-artifact-path/dub.sdl +++ b/test/pr2644-describe-artifact-path/dub.sdl @@ -1,2 +1,3 @@ name "pr2644-describe-artifact-path"; targetType "executable"; +dependency "common" path="../common"; diff --git a/test/pr2644-describe-artifact-path/source/describe_artifact_path.d b/test/pr2644-describe-artifact-path/source/describe_artifact_path.d index 0e7b2bb927..2dd070da83 100644 --- a/test/pr2644-describe-artifact-path/source/describe_artifact_path.d +++ b/test/pr2644-describe-artifact-path/source/describe_artifact_path.d @@ -1,5 +1,7 @@ module describe_artifact_path; +import common; + import std.path; import std.file; import std.process; @@ -8,54 +10,45 @@ import std.json; void main() { - const dubhome = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("dubhome"); - if (exists(dubhome)) - { - rmdirRecurse(dubhome); - } - scope (success) + if (exists(dubHome)) { - // leave dubhome in the tree for analysis in case of failure - rmdirRecurse(dubhome); + rmdirRecurse(dubHome); } - const string[string] env = [ - "DUB_HOME": dubhome, - ]; const fetchProgram = [ environment["DUB"], "fetch", "gitcompatibledubpackage@1.0.4", ]; - auto dubFetch = spawnProcess(fetchProgram, stdin, stdout, stderr, env); + auto dubFetch = spawnProcess(fetchProgram); wait(dubFetch); - const describeProgram = [ - environment["DUB"], + dub, "describe", - "--compiler=" ~ environment["DC"], "--build=debug", "--config=lib", "gitcompatibledubpackage@1.0.4", ]; - auto result = execute(describeProgram, env); - assert(result.status == 0, "expected dub describe to return zero"); + auto result = execute(describeProgram); + if (result.status != 0) + die("expected dub describe to return zero"); auto json = parseJSON(result.output); auto cacheFile = json["targets"][0]["cacheArtifactPath"].str; - assert(!exists(cacheFile), "found cache file in virgin dubhome"); + if(exists(cacheFile)) + die("found cache file in virgin dubhome"); const buildProgram = [ - environment["DUB"], + dub, "build", - "--compiler=" ~ environment["DC"], "--build=debug", "--config=lib", "gitcompatibledubpackage@1.0.4", ]; - auto dubBuild = spawnProcess(buildProgram, stdin, stdout, stderr, env); + auto dubBuild = spawnProcess(buildProgram); wait(dubBuild); - assert(exists(cacheFile), "did not find cache file after build"); + if (!exists(cacheFile)) + die("did not find cache file after build"); } diff --git a/test/pr2647-build-deep/.gitignore b/test/pr2647-build-deep/.gitignore index a71baffd99..bb8fca4eea 100644 --- a/test/pr2647-build-deep/.gitignore +++ b/test/pr2647-build-deep/.gitignore @@ -1,2 +1,5 @@ -dubhome/ -pr2647-build-deep +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/source/ +!/sample/source/*.d \ No newline at end of file diff --git a/test/pr2647-build-deep/.no_test b/test/pr2647-build-deep/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/pr2647-build-deep/dub.sdl b/test/pr2647-build-deep/dub.sdl index 639f6d5ab4..eae6b02eb1 100644 --- a/test/pr2647-build-deep/dub.sdl +++ b/test/pr2647-build-deep/dub.sdl @@ -1,2 +1,3 @@ name "pr2647-build-deep"; targetType "executable"; +dependency "common" path="../common"; diff --git a/test/pr2647-build-deep/pack/dub.sdl b/test/pr2647-build-deep/sample/dub.sdl similarity index 100% rename from test/pr2647-build-deep/pack/dub.sdl rename to test/pr2647-build-deep/sample/dub.sdl diff --git a/test/pr2647-build-deep/pack/source/lib.d b/test/pr2647-build-deep/sample/source/lib.d similarity index 100% rename from test/pr2647-build-deep/pack/source/lib.d rename to test/pr2647-build-deep/sample/source/lib.d diff --git a/test/pr2647-build-deep/source/test_build_deep.d b/test/pr2647-build-deep/source/test_build_deep.d index 79e4a41e37..7bc2d2c3b9 100644 --- a/test/pr2647-build-deep/source/test_build_deep.d +++ b/test/pr2647-build-deep/source/test_build_deep.d @@ -1,5 +1,7 @@ module test_build_deep; +import common; + import std.array; import std.file; import std.path; @@ -8,46 +10,34 @@ import std.stdio; void main() { - const dubhome = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("dubhome"); - const packdir = __FILE_FULL_PATH__.dirName().dirName().buildNormalizedPath("pack"); - const dub = absolutePath(environment["DUB"]); + const packdir = getcwd.buildPath("sample"); - if (exists(dubhome)) + if (exists(dubHome)) { - rmdirRecurse(dubhome); + rmdirRecurse(dubHome); } - scope (success) - { - // leave dubhome in the tree for analysis in case of failure - rmdirRecurse(dubhome); - } - - const string[string] env = [ - "DUB_HOME": dubhome, - ]; - // testing the regular way first: `dub build` only builds what is needed // (urld is downloaded but not built) const dubBuildProg = [dub, "build"]; - writefln("running %s ...", dubBuildProg.join(" ")); - auto dubBuild = spawnProcess(dubBuildProg, stdin, stdout, stderr, env, Config.none, packdir); + log("running ", dubBuildProg.join(" "), " ..."); + auto dubBuild = spawnProcess(dubBuildProg, null, Config.none, packdir); wait(dubBuild); - assert(exists(buildPath(dubhome, "cache", "pack"))); - assert(isDir(buildPath(dubhome, "cache", "pack"))); - assert(exists(buildPath(dubhome, "packages", "urld"))); - assert(isDir(buildPath(dubhome, "packages", "urld"))); - assert(!exists(buildPath(dubhome, "cache", "urld"))); + assert(exists(buildPath(dubHome, "cache", "pack"))); + assert(isDir(buildPath(dubHome, "cache", "pack"))); + assert(exists(buildPath(dubHome, "packages", "urld"))); + assert(isDir(buildPath(dubHome, "packages", "urld"))); + assert(!exists(buildPath(dubHome, "cache", "urld"))); // now testing the --deep switch: `dub build --deep` will build urld const dubBuildDeepProg = [dub, "build", "--deep"]; - writefln("running %s ...", dubBuildDeepProg.join(" ")); - auto dubBuildDeep = spawnProcess(dubBuildDeepProg, stdin, stdout, stderr, env, Config.none, packdir); + log("running ", dubBuildDeepProg.join(" "), " ..."); + auto dubBuildDeep = spawnProcess(dubBuildDeepProg, null, Config.none, packdir); wait(dubBuildDeep); - assert(exists(buildPath(dubhome, "cache", "pack"))); - assert(isDir(buildPath(dubhome, "cache", "pack"))); - assert(exists(buildPath(dubhome, "packages", "urld"))); - assert(isDir(buildPath(dubhome, "packages", "urld"))); - assert(exists(buildPath(dubhome, "cache", "urld"))); - assert(isDir(buildPath(dubhome, "cache", "urld"))); + assert(exists(buildPath(dubHome, "cache", "pack"))); + assert(isDir(buildPath(dubHome, "cache", "pack"))); + assert(exists(buildPath(dubHome, "packages", "urld"))); + assert(isDir(buildPath(dubHome, "packages", "urld"))); + assert(exists(buildPath(dubHome, "cache", "urld"))); + assert(isDir(buildPath(dubHome, "cache", "urld"))); } diff --git a/test/removed-dub-obj.sh b/test/removed-dub-obj.sh deleted file mode 100755 index d767b43e30..0000000000 --- a/test/removed-dub-obj.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -cd ${CURR_DIR}/removed-dub-obj - -DUB_CACHE_PATH="$HOME/.dub/cache/removed-dub-obj" - -rm -rf "$DUB_CACHE_PATH" - -${DUB} build --compiler=${DC} - -[ -d "$DUB_CACHE_PATH" ] || die $LINENO "$DUB_CACHE_PATH not found" - -numObjectFiles=$(find "$DUB_CACHE_PATH" -type f -iname '*.o*' | wc -l) -# note: fails with LDC < v1.1 -[ "$numObjectFiles" -eq 0 ] || die $LINENO "Found left-over object files in $DUB_CACHE_PATH" diff --git a/test/removed-dub-obj/.gitignore b/test/removed-dub-obj/.gitignore new file mode 100644 index 0000000000..a1ce216fbc --- /dev/null +++ b/test/removed-dub-obj/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/source/ +!/sample/source/test.d diff --git a/test/removed-dub-obj/.no_build b/test/removed-dub-obj/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/removed-dub-obj/.no_run b/test/removed-dub-obj/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/removed-dub-obj/.no_test b/test/removed-dub-obj/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/removed-dub-obj/dub.json b/test/removed-dub-obj/dub.json new file mode 100644 index 0000000000..540f15c242 --- /dev/null +++ b/test/removed-dub-obj/dub.json @@ -0,0 +1,8 @@ +{ + "name": "removed-dub-obj", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/removed-dub-obj/dub.sdl b/test/removed-dub-obj/sample/dub.sdl similarity index 100% rename from test/removed-dub-obj/dub.sdl rename to test/removed-dub-obj/sample/dub.sdl diff --git a/test/removed-dub-obj/source/test.d b/test/removed-dub-obj/sample/source/test.d similarity index 100% rename from test/removed-dub-obj/source/test.d rename to test/removed-dub-obj/sample/source/test.d diff --git a/test/removed-dub-obj/source/app.d b/test/removed-dub-obj/source/app.d new file mode 100644 index 0000000000..b79833bf4b --- /dev/null +++ b/test/removed-dub-obj/source/app.d @@ -0,0 +1,28 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.range; + +void main () { + chdir("sample"); + + immutable cachePath = dubHome.buildPath("cache", "removed-dub-obj"); + if (exists(cachePath)) rmdirRecurse(cachePath); + + if (spawnProcess([dub, "build"]).wait != 0) + die("dub build failed"); + + if (!exists(cachePath)) + die("The expected ", cachePath, " doesn't exist"); + if (!isDir(cachePath)) + die("The expected ", cachePath, " isn't a directory"); + + immutable numObjecjtFiles = dirEntries(cachePath, "*.o*", SpanMode.depth) + .walkLength; + + if (numObjecjtFiles != 0) + die("Found left-over object files in ", cachePath); +} diff --git a/test/run-unittest.d b/test/run-unittest.d index ae6fad4331..cdae908812 100644 --- a/test/run-unittest.d +++ b/test/run-unittest.d @@ -1,190 +1,36 @@ #!/usr/bin/env dub /+dub.sdl: - name: run_unittest + name: run_unittest_old targetName: run-unittest - dependency "common" path="./common" +/ module run_unittest; -import common; +import std.file; +import std.path; +import std.process; int main(string[] args) { - import std.algorithm, std.file, std.format, std.stdio, std.path, std.process, std.string; - alias ProcessConfig = std.process.Config; - - //** if [ -z ${DUB:-} ]; then - //** die $LINENO 'Variable $DUB must be defined to run the tests.' - //** fi - auto dub = environment.get("DUB", ""); - if (dub == "") - { - logError(`Environment variable "DUB" must be defined to run the tests.`); - return 1; - } - - //** if [ -z ${DC:-} ]; then - //** log '$DC not defined, assuming dmd...' - //** DC=dmd - //** fi - auto dc = environment.get("DC", ""); - if (dc == "") - { - log(`Environment variable "DC" not defined, assuming dmd...`); - dc = "dmd"; - } - - // Clear log file - { - File(logFile, "w"); - } - - //** DC_BIN=$(basename "$DC") - //** CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) - //** FRONTEND="${FRONTEND:-}" - const dc_bin = baseName(dc).stripExtension; - const curr_dir = __FILE_FULL_PATH__.dirName(); - const frontend = environment.get("FRONTEND", __VERSION__.format!"%04d"); - - //** if [ "$#" -gt 0 ]; then FILTER=$1; else FILTER=".*"; fi - auto filter = (args.length > 1) ? args[1] : "*"; - version (linux) auto os = "linux"; - version (Windows) auto os = "windows"; - version (OSX) auto os = "osx"; - - version (Posix) - { - //** for script in $(ls $CURR_DIR/*.sh); do - //** if [[ ! "$script" =~ $FILTER ]]; then continue; fi - //** if [ "$script" = "$(gnureadlink ${BASH_SOURCE[0]})" ] || [ "$(basename $script)" = "common.sh" ]; then continue; fi - //** if [ -e $script.min_frontend ] && [ ! -z "$FRONTEND" ] && [ ${FRONTEND} \< $(cat $script.min_frontend) ]; then continue; fi - //** log "Running $script..." - //** DUB=$DUB DC=$DC CURR_DIR="$CURR_DIR" $script || logError "Script failure." - //** done - foreach(DirEntry script; dirEntries(curr_dir, "*.sh", SpanMode.shallow)) - { - if (!script.name.baseName.globMatch(filter)) continue; - if (!script.name.endsWith(".sh")) - continue; - if (baseName(script.name).among("run-unittest.sh", "common.sh")) continue; - const min_frontend = script.name ~ ".min_frontend"; - if (exists(min_frontend) && frontend.length && cmp(frontend, min_frontend.readText) < 0) continue; - log("Running " ~ script ~ "..."); - if (spawnShell(script.name, ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir]).wait) - logError("Script failure."); - else - log(script.name.baseName, " status: Ok"); - } - } - - foreach (DirEntry script; dirEntries(curr_dir, "*.script.d", SpanMode.shallow)) - { - if (!script.name.baseName.globMatch(filter)) continue; - if (!script.name.endsWith(".d")) - continue; - const min_frontend = script.name ~ ".min_frontend"; - if (frontend.length && exists(min_frontend) && cmp(frontend, min_frontend.readText) < 0) continue; - log("Running " ~ script ~ "..."); - if (spawnProcess([dub, script.name], ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir]).wait) - logError("Script failure."); - else - log(script.name, " status: Ok"); - } - - //for pack in $(ls -d $CURR_DIR/*/); do - foreach (DirEntry pack; dirEntries(curr_dir, SpanMode.shallow)) - { - //if [[ ! "$pack" =~ $FILTER ]]; then continue; fi - if (!pack.name.baseName.globMatch(filter)) continue; - if (!pack.isDir || pack.name.baseName.startsWith(".")) continue; - if (!pack.name.buildPath("dub.json").exists && !pack.name.buildPath("dub.sdl").exists && !pack.name.buildPath("package.json").exists) continue; - //if [ -e $pack/.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $pack/.min_frontend) ]; then continue; fi - if (pack.name.buildPath(".min_frontend").exists && cmp(frontend, pack.name.buildPath(".min_frontend").readText) < 0) continue; - - //#First we build the packages - //if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_build_$DC_BIN ]; then # For sourceLibrary - bool build = (!pack.name.buildPath(".no_build").exists - && !pack.name.buildPath(".no_build_" ~ dc_bin).exists - && !pack.name.buildPath(".no_build_" ~ os).exists); - if (build) - { - //build=1 - //if [ -e $pack/.fail_build ]; then - // log "Building $pack, expected failure..." - // $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=$DC || logError "Build failure." - //fi - //if [ -e $pack/.fail_build ]; then - if (pack.name.buildPath(".fail_build").exists) - { - log("Building " ~ pack.name.baseName ~ ", expected failure..."); - if (spawnProcess([dub, "build", "--force", "--compiler", dc], ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir], ProcessConfig.none, pack.name).wait) - log(pack.name.baseName, " status: Ok"); - else - logError("Failure expected, but build passed."); - } - else - { - log("Building ", pack.name.baseName, "..."); - if (spawnProcess([dub, "build", "--force", "--compiler", dc], ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir], ProcessConfig.none, pack.name).wait) - logError("Script failure."); - else - log(pack.name.baseName, " status: Ok"); - } - } - //else - // build=0 - //fi - - //# We run the ones that are supposed to be run - //if [ $build -eq 1 ] && [ ! -e $pack/.no_run ] && [ ! -e $pack/.no_run_$DC_BIN ]; then - // log "Running $pack..." - // $DUB run --force --root=$pack --compiler=$DC || logError "Run failure." - //fi - if (build - && !pack.name.buildPath(".no_run").exists - && !pack.name.buildPath(".no_run_" ~ dc_bin).exists - && !pack.name.buildPath(".no_run_" ~ os).exists) - { - log("Running ", pack.name.baseName, "..."); - if (spawnProcess([dub, "run", "--force", "--compiler", dc], ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir], ProcessConfig.none, pack.name).wait) - logError("Run failure."); - else - log(pack.name.baseName, " status: Ok"); - } - - //# Finally, the unittest part - //if [ $build -eq 1 ] && [ ! -e $pack/.no_test ] && [ ! -e $pack/.no_test_$DC_BIN ]; then - // log "Testing $pack..." - // $DUB test --force --root=$pack --compiler=$DC || logError "Test failure." - //fi - if (build - && !pack.name.buildPath(".no_test").exists - && !pack.name.buildPath(".no_test_" ~ dc_bin).exists - && !pack.name.buildPath(".no_test_" ~ os).exists) - { - log("Testing ", pack.name.baseName, "..."); - if (spawnProcess([dub, "test", "--force", "--root", pack.name, "--compiler", dc], ["DUB":dub, "DC":dc, "CURR_DIR":curr_dir]).wait) - logError("Test failure."); - else - log(pack.name.baseName, " status: Ok"); - } - //done - } - - //echo - //echo 'Testing summary:' - //cat $(dirname "${BASH_SOURCE[0]}")/test.log - writeln(); - writeln("Testing summary:"); - auto logLines = readText("test.log").splitLines; - foreach (line; logLines) - writeln(line); - auto errCnt = logLines.count!(a => a.startsWith("[ERROR]")); - auto passCnt = logLines.count!(a => a.startsWith("[INFO]") && a.endsWith("status: Ok")); - writeln(passCnt , "/", errCnt + passCnt, " tests succeeded."); - - return any_errors; + immutable dubRoot = environment.get("DUB", __FILE_FULL_PATH__.dirName.dirName); + immutable dub = dubRoot.buildPath("bin", "dub"); + immutable testRoot = dubRoot.buildPath("test"); + immutable runUnittestRoot = testRoot.buildPath("run_unittest"); + + import std.stdio; + writefln("This script is deprecated. Call `dub --root %s` instead", runUnittestRoot); + import core.thread.osthread; + import core.time; + Thread.sleep(1.seconds); + + const cmd = [ + dub, + "run", + "--root=run_unittest", + "--", + "-j1", + ] + ~ args[1 .. $]; + + chdir(testRoot); + return spawnProcess(cmd).wait; } diff --git a/test/run-unittest.sh b/test/run-unittest.sh index 5ef1c1c6d8..22c57406aa 100755 --- a/test/run-unittest.sh +++ b/test/run-unittest.sh @@ -1,88 +1,6 @@ #!/usr/bin/env bash -set -ueo pipefail -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -> $(dirname "${BASH_SOURCE[0]}")/test.log - -function log() { - echo -e "\033[0;33m[INFO] $@\033[0m" - echo "[INFO] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log -} - -function logError() { - echo -e 1>&2 "\033[0;31m[ERROR] $@\033[0m" - echo "[ERROR] $@" >> $(dirname "${BASH_SOURCE[0]}")/test.log - any_errors=1 -} - -function die() { - logError "$@" - exit 1 -} - -export -f log -export -f die - -if [ -z ${DUB:-} ]; then - die $LINENO 'Variable $DUB must be defined to run the tests.' -fi - -if [ -z ${DC:-} ]; then - log '$DC not defined, assuming dmd...' - DC=dmd -fi - -DC_BIN=$(basename "$DC") -CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -FRONTEND="${FRONTEND:-}" - -if [ -z ${FRONTEND:-} ]; then - if [ "$DC_BIN" == "ldc2" ]; then - FRONTEND=$(ldc2 --version | grep 'based on DMD v2.' | sed -E -n 's/^.*DMD v(2\.[0-9]+\.[0-9]).*$/\1/p') - fi - if [ "$DC_BIN" == "dmd" ]; then - FRONTEND=$(dmd --version | grep 'D Compiler v2.' | sed -E -n 's/^.*D Compiler v(2\.[0-9]+\.[0-9]).*$/\1/p') - fi -fi - -echo "Running unittests with $DC_BIN (frontend=$FRONTEND)" - -if [ "$#" -gt 0 ]; then FILTER=$1; else FILTER=".*"; fi - -for pack in $(ls -d $CURR_DIR/*/); do - if [[ ! "$pack" =~ $FILTER ]]; then continue; fi - if [ -f $pack/.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $pack/.min_frontend) ]; then continue; fi - - # First we build the packages - if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_build_$DC_BIN ]; then # For sourceLibrary - build=1 - if [ -e $pack/.fail_build ]; then - log "Building $pack, expected failure..." - $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=$DC || logError "Build failure." - fi - else - build=0 - fi - - # We run the ones that are supposed to be run - if [ $build -eq 1 ] && [ ! -e $pack/.no_run ] && [ ! -e $pack/.no_run_$DC_BIN ]; then - log "Running $pack..." - $DUB run --force --root=$pack --compiler=$DC || logError "Run failure." - fi - - # Finally, the unittest part - if [ $build -eq 1 ] && [ ! -e $pack/.no_test ] && [ ! -e $pack/.no_test_$DC_BIN ]; then - log "Testing $pack..." - $DUB test --force --root=$pack --compiler=$DC || logError "Test failure." - fi -done - -echo -echo 'Testing summary:' -cat $(dirname "${BASH_SOURCE[0]}")/test.log - -exit ${any_errors:-0} +cd "$(dirname "${0}")" +echo "This script is deprecated. Call \`dub --root ${PWD}/run_unittest\` instead" +sleep 1 +exec "${DUB:-../bin/dub}" run --root=run_unittest -- -j1 "${@}" diff --git a/test/run_unittest/dub.json b/test/run_unittest/dub.json new file mode 100644 index 0000000000..0832001c31 --- /dev/null +++ b/test/run_unittest/dub.json @@ -0,0 +1,5 @@ +{ + "description": "Dub test runner", + "license": "MIT", + "name": "run_unittest" +} diff --git a/test/run_unittest/source/app.d b/test/run_unittest/source/app.d new file mode 100644 index 0000000000..e22bba7e70 --- /dev/null +++ b/test/run_unittest/source/app.d @@ -0,0 +1,48 @@ +module app; + +import run_unittest.log; +import run_unittest.runner; + +import std.file; +import std.getopt; +import std.stdio; +import std.path; + +int main(string[] args) { + bool verbose; + bool color; + int jobs; + version(Posix) + color = true; + + auto help = getopt(args, + "v|verbose", &verbose, + "color", &color, + "j|jobs", &jobs, + ); + if (help.helpWanted) { + defaultGetoptPrinter(`run_unittest [-v|--verbose] [--color] [-j|--jobs] [...] + + are shell globs matching directory names under test/ +`, help.options); + return 0; + } + + auto testDir = __FILE_FULL_PATH__.dirName.dirName.dirName; + chdir(testDir); + + ErrorSink sink; + { + ErrorSink fileSink = new FileSink("test.log"); + ErrorSink consoleSink = new ConsoleSink(color); + if (!verbose) + consoleSink = new NonVerboseSink(consoleSink); + sink = new GroupSink(fileSink, consoleSink); + } + auto config = generateRunnerConfig(sink); + config.color = color; + config.jobs = jobs; + + auto runner = Runner(config, sink); + return runner.run(args[1 .. $]); +} diff --git a/test/run_unittest/source/run_unittest/log.d b/test/run_unittest/source/run_unittest/log.d new file mode 100644 index 0000000000..fc6c9b516f --- /dev/null +++ b/test/run_unittest/source/run_unittest/log.d @@ -0,0 +1,197 @@ +module run_unittest.log; + +import std.conv; +import std.format; +import std.stdio; + +enum Severity { + Info, + Warning, + Error, + Status, +} + +string getName(Severity severity) { + final switch (severity) { + case Severity.Warning: + return "WARN"; + case Severity.Info: + return "INFO"; + case Severity.Error: + return "ERROR"; + case Severity.Status: + return "STAT"; + } +} + +abstract class ErrorSink { + void info (const(char)[] msg) { + log(Severity.Info, msg); + } + void warn (const(char)[] msg) { + log(Severity.Warning, msg); + } + void error (const(char)[] msg) { + log(Severity.Error, msg); + } + void status (const(char)[] msg) { + log(Severity.Status, msg); + } + + void info (Args...) (Args args) { + log(Severity.Info, text(args)); + } + void warn (Args...) (Args args) { + log(Severity.Warning, text(args)); + } + void error (Args...) (Args args) { + log(Severity.Error, text(args)); + } + void status (Args...) (Args args) { + log(Severity.Status, text(args)); + } + + abstract void log(Severity severity, const(char)[] msg); + void log (Args...) (Severity severity, Args args) { + log(severity, text(args)); + } +} + +class ConsoleSink : ErrorSink { + this(bool useColor) { + this.useColor = useColor; + } + + override void log (Severity severity, const(char)[] msg) { + immutable preamble = severity.getName; + immutable color = getColor(severity); + + immutable colorBegin = useColor ? "\033[0;" ~ color ~ "m" : ""; + immutable colorEnd = useColor ? "\033[0;m" : ""; + immutable str = format("%s[%5s]:%s %s", colorBegin, preamble, colorEnd, msg); + + stderr.writeln(str); + stderr.flush(); + } + +private: + bool useColor; + + enum AnsiColor { + Red = "31", + Green = "32", + Yellow = "33", + } + + string getColor(Severity severity) { + final switch (severity) { + case Severity.Warning: + return AnsiColor.Yellow; + case Severity.Info: + return AnsiColor.Green; + case Severity.Error: + return AnsiColor.Red; + case Severity.Status: + return AnsiColor.Green; + } + } +} + +class FileSink : ErrorSink { + this(string logFile) { + this.logFile = File(logFile, "w"); + } + + override void log (Severity severity, const(char)[] msg) { + immutable preamble = severity.getName; + immutable str = format("[%5s]: %s", preamble, msg); + logFile.writeln(str); + } + +private: + File logFile; +} + +class GroupSink : ErrorSink { + this (ErrorSink[] sinks...) { + this.sinks = sinks.dup; + } + + override void log (Severity severity, const(char)[] msg) { + foreach (sink; sinks) + sink.log(severity, msg); + } + +private: + ErrorSink[] sinks; +} + +class TestCaseSink : ErrorSink { + ErrorSink proxy; + string tc; + this(ErrorSink proxy, string testCase) { + this.proxy = proxy; + tc = testCase; + } + + override void log(Severity severity, const(char)[] msg) { + proxy.log(severity, tc, ": ", msg); + } +} + +class CaptureErrorSink : ErrorSink { + const(char)[][][Severity] capturedMessages; + + override void log (Severity severity, const(char)[] msg) { + capturedMessages[severity] ~= msg; + } + + override string toString() const { + import std.conv; + return text(capturedMessages); + } + + bool empty() { + int result = 0; + foreach (value; capturedMessages) + result += value.length; + return result == 0; + } + void clear() { + foreach (ref value; capturedMessages) value = []; + } + + const(char)[][] errors () { + return capturedMessages[Severity.Error]; + } + const(char)[] errorsBlock () { + return block(Severity.Error); + } + const(char)[] warningsBlock () { + return block(Severity.Warning); + } + const(char)[] infosBlock () { + return block(Severity.Info); + } + const(char)[] statusBlock () { + return block(Severity.Status); + } + +private: + const(char)[] block(Severity severity) { + import std.array; + return capturedMessages.get(severity, []).join(" "); + } +} + +class NonVerboseSink : ErrorSink { + public ErrorSink sink; + this(ErrorSink sink) { + this.sink = sink; + } + + override void log(Severity severity, const(char)[] msg) { + if (severity == Severity.Info) return; + sink.log(severity, msg); + } +} diff --git a/test/run_unittest/source/run_unittest/runner/config.d b/test/run_unittest/source/run_unittest/runner/config.d new file mode 100644 index 0000000000..03e73eb1ce --- /dev/null +++ b/test/run_unittest/source/run_unittest/runner/config.d @@ -0,0 +1,185 @@ +module run_unittest.runner.config; + +import run_unittest.test_config; +import run_unittest.log; + +import core.sync.mutex; +import std.algorithm; + +struct RunnerConfig { + Os os; + DcBackend dc_backend; + FeVersion dlang_fe_version; + + string dubPath; + string dc; + bool color; + int jobs; +} + +RunnerConfig generateRunnerConfig(ErrorSink sink) { + import std.process; + + RunnerConfig config; + + version(linux) config.os = Os.linux; + else version(Windows) config.os = Os.windows; + else version(OSX) config.os = Os.osx; + else static assert(false, "Unknown target OS"); + + version(DigitalMars) config.dc_backend = DcBackend.dmd; + else version(LDC) config.dc_backend = DcBackend.ldc; + else version(GNU) config.dc_backend = DcBackend.gdc; + else static assert(false, "Unknown compiler"); + { + auto envDc = environment.get("DC"); + if (envDc.length == 0) { + sink.warn("The DC environment is empty. Defaulting to dmd"); + envDc = "dmd"; + } + + handleEnvironmentDc(envDc, config.dc_backend, sink); + config.dc = envDc; + } + + import std.format; + config.dlang_fe_version = __VERSION__; + { + const envFe = environment.get("FRONTEND"); + handleEnvironmentFrontend(envFe, sink); + } + + import std.path; + immutable fallbackPath = buildNormalizedPath(absolutePath("../bin/dub")); + config.dubPath = environment.get("DUB", fallbackPath); + + return config; +} + + +private: + +void handleEnvironmentFrontend(string envFe, ErrorSink errorSink) { + if (envFe.length == 0) return; + + errorSink.warn("The FRONTEND environment variable is ignored and this script will compute it by itself"); + errorSink.warn("You can safely remove the variable from the environment"); +} + +unittest { + auto sink = new CaptureErrorSink(); + handleEnvironmentFrontend(null, sink); + assert(sink.empty()); +} + +unittest { + auto sink = new CaptureErrorSink(); + handleEnvironmentFrontend("", sink); + assert(sink.empty()); +} + +unittest { + auto sink = new CaptureErrorSink(); + handleEnvironmentFrontend("2109", sink); + assert(!sink.empty()); + assert(sink.warningsBlock.canFind("FRONTEND")); +} + +void handleEnvironmentDc(string envDc, DcBackend thisDc, ErrorSink sink) { + import std.path; + + const dcBasename = baseName(envDc); + DcBackend dcBackendGuess; + if (dcBasename.canFind("gdmd")) + dcBackendGuess = DcBackend.gdc; + else if (dcBasename.canFind("gdc")) { + sink.error("Running the testsuite with plain gdc is not supported."); + sink.error("Please use (an up-to-date) gdmd instead."); + throw new Exception("gdc is not supported. Use gdmd"); + } else if (dcBasename.canFind("ldc", "ldmd")) + dcBackendGuess = DcBackend.ldc; + else if (dcBasename.canFind("dmd")) + dcBackendGuess = DcBackend.dmd; + else { + // Dub will fail as well with this + throw new Exception("DC environment variable(" ~ envDc ~ ") does not seem to be a D compiler"); + } + + if (dcBackendGuess != thisDc) { + sink.error("The DC environment is not the same backend as the D compiler"); + sink.error("used to build this script: ", dcBackendGuess, " vs ", thisDc, '.'); + sink.error("If you invoke this script manually make sure you compile this"); + sink.error("script with the same compiler that you will run the tests with."); + + throw new Exception("$DC is not the same compiler as the one used to build this script"); + } +} + +CaptureErrorSink successfullDcTestCase(string env, DcBackend backend) { + auto sink = new CaptureErrorSink(); + try { + handleEnvironmentDc(env, backend, sink); + } catch (Exception e) { + assert(false, sink.toString()); + } + return sink; +} + +CaptureErrorSink unsuccessfullDcTestCase(string env, DcBackend backend) { + auto sink = new CaptureErrorSink(); + try { + handleEnvironmentDc(env, backend, sink); + } catch (Exception e) { + return sink; + } + assert(false, "handleEnvironemntDc did not fail as expected"); +} + +unittest { + auto sink = successfullDcTestCase("/usr/bin/dmd", DcBackend.dmd); + assert(sink.empty, sink.toString); +} +unittest { + auto sink = successfullDcTestCase("dmd", DcBackend.dmd); + assert(sink.empty); +} + +unittest { + successfullDcTestCase("/usr/bin/dmd-2.109", DcBackend.dmd); +} +unittest { + successfullDcTestCase("dmd-2.111", DcBackend.dmd); +} +unittest { + successfullDcTestCase("/bin/gdmd", DcBackend.gdc); +} +unittest { + successfullDcTestCase("x86_64-pc-linux-gnu-gdmd-15", DcBackend.gdc); +} +unittest { + successfullDcTestCase("ldc2", DcBackend.ldc); +} +unittest { + successfullDcTestCase("/usr/local/bin/ldc", DcBackend.ldc); +} +unittest { + successfullDcTestCase("ldmd2-1.37", DcBackend.ldc); +} + +unittest { + unsuccessfullDcTestCase("/usr/bin/true", DcBackend.dmd); +} + +unittest { + auto sink = unsuccessfullDcTestCase("dmd", DcBackend.gdc); + assert(sink.errorsBlock.canFind("dmd")); + assert(sink.errorsBlock.canFind("gdc")); + + assert(sink.errorsBlock.canFind("compile this script with the same compiler")); +} + +unittest { + auto sink = unsuccessfullDcTestCase("gdc-11", DcBackend.gdc); + assert(sink.errorsBlock.canFind("gdc")); + assert(sink.errorsBlock.canFind("gdmd")); +} diff --git a/test/run_unittest/source/run_unittest/runner/individual.d b/test/run_unittest/source/run_unittest/runner/individual.d new file mode 100644 index 0000000000..128187d7c1 --- /dev/null +++ b/test/run_unittest/source/run_unittest/runner/individual.d @@ -0,0 +1,260 @@ +module run_unittest.runner.individual; + +import run_unittest.log; +import run_unittest.runner; +import run_unittest.test_config; + +import std.algorithm; +import std.file; +import std.format; +import std.path; +import std.process; + +struct TestCaseRunner { + string tc; + ErrorSink sink; + Runner runner; + void delegate() testResultAction = null; + + void run() { + initConfig(); + ensureTestCanRun(); + + runner.acquireLocks(testConfig); + scope(exit) runner.releaseLocks(testConfig); + + scope(success) endTest(); + if (testConfig.dub_command.length != 0) { + foreach (dubConfig; ["dub.sdl", "dub.json", "package.json"]) + if (exists(buildPath(tc, dubConfig))) { + runDubTestCase(); + return; + } + } + } + +private: + TestConfig testConfig; + + void ensureTestCanRun() { + import std.array; + import std.format; + + string reason; + static foreach (member; ["dc_backend", "os"]) {{ + const testArray = __traits(getMember, testConfig, member); + const myValue = __traits(getMember, runner.config, member); + + if (testArray.length && !testArray.canFind(myValue)) { + reason = format("our %s (%s) is not in %s", member, myValue, testArray); + } + }} + + if (testConfig.dlang_fe_version_min != 0 + && testConfig.dlang_fe_version_min > runner.config.dlang_fe_version) + reason = format("our frontend version (%s) is lower than the minimum %s", + runner.config.dlang_fe_version, testConfig.dlang_fe_version_min); + + if (reason) + skipTest(reason); + } + + unittest { + import std.exception; + + auto sink = new CaptureErrorSink(); + TestCaseRunner tcr = TestCaseRunner("foo", sink, Runner()); + + tcr.runner.config.dc_backend = DcBackend.dmd; + tcr.runner.config.os = Os.linux; + tcr.testConfig.dc_backend = [ DcBackend.dmd ]; + tcr.testConfig.os = [ Os.linux ]; + + tcr.ensureTestCanRun(); + + tcr.testConfig.dc_backend = [ DcBackend.gdc, DcBackend.ldc, DcBackend.dmd]; + tcr.ensureTestCanRun(); + + tcr.testConfig.dc_backend = [ DcBackend.gdc, DcBackend.ldc ]; + assertThrown!TCSkip(tcr.ensureTestCanRun()); + assert(sink.statusBlock.canFind("dmd")); + assert(sink.statusBlock.canFind("dc_backend")); + sink.clear(); + + tcr.testConfig.dc_backend = [ DcBackend.dmd ]; + tcr.testConfig.os = [ Os.windows ]; + assertThrown!TCSkip(tcr.ensureTestCanRun()); + assert(sink.statusBlock.canFind("linux"), sink.toString()); + assert(sink.statusBlock.canFind("os")); + assert(sink.statusBlock.canFind("windows")); + sink.clear; + + tcr.testConfig.os = [ Os.linux ]; + tcr.testConfig.dlang_fe_version_min = 2100; + tcr.runner.config.dlang_fe_version = 2105; + tcr.ensureTestCanRun(); + + tcr.testConfig.dlang_fe_version_min = 2110; + assertThrown!TCSkip(tcr.ensureTestCanRun()); + assert(sink.statusBlock.canFind("2110")); + assert(sink.statusBlock.canFind("2105")); + sink.clear(); + } + + void initConfig() { + immutable testConfigPath = buildPath(tc, "test.config"); + if (testConfigPath.exists) { + immutable testConfigContents = readText(testConfigPath); + try + testConfig = parseConfig(testConfigContents, sink); + catch (Exception e) + failTest("Could not load test.config:", e); + } + + testConfig.locks ~= tc; + } + + void runDubTestCase() + in(testConfig.dub_command.length != 0) + { + foreach (cmd; getDubCmds()) { + auto env = [ + "DUB": runner.config.dubPath, + "DC": runner.config.dc, + "CURR_DIR": getcwd(), + ]; + immutable redirect = Redirect.stdout | Redirect.stderrToStdout; + + beginTest(cmd); + auto pipes = pipeProcess(cmd, redirect, env, Config.none, tc); + scope(exit) pipes.pid.wait; + + foreach (line; pipes.stdout.byLine) + passthrough(line); + + // Handle possible skips or explicit failures + if (testResultAction) + testResultAction(); + + immutable exitStatus = pipes.pid.wait; + if (testConfig.expect_nonzero) { + if (exitStatus == 0) + failTest("Expected non-0 exit status"); + } else + if (exitStatus != 0) + failTest("Expected 0 exit status"); + } + } + + string[][] getDubCmds() { + string[][] result; + foreach (dub_command; testConfig.dub_command) { + string dubVerb; + sw: final switch (dub_command) { + static foreach (member; __traits(allMembers, DubCommand)) { + case __traits(getMember, DubCommand, member): + dubVerb = member; + break sw; + } + } + + auto now = [runner.config.dubPath, dubVerb, "--force"]; + now ~= ["--color", runner.config.color ? "always" : "never"]; + if (testConfig.dub_build_type !is null) + now ~= ["--build", testConfig.dub_build_type]; + now ~= testConfig.extra_dub_args; + result ~= now; + } + return result; + } + + unittest { + auto tcr = TestCaseRunner(); + tcr.runner.config.dubPath = "dub"; + tcr.runner.config.color = true; + tcr.testConfig.dub_command = [ DubCommand.build ]; + import std.stdio; + assert(tcr.getDubCmds == [ ["dub", "build", "--force", "--color", "always"] ]); + } + + unittest { + auto tcr = TestCaseRunner(); + tcr.runner.config.dubPath = "dub"; + tcr.runner.config.color = false; + tcr.testConfig.dub_command = [ DubCommand.build, DubCommand.test ]; + assert(tcr.getDubCmds == [ + ["dub", "build", "--force", "--color", "never"], + ["dub", "test", "--force", "--color", "never"], + ]); + } + + unittest { + auto tcr = TestCaseRunner(); + tcr.runner.config.dubPath = "dub"; + tcr.runner.config.color = false; + tcr.testConfig.dub_command = [ DubCommand.run ]; + tcr.testConfig.extra_dub_args = [ "--", "--switch" ]; + assert(tcr.getDubCmds == [ + ["dub", "run", "--force", "--color", "never", "--", "--switch"], + ]); + } + + void passthrough(const(char)[] logLine) { + import std.typecons; + import std.string; + alias Tup = Tuple!(string, void delegate(const(char)[])); + auto actions = [ + Tup("ERROR", &sink.error), + Tup("INFO", &sink.info), + Tup("FAIL", (line) { + immutable cpy = line.idup; + testResultAction = () => failTest(cpy); + }), + Tup("SKIP", (line) { + immutable cpy = line.idup; + testResultAction = () => skipTest(cpy); + }), + ]; + + foreach (tup; actions) { + immutable match = "[" ~ tup[0] ~ "]: "; + if (logLine.startsWith(match)) { + const rest = logLine[match.length .. $]; + tup[1](rest); + return; + } + } + sink.info(logLine); + } + + void beginTest(const string[] cmd) { + import std.array; + sink.status("starting: ", cmd.join(" ")); + } + void endTest() { + sink.status("success"); + } + noreturn failTest(const(char)[] reason, in Throwable exception = null) { + sink.error("failed because: ", reason); + + if (exception) { + import std.conv; + sink.error("Error context:"); + foreach (trace; exception.info) + sink.error(trace); + } + + throw new TCFailure(); + } + noreturn skipTest(const(char)[] reason) { + sink.status("skipped because ", reason); + throw new TCSkip(); + } +} + + +class TestResult : Exception { + this() { super(""); } +} +class TCFailure : TestResult {} +class TCSkip : TestResult {} diff --git a/test/run_unittest/source/run_unittest/runner/package.d b/test/run_unittest/source/run_unittest/runner/package.d new file mode 100644 index 0000000000..43a607af87 --- /dev/null +++ b/test/run_unittest/source/run_unittest/runner/package.d @@ -0,0 +1,4 @@ +module run_unittest.runner; + +public import run_unittest.runner.runner; +public import run_unittest.runner.config; diff --git a/test/run_unittest/source/run_unittest/runner/runner.d b/test/run_unittest/source/run_unittest/runner/runner.d new file mode 100644 index 0000000000..bb79845321 --- /dev/null +++ b/test/run_unittest/source/run_unittest/runner/runner.d @@ -0,0 +1,148 @@ +module run_unittest.runner.runner; + +import run_unittest.test_config; +import run_unittest.runner.config; +import run_unittest.runner.individual; +import run_unittest.log; + +import core.sync.rwmutex; +import core.sync.mutex; +import core.atomic; +import std.array; +import std.algorithm; +import std.file; +import std.format; +import std.path; + +struct Runner { + RunnerConfig config; + ErrorSink sink; + + shared int skippedTests; + shared int failedTests; + shared int successfulTests; + int totalTests () { + return skippedTests.atomicLoad + failedTests.atomicLoad + successfulTests.atomicLoad; + } + + this(RunnerConfig config, ErrorSink sink) { + this.config = config; + this.sink = sink; + + // Get around issue https://github.com/dlang/dmd/issues/17955 + // with older compilers + //locks = new typeof(locks); + locks[""] = null; + locksMutex = new typeof(locksMutex); + lockExclusive = new typeof(lockExclusive); + } + + int run (string[] patterns) { + if (config.dc_backend == DcBackend.gdc) { + import std.process; + if ("DFLAGS" !in environment) { + immutable defaultFlags = "-q,-Wno-error -allinst"; + sink.info("Adding ", defaultFlags, " to DFLAGS because gdmd will fail some tests without them"); + environment["DFLAGS"] = defaultFlags; + } + } + + const testCases = dirEntries(".", SpanMode.shallow) + .filter!`a.isDir` + .filter!(a => !canFind(["extra", "common", "run_unittest"], a.baseName)) + .filter!(entry => entry.name.matches(patterns)) + .map!(a => a.name.baseName) + .array; + + void runTc(string tc) { + auto tcSink = new TestCaseSink(sink, tc); + auto tcRunner = TestCaseRunner(tc, tcSink, this); + try { + tcRunner.run(); + successfulTests.atomicOp!"+="(1); + } catch (TCFailure) { + failedTests.atomicOp!"+="(1); + } catch (TCSkip) { + skippedTests.atomicOp!"+="(1); + } catch (Exception e) { + tcSink.error("Unexpected exception was thrown: ", e); + failedTests.atomicOp!"+="(1); + } + } + + import std.parallelism; + if (config.jobs != 0) + defaultPoolThreads = config.jobs - 1; + foreach (tc; testCases.parallel) + runTc(tc); + + if (totalTests == 0) { + sink.error("No tests that match your search were found"); + throw new Exception("No tests were run"); + } + + sink.status(format("Summary %s total: %s successful %s failed and %s skipped", + totalTests, successfulTests.atomicLoad, failedTests.atomicLoad, skippedTests.atomicLoad)); + return failedTests != 0; + } + + void acquireLocks (const TestConfig testConfig) { + if (testConfig.must_be_run_alone) { + lockExclusive.writer.lock(); + return; + } + + lockExclusive.reader.lock(); + + const orderedKeys = testConfig.locks.dup.sort.release; + auto ourLocks = new shared(Mutex)[](orderedKeys.length); + + onLocks((locks) { + foreach (i, key; orderedKeys) + ourLocks[i].atomicStore(cast(shared)locks.require(key, new Mutex())); + }); + + foreach (i; 0 .. ourLocks.length) + ourLocks[i].lock; + } + + void releaseLocks (const TestConfig testConfig) { + if (testConfig.must_be_run_alone) { + lockExclusive.writer.unlock(); + return; + } + lockExclusive.reader.unlock(); + + onLocks((locks) { + testConfig.locks.each!(key => locks[key].unlock); + }); + } +private: + shared ReadWriteMutex lockExclusive; + shared Mutex[string] locks; + void onLocks(void delegate(Mutex[string] unsharedLocks) action) { + locksMutex.lock; + scope(exit) locksMutex.unlock; + action(cast(Mutex[string])locks); + } + + shared Mutex locksMutex; +} + +private: + +bool matches(string dir, string[] patterns) { + if (patterns.length == 0) return true; + + foreach (pat; patterns) + if (globMatch(baseName(dir), pat)) return true; + return false; +} + +unittest { + assert(matches("./foo", [])); + assert(matches("./foo", ["foo"])); + assert(matches("./foo", ["f*"])); + assert(!matches("./foo", ["bar"])); + assert(matches("./foo", ["b", "f*"])); +} diff --git a/test/run_unittest/source/run_unittest/test_config.d b/test/run_unittest/source/run_unittest/test_config.d new file mode 100644 index 0000000000..510dcad67f --- /dev/null +++ b/test/run_unittest/source/run_unittest/test_config.d @@ -0,0 +1,354 @@ +module run_unittest.test_config; + +import run_unittest.log; + +import std.algorithm; +import std.array; +import std.conv; +import std.string; + +enum Os { + linux, + windows, + osx, +} + +enum DcBackend { + gdc, + dmd, + ldc, +} + +enum DubCommand { + run, + test, + build, + none, +} + +struct FeVersion { + int value; + alias value this; +} + +struct TestConfig { + Os[] os; + DcBackend[] dc_backend; + FeVersion dlang_fe_version_min; + DubCommand[] dub_command = [ DubCommand.run ]; + string dub_config = null; + string dub_build_type = null; + string[] locks; + bool expect_nonzero = false; + + string[] extra_dub_args; + bool must_be_run_alone = false; +} + +TestConfig parseConfig(string content, ErrorSink errorSink) { + TestConfig result; + + bool any_errors = false; + foreach (line; content.lineSplitter) { + line = line.strip(); + if (line.empty) continue; + if (line[0] == '#') continue; + + const split = line.findSplit("="); + if (!split[1].length) { + errorSink.warn("Malformed config line '", line, "'. Missing ="); + continue; + } + + const key = split[0].strip(); + const value = split[2]; + + sw: switch (key) { + static foreach (idx, _; TestConfig.tupleof) { + case TestConfig.tupleof[idx].stringof: + if (!handle(result.tupleof[idx], key, value, errorSink)) + any_errors = true; + break sw; + } + default: + errorSink.error("Setting ", key, " is not recognized.", + " Available settings are: ", + join([__traits(allMembers, TestConfig)], ", ")); + any_errors = true; + break; + } + } + + if (any_errors) + throw new Exception("Config file is not in the correct format"); + + return result; +} + + +private: + +bool handle(T)(ref T field, string memberName, string value, ErrorSink errorSink) + if (is(T == string) || !is(T: V[], V)) +{ + value = value.strip(); + try { + alias TgtType = TargetType!T; + field = to!TgtType(value); + } catch (ConvException e) { + + errorSink.error("Setting ", memberName, " does not recognize value ", value, + ". Possible values are: ", PossibleValues!T); + return false; + } + + static if (is(T == FeVersion)) { + if (field < 2000 || field >= 3000) { + errorSink.error("The value ", value, " for setting ", memberName, " does not respect the format ", PossibleValues!T); + return false; + } + } + return true; +} + +bool handle(T)(ref T[] field, string memberName, string value, ErrorSink errorSink) +if (!is(immutable T == immutable char)) +{ + value = value.strip(); + if ((value[0] != '[') ^ (value[$ - 1] != ']')) { + errorSink.error("Setting ", memberName, " missmatch of [ and ]"); + return false; + } + + string[] values; + if (value[0] == '[') { + assert(value[$ - 1] == ']'); + value = value[1 .. $ - 1]; + values = value.split(','); + } else { + values = [ value ]; + } + + bool any_errors = false; + field = []; + foreach (singleValue; values) { + T thisValue; + if (!handle(thisValue, memberName, singleValue, errorSink)) { + any_errors = true; + continue; + } + field ~= thisValue; + } + + return !any_errors; +} + +template PossibleValues (T) { + static if (is(T == FeVersion)) { + enum PossibleValues = "2XXX"; + } else static if (is(T == string)) { + enum PossibleValues = ""; + } else static if (is(T == bool)) { + enum PossibleValues = "true or false"; + } else { + enum PossibleValues = (){ + string result; + alias members = __traits(allMembers, T); + + result ~= members[0]; + foreach(member; members[1..$]) { + result ~= ", "; + result ~= member; + } + + return result; + }(); + } +} + +template TargetType (T) { + static if (__traits(isScalar, T)) + alias TargetType = T; + else static if (is(T == FeVersion)) + alias TargetType = int; + else static if (is(T == string)) + alias TargetType = T; + else + static assert(false, "Unknown type " ~ T.stringof); +} + + +void parseSuccess(out TestConfig config, out CaptureErrorSink sink, string content) { + sink = new CaptureErrorSink(); + try { + config = parseConfig(content, sink); + } catch (Exception e) { + assert(false, "Parsing failed with error messages: " ~ sink.toString()); + } +} + +void parseFailure(out CaptureErrorSink sink, string content) { + sink = new CaptureErrorSink(); + try { + const _ = parseConfig(content, sink); + } catch (Exception e) { + return; + } + assert(false, "Parsing did not fail as expected"); +} + +unittest { + TestConfig config; + CaptureErrorSink sink; + parseSuccess(config, sink, ` + dub_command = test + os = [ linux,windows, osx] + dc_backend = [dmd, gdc,ldc] + dub_config = cappy-barry + + dlang_fe_version_min = 2108 + # A comment + # and one with spaces + locks=[XX,YY] + + dub_build_type = foo + + expect_nonzero = true + extra_dub_args = [ -f, -b ] + + must_be_run_alone = true + `); + + assert(config.dc_backend == [DcBackend.dmd, DcBackend.gdc, DcBackend.ldc]); + assert(config.os == [Os.linux, Os.windows, Os.osx]); + assert(config.dub_command == [ DubCommand.test ]); + assert(config.dlang_fe_version_min == 2108); + assert(config.dub_config == "cappy-barry"); + assert(config.locks == ["XX", "YY"]); + assert(config.dub_build_type == "foo"); + assert(config.expect_nonzero); + assert(config.extra_dub_args == ["-f", "-b"]); + assert(config.must_be_run_alone); + assert(sink.empty); +} + +unittest { + TestConfig config; + CaptureErrorSink sink; + parseSuccess(config, sink, ` +dub_command = build + +dc_backend = [gdc] +`); + + assert(config.dc_backend == [DcBackend.gdc]); + assert(config.dub_command == [ DubCommand.build ]); + assert(config.os == []); + assert(config.dlang_fe_version_min == 0); + assert(sink.empty); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dub_command = foo_bar_baz`); + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("dub_command")); + assert(sink.errors[0].canFind("foo_bar_baz")); + + assert(sink.errors[0].canFind("run")); + assert(sink.errors[0].canFind("build")); + assert(sink.errors[0].canFind("test")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `strace = [boo]`); + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("strace")); + + assert(sink.errors[0].canFind("dub_command")); + assert(sink.errors[0].canFind("dlang_fe_version_min")); + assert(sink.errors[0].canFind("os")); + assert(sink.errors[0].canFind("dc_backend")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `os = linux]`); + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("os")); +} + +unittest { + CaptureErrorSink sink; + TestConfig config; + parseSuccess(config, sink, `os = [linux, linux]`); + + assert(sink.empty); + assert(config.os == [Os.linux, Os.linux]); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dc_backend = [gdmd]`); + + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("dc_backend")); + assert(sink.errors[0].canFind("gdmd")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dc_backend = [ldmd2, gdmd, ldc2]`); + + assert(sink.errors.length == 3); + assert(sink.errors[0].canFind("dc_backend")); + assert(sink.errors[0].canFind("ldmd2")); + assert(sink.errors[1].canFind("dc_backend")); + assert(sink.errors[1].canFind("gdmd")); + assert(sink.errors[2].canFind("dc_backend")); + assert(sink.errors[2].canFind("ldc2")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dlang_fe_version_min = 2.109`); + + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("2.109")); + assert(sink.errors[0].canFind("2XXX")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dlang_fe_version_min = 2.foo`); + + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("2.foo")); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `dlang_fe_version_min = garbage`); + + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("garbage")); +} + +unittest { + TestConfig config; + CaptureErrorSink sink; + parseSuccess(config, sink, `dub_command = [build, test]`); + + assert(config.dub_command == [DubCommand.build, DubCommand.test]); +} + +unittest { + CaptureErrorSink sink; + parseFailure(sink, `expect_nonzero = 1`); + + assert(sink.errors.length == 1); + assert(sink.errors[0].canFind("1")); + assert(sink.errors[0].canFind("true")); + assert(sink.errors[0].canFind("false")); +} diff --git a/test/sdl-package-simple/dub.sdl b/test/sdl-package-simple/dub.sdl index 78d50b6177..f128ab18b7 100644 --- a/test/sdl-package-simple/dub.sdl +++ b/test/sdl-package-simple/dub.sdl @@ -1,2 +1,2 @@ -name "exec-simple"; +name "sdl-package-simple"; targetType "executable"; diff --git a/test/single-file-sdl-default-name.sh b/test/single-file-sdl-default-name.sh deleted file mode 100755 index ab2ba8b2cc..0000000000 --- a/test/single-file-sdl-default-name.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e -cd ${CURR_DIR} -rm -f single-file-sdl-default-name - -${DUB} run --single single-file-sdl-default-name.d --compiler=${DC} -if [ ! -f single-file-sdl-default-name ]; then - echo "Normal invocation did not produce a binary in the current directory" - exit 1 -fi -rm single-file-sdl-default-name diff --git a/test/single-file-sdl-default-name/.gitignore b/test/single-file-sdl-default-name/.gitignore new file mode 100644 index 0000000000..82099977c4 --- /dev/null +++ b/test/single-file-sdl-default-name/.gitignore @@ -0,0 +1 @@ +!/single-file-sdl-default-name-sample.d \ No newline at end of file diff --git a/test/single-file-sdl-default-name/dub.json b/test/single-file-sdl-default-name/dub.json new file mode 100644 index 0000000000..7e822af42a --- /dev/null +++ b/test/single-file-sdl-default-name/dub.json @@ -0,0 +1,8 @@ +{ + "name": "single-file-sdl-default-name", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/single-file-sdl-default-name.d b/test/single-file-sdl-default-name/single-file-sdl-default-name-sample.d similarity index 58% rename from test/single-file-sdl-default-name.d rename to test/single-file-sdl-default-name/single-file-sdl-default-name-sample.d index e7e7befa1a..22891a33ce 100644 --- a/test/single-file-sdl-default-name.d +++ b/test/single-file-sdl-default-name/single-file-sdl-default-name-sample.d @@ -1,5 +1,5 @@ /++dub.sdl: -dependency "sourcelib-simple" path="1-sourceLib-simple" +dependency "sourcelib-simple" path="../extra/1-sourceLib-simple" +/ module single; diff --git a/test/single-file-sdl-default-name/source/app.d b/test/single-file-sdl-default-name/source/app.d new file mode 100644 index 0000000000..447b333450 --- /dev/null +++ b/test/single-file-sdl-default-name/source/app.d @@ -0,0 +1,19 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + immutable expectedPath = "single-file-sdl-default-name-sample" ~ DotExe; + if (exists(expectedPath)) remove(expectedPath); + + if (spawnProcess([dub, "run", "--single", "single-file-sdl-default-name-sample.d"]).wait != 0) + die("dub run failed"); + + if (!exists(expectedPath)) { + logError("Expected to find file: ", expectedPath); + die("Normal invocation did not produce a binary in the current directory"); + } +} diff --git a/test/subpackage-common-with-sourcefile-globbing.sh b/test/subpackage-common-with-sourcefile-globbing.sh deleted file mode 100755 index 1341acc0d4..0000000000 --- a/test/subpackage-common-with-sourcefile-globbing.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -cd ${CURR_DIR}/subpackage-common-with-sourcefile-globbing -rm -rf .dub dub.selections.json -${DUB} build --compiler=${DC} :server -v -${DUB} build --compiler=${DC} :client -v -${DUB} build --compiler=${DC} :common -v diff --git a/test/subpackage-common-with-sourcefile-globbing/.gitignore b/test/subpackage-common-with-sourcefile-globbing/.gitignore new file mode 100644 index 0000000000..f3ccceceb2 --- /dev/null +++ b/test/subpackage-common-with-sourcefile-globbing/.gitignore @@ -0,0 +1,5 @@ +/sample/** +!/sample/ +!/sample/dub.sdl +!/sample/code/ +!/sample/code/** diff --git a/test/subpackage-common-with-sourcefile-globbing/.no_build b/test/subpackage-common-with-sourcefile-globbing/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/subpackage-common-with-sourcefile-globbing/dub.json b/test/subpackage-common-with-sourcefile-globbing/dub.json new file mode 100644 index 0000000000..7f06dab666 --- /dev/null +++ b/test/subpackage-common-with-sourcefile-globbing/dub.json @@ -0,0 +1,8 @@ +{ + "name": "subpackage-common-with-sourcefile-globbing", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/subpackage-common-with-sourcefile-globbing/code/mypackage/client/app.d b/test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/client/app.d similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/code/mypackage/client/app.d rename to test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/client/app.d diff --git a/test/subpackage-common-with-sourcefile-globbing/code/mypackage/client/extra.d b/test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/client/extra.d similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/code/mypackage/client/extra.d rename to test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/client/extra.d diff --git a/test/subpackage-common-with-sourcefile-globbing/code/mypackage/common/blah.d b/test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/common/blah.d similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/code/mypackage/common/blah.d rename to test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/common/blah.d diff --git a/test/subpackage-common-with-sourcefile-globbing/code/mypackage/server/app.d b/test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/server/app.d similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/code/mypackage/server/app.d rename to test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/server/app.d diff --git a/test/subpackage-common-with-sourcefile-globbing/code/mypackage/server/extra.d b/test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/server/extra.d similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/code/mypackage/server/extra.d rename to test/subpackage-common-with-sourcefile-globbing/sample/code/mypackage/server/extra.d diff --git a/test/subpackage-common-with-sourcefile-globbing/dub.sdl b/test/subpackage-common-with-sourcefile-globbing/sample/dub.sdl similarity index 100% rename from test/subpackage-common-with-sourcefile-globbing/dub.sdl rename to test/subpackage-common-with-sourcefile-globbing/sample/dub.sdl diff --git a/test/subpackage-common-with-sourcefile-globbing/source/app.d b/test/subpackage-common-with-sourcefile-globbing/source/app.d new file mode 100644 index 0000000000..ea32e48533 --- /dev/null +++ b/test/subpackage-common-with-sourcefile-globbing/source/app.d @@ -0,0 +1,15 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + foreach (subpkg; ["server", "client", "common"]) { + if (spawnProcess([dub, "build", ":" ~ subpkg, "-v"]).wait != 0) + die("dub build :", subpkg, " failed"); + } +} diff --git a/test/subpackage-ref/dub.json b/test/subpackage-ref/dub.json index b840a09aa4..356130fc1c 100644 --- a/test/subpackage-ref/dub.json +++ b/test/subpackage-ref/dub.json @@ -1,7 +1,7 @@ { - "name": "test", + "name": "subpackage-ref", "dependencies": { - "test:subpack": "*" + "subpackage-ref:subpack": "*" }, "subPackages": [ { diff --git a/test/test-upgrade-subpackages.sh b/test/test-upgrade-subpackages.sh deleted file mode 100755 index 860e68681f..0000000000 --- a/test/test-upgrade-subpackages.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname ${BASH_SOURCE[0]})/common.sh - -PACK_PATH="$CURR_DIR"/path-subpackage-ref - -# make sure that there are no left-over selections files -rm -f $PACK_PATH/dub.selections.json $PACK_PATH/subpack/dub.selections.json - -# first upgrade only the root package -if ! ${DUB} upgrade --root $PACK_PATH; then - die $LINENO 'The upgrade command failed.' -fi -if [ ! -f $PACK_PATH/dub.selections.json ] || [ -f $PACK_PATH/subpack/dub.selections.json ]; then - die $LINENO 'The upgrade command did not generate the right set of dub.selections.json files.' -fi - -rm -f $PACK_PATH/dub.selections.json - -# now upgrade with all sub packages -if ! ${DUB} upgrade -s --root $PACK_PATH; then - die $LINENO 'The upgrade command failed with -s.' -fi -if [ ! -f $PACK_PATH/dub.selections.json ] || [ ! -f $PACK_PATH/subpack/dub.selections.json ]; then - die $LINENO 'The upgrade command did not generate all dub.selections.json files.' -fi - -# clean up -rm -f $PACK_PATH/dub.selections.json $PACK_PATH/subpack/dub.selections.json diff --git a/test/test-upgrade-subpackages/.gitignore b/test/test-upgrade-subpackages/.gitignore new file mode 100644 index 0000000000..0c7cb9839b --- /dev/null +++ b/test/test-upgrade-subpackages/.gitignore @@ -0,0 +1,9 @@ +/sample/** +!/sample/ +!/sample/dub.json +!/sample/source/ +!/sample/source/*.d +!/sample/subpack/ +!/sample/subpack/dub.json +!/sample/subpack/source/ +!/sample/subpack/source/*.d diff --git a/test/test-upgrade-subpackages/dub.json b/test/test-upgrade-subpackages/dub.json new file mode 100644 index 0000000000..ce37943747 --- /dev/null +++ b/test/test-upgrade-subpackages/dub.json @@ -0,0 +1,8 @@ +{ + "name": "test-upgrade-subpackages", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/test-upgrade-subpackages/sample/dub.json b/test/test-upgrade-subpackages/sample/dub.json new file mode 100644 index 0000000000..b5eee24382 --- /dev/null +++ b/test/test-upgrade-subpackages/sample/dub.json @@ -0,0 +1,9 @@ +{ + "name": "test-upgrade-subpackages-sample", + "dependencies": { + "test-upgrade-subpackages-sample:subpack": "*" + }, + "subPackages": [ + "subpack/" + ] +} diff --git a/test/test-upgrade-subpackages/sample/source/app.d b/test/test-upgrade-subpackages/sample/source/app.d new file mode 100644 index 0000000000..6dc0376637 --- /dev/null +++ b/test/test-upgrade-subpackages/sample/source/app.d @@ -0,0 +1,7 @@ +module app; +import lib; + +void main() +{ + libFunc(); +} diff --git a/test/test-upgrade-subpackages/sample/subpack/dub.json b/test/test-upgrade-subpackages/sample/subpack/dub.json new file mode 100644 index 0000000000..6c11e39985 --- /dev/null +++ b/test/test-upgrade-subpackages/sample/subpack/dub.json @@ -0,0 +1,8 @@ +{ + "name": "subpack", + "description": "A minimal D application.", + "copyright": "Copyright © 2014, sludwig", + "authors": ["sludwig"], + "dependencies": { + } +} diff --git a/test/test-upgrade-subpackages/sample/subpack/source/lib.d b/test/test-upgrade-subpackages/sample/subpack/source/lib.d new file mode 100644 index 0000000000..a49c81712f --- /dev/null +++ b/test/test-upgrade-subpackages/sample/subpack/source/lib.d @@ -0,0 +1,6 @@ +import std.stdio; + +void libFunc() +{ + writeln("Library function called."); +} diff --git a/test/test-upgrade-subpackages/source/app.d b/test/test-upgrade-subpackages/source/app.d new file mode 100644 index 0000000000..7796d77721 --- /dev/null +++ b/test/test-upgrade-subpackages/source/app.d @@ -0,0 +1,30 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + chdir("sample"); + + // make sure that there are no left-over selections files + foreach (file; ["dub.selections.json", "subpack/dub.selections.json"]) + if (exists(file)) remove(file); + + // first upgrade only the root package + if (spawnProcess([dub, "upgrade"]).wait != 0) + die("The upgrade command failed."); + + if (!exists("dub.selections.json") || exists("subpack/dub.selections.json")) + die("The upgrade command did not generate the right set of dub.selections.json files."); + + remove("dub.selections.json"); + + // now upgrade with all sub packages + if (spawnProcess([dub, "upgrade", "-s"]).wait != 0) + die("The upgrade command failed with -s."); + + if (!exists("dub.selections.json") || !exists("subpack/dub.selections.json")) + die("The upgrade command did not generate all dub.selections.json files."); +} diff --git a/test/test-version-opt.sh b/test/test-version-opt.sh deleted file mode 100755 index 3abf31be6f..0000000000 --- a/test/test-version-opt.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -$DUB --version | grep -qF 'DUB version' diff --git a/test/test-version-opt/dub.json b/test/test-version-opt/dub.json new file mode 100644 index 0000000000..2e972c0c3b --- /dev/null +++ b/test/test-version-opt/dub.json @@ -0,0 +1,8 @@ +{ + "name": "test-version-opt", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/test-version-opt/source/app.d b/test/test-version-opt/source/app.d new file mode 100644 index 0000000000..21d9352a62 --- /dev/null +++ b/test/test-version-opt/source/app.d @@ -0,0 +1,14 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; + +void main () { + auto p = teeProcess([dub, "--version"], Redirect.stdout); + if (p.pid.wait != 0) + die("dub --version failed"); + if (!p.stdout.canFind("DUB version")) + die("dub --version did not contain 'DUB version'"); +} diff --git a/test/timeout.sh b/test/timeout.sh deleted file mode 100755 index 746b0aafc7..0000000000 --- a/test/timeout.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -PORT=$(getRandomPort) - -log ' Testing unconnectable registry' -if timeout 1s $DUB fetch dub --skip-registry=all --registry=http://localhost:$PORT; then - die $LINENO 'Fetching from unconnectable registry should fail.' -elif [ $? -eq 124 ]; then - die $LINENO 'Fetching from unconnectable registry should fail immediately.' -fi - -log ' Testing non-responding registry' -cat | nc -l $PORT >/dev/null & -PID=$! -if timeout 10s $DUB fetch dub --skip-registry=all --registry=http://localhost:$PORT; then - die $LINENO 'Fetching from non-responding registry should fail.' -elif [ $? -eq 124 ]; then - die $LINENO 'Fetching from non-responding registry should time-out within 8s.' -fi -kill $PID 2>/dev/null || true - -log ' Testing too slow registry' -{ - res=$(printf 'HTTP/1.1 200 OK\r -Server: dummy\r -Content-Type: application/json\r -Content-Length: 2\r -\r -{}') - for i in $(seq 0 $((${#res} - 1))); do - echo -n "${res:$i:1}" || true - sleep 1 - done -} | tail -n +1 | nc -l $PORT >/dev/null & -PID=$! -if timeout 10s time $DUB fetch dub --skip-registry=all --registry=http://localhost:$PORT; then - die $LINENO 'Fetching from too slow registry should fail.' -elif [ $? -eq 124 ]; then - die $LINENO 'Fetching from too slow registry should time-out within 8s.' -fi -kill $PID 2>/dev/null || true diff --git a/test/timeout/dub.json b/test/timeout/dub.json new file mode 100644 index 0000000000..0757973f92 --- /dev/null +++ b/test/timeout/dub.json @@ -0,0 +1,8 @@ +{ + "name": "timeout", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/timeout/source/app.d b/test/timeout/source/app.d new file mode 100644 index 0000000000..0f5e254ad8 --- /dev/null +++ b/test/timeout/source/app.d @@ -0,0 +1,100 @@ +import common; + +import core.thread.osthread; +import core.time; +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main () { + immutable port = getRandomPort(); + immutable cmd = [ + dub, + "fetch", + "dub", + "--skip-registry=all", + // a port that shouldn't be occupied + "--registry=http://localhost:" ~ port, + ]; + + // FIXME windows waits the full 8 seconds before stopping + version(Posix) {{ + log("Testing unconnectable registry"); + auto p = spawnProcess(cmd); + scope(exit) p.stop; + + Thread.sleep(4.seconds); + if (!p.tryWait.terminated) + die("Fetching from unconnectable registry should fail immediately."); + if (p.wait == 0) + die("Fetching from unconnectable registry should fail."); + }} + + try { + execute("nc"); + } catch (ProcessException) { + log("Skipping the rests of these tests as they require `nc`"); + return; + } + + { + log("Testing non-responding registry"); + auto nc = pipeProcess(["nc", "-l", port]); + scope(exit) stop(nc.pid); + nc.stdin.close(); + + auto p = spawnProcess(cmd); + scope(exit) p.stop; + + Thread.sleep(10.seconds); + + if (!p.tryWait.terminated) + die("Fetching from non-responding registry should fail."); + if (p.wait == 0) + die("Fetching from non-responding registry should fail."); + } + + { + log("Testing too slow registry"); + auto nc = pipeProcess(["nc", "-l", port]); + scope(exit) stop(nc.pid); + + nc.stdin.write("HTTP/1.1 200 OK\r\n"); + nc.stdin.write("Server: dummy\r\n"); + nc.stdin.write("Content-Type: application/json\r\n"); + nc.stdin.write("Content-Length: 2\r\n"); + nc.stdin.write("\r\n"); + // Simulate slow response + //nc.stdin.write("{}"); + + // SEGV without this ?? + nc.stdin.flush(); + + auto p = spawnProcess(cmd); + scope(exit) p.stop; + + Thread.sleep(10.seconds); + + if (!p.tryWait.terminated) + die("Fetching from too slow registry should time-out within 8s."); + if (p.wait == 0) + die("Fetching from non-responding registry should fail."); + } +} + +string getRandomPort() { + auto result = cast(ushort)(thisProcessID % ushort.max); + if (result < 1024) + result += 1025; + import std.conv; + return text(result); +} + +void stop(Pid pid) { + scope(exit) pid.wait; + try { + pid.kill; + } catch (Exception) {} +} diff --git a/test/unittest-cov-ctfe.sh b/test/unittest-cov-ctfe.sh deleted file mode 100755 index a97a262ca5..0000000000 --- a/test/unittest-cov-ctfe.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -DIR=$(dirname "${BASH_SOURCE[0]}") -. "$DIR"/common.sh -"$DUB" test --root "$DIR"/unittest-cov-ctfe --build=unittest-cov-ctfe diff --git a/test/unittest-cov-ctfe/.no_build b/test/unittest-cov-ctfe/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/unittest-cov-ctfe/.no_run b/test/unittest-cov-ctfe/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/unittest-cov-ctfe/.no_test b/test/unittest-cov-ctfe/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/unittest-cov-ctfe/dub.sdl b/test/unittest-cov-ctfe/dub.sdl index de485d0ab1..751b9a6083 100644 --- a/test/unittest-cov-ctfe/dub.sdl +++ b/test/unittest-cov-ctfe/dub.sdl @@ -1,4 +1,4 @@ -name "test" +name "unittest-cov-ctfe" version "1.0.0" targetType "library" dflags "-cov=100" diff --git a/test/unittest-cov-ctfe/test.config b/test/unittest-cov-ctfe/test.config new file mode 100644 index 0000000000..5c69b16675 --- /dev/null +++ b/test/unittest-cov-ctfe/test.config @@ -0,0 +1,4 @@ +dub_command = test +dub_build_type = unittest-cov-ctfe +# no -cov=ctfe switch for gdmd +dc_backend = [dmd, ldc] diff --git a/test/use-c-sources/.min_frontend b/test/use-c-sources/.min_frontend deleted file mode 100644 index 1dbb4ffb0a..0000000000 --- a/test/use-c-sources/.min_frontend +++ /dev/null @@ -1 +0,0 @@ -2.101 diff --git a/test/use-c-sources/.no_build_gdc b/test/use-c-sources/.no_build_gdc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/use-c-sources/test.config b/test/use-c-sources/test.config new file mode 100644 index 0000000000..47e72f5625 --- /dev/null +++ b/test/use-c-sources/test.config @@ -0,0 +1,3 @@ +dlang_fe_version_min = 2101 +# no #include for gdc +dc_backend = [dmd, ldc] \ No newline at end of file diff --git a/test/version-filters-diamond/.gitignore b/test/version-filters-diamond/.gitignore index c09a5970c4..9a14c13e05 100644 --- a/test/version-filters-diamond/.gitignore +++ b/test/version-filters-diamond/.gitignore @@ -1,15 +1,3 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance-diamond -issue1262-version-inheritance-diamond.so -issue1262-version-inheritance-diamond.dylib -issue1262-version-inheritance-diamond.dll -issue1262-version-inheritance-diamond.a -issue1262-version-inheritance-diamond.lib -issue1262-version-inheritance-diamond-test-* -*.exe -*.o -*.obj -*.lst +!/son/ +!/daughter/ +!/diamond/ \ No newline at end of file diff --git a/test/version-filters-diamond/.no_build b/test/version-filters-diamond/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-diamond/.no_run b/test/version-filters-diamond/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-diamond/.no_test b/test/version-filters-diamond/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-diamond/daughter/.gitignore b/test/version-filters-diamond/daughter/.gitignore deleted file mode 100644 index f190acb869..0000000000 --- a/test/version-filters-diamond/daughter/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -daughter.so -daughter.dylib -daughter.dll -daughter.a -daughter.lib -daughter-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/version-filters-diamond/daughter/dub.sdl b/test/version-filters-diamond/daughter/dub.sdl index 9562cc5e83..08167675a8 100644 --- a/test/version-filters-diamond/daughter/dub.sdl +++ b/test/version-filters-diamond/daughter/dub.sdl @@ -1,6 +1,6 @@ -name "daughter" +name "version-filters-diamond-daughter" versions "Daughter" debugVersions "dDaughter" x:versionFilters "Daughter" "Parent" x:debugVersionFilters "dDaughter" "dParent" -dependency "diamond" path="../diamond" +dependency "version-filters-diamond-diamond" path="../diamond" diff --git a/test/version-filters-diamond/diamond/.gitignore b/test/version-filters-diamond/diamond/.gitignore index c359a73474..e9fe786b22 100644 --- a/test/version-filters-diamond/diamond/.gitignore +++ b/test/version-filters-diamond/diamond/.gitignore @@ -1,14 +1 @@ -.dub -docs.json -__dummy.html -docs/ -diamond.so -diamond.dylib -diamond.dll -diamond.a -diamond.lib -diamond-test-* -*.exe -*.o -*.obj -*.lst +/version-filters-diamond-diamond \ No newline at end of file diff --git a/test/version-filters-diamond/diamond/dub.sdl b/test/version-filters-diamond/diamond/dub.sdl index afdb2725cd..6b5002513d 100644 --- a/test/version-filters-diamond/diamond/dub.sdl +++ b/test/version-filters-diamond/diamond/dub.sdl @@ -1,3 +1,3 @@ -name "diamond" +name "version-filters-diamond-diamond" versions "Diamond" debugVersions "dDiamond" diff --git a/test/version-filters-diamond/dub.sdl b/test/version-filters-diamond/dub.sdl index 51295fd051..e55158b5a2 100644 --- a/test/version-filters-diamond/dub.sdl +++ b/test/version-filters-diamond/dub.sdl @@ -3,5 +3,5 @@ versions "Parent" debugVersions "dParent" x:versionFilters "Parent" x:debugVersionFilters "dParent" -dependency "daughter" path="daughter" -dependency "son" path="son" +dependency "version-filters-diamond-daughter" path="daughter" +dependency "version-filters-diamond-son" path="son" diff --git a/test/version-filters-diamond/son/.gitignore b/test/version-filters-diamond/son/.gitignore deleted file mode 100644 index 601a33b470..0000000000 --- a/test/version-filters-diamond/son/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -son.so -son.dylib -son.dll -son.a -son.lib -son-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/version-filters-diamond/son/dub.sdl b/test/version-filters-diamond/son/dub.sdl index 3e0a630c69..21c5c6f88d 100644 --- a/test/version-filters-diamond/son/dub.sdl +++ b/test/version-filters-diamond/son/dub.sdl @@ -1,6 +1,6 @@ -name "son" +name "version-filters-diamond-son" versions "Son" debugVersions "dSon" x:versionFilters "Son" x:debugVersionFilters "dSon" -dependency "diamond" path="../diamond" +dependency "version-filters-diamond-diamond" path="../diamond" diff --git a/test/version-filters-diamond/test.config b/test/version-filters-diamond/test.config new file mode 100644 index 0000000000..187d256a67 --- /dev/null +++ b/test/version-filters-diamond/test.config @@ -0,0 +1,2 @@ +dub_command = build +extra_dub_args = --filter-versions \ No newline at end of file diff --git a/test/version-filters-none/.gitignore b/test/version-filters-none/.gitignore deleted file mode 100644 index c09a5970c4..0000000000 --- a/test/version-filters-none/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance-diamond -issue1262-version-inheritance-diamond.so -issue1262-version-inheritance-diamond.dylib -issue1262-version-inheritance-diamond.dll -issue1262-version-inheritance-diamond.a -issue1262-version-inheritance-diamond.lib -issue1262-version-inheritance-diamond-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/version-filters-none/.no_build b/test/version-filters-none/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-none/.no_run b/test/version-filters-none/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-none/.no_test b/test/version-filters-none/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-none/test.config b/test/version-filters-none/test.config new file mode 100644 index 0000000000..187d256a67 --- /dev/null +++ b/test/version-filters-none/test.config @@ -0,0 +1,2 @@ +dub_command = build +extra_dub_args = --filter-versions \ No newline at end of file diff --git a/test/version-filters-source-dep/.gitignore b/test/version-filters-source-dep/.gitignore index c09a5970c4..e582da3864 100644 --- a/test/version-filters-source-dep/.gitignore +++ b/test/version-filters-source-dep/.gitignore @@ -1,15 +1 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance-diamond -issue1262-version-inheritance-diamond.so -issue1262-version-inheritance-diamond.dylib -issue1262-version-inheritance-diamond.dll -issue1262-version-inheritance-diamond.a -issue1262-version-inheritance-diamond.lib -issue1262-version-inheritance-diamond-test-* -*.exe -*.o -*.obj -*.lst +!/source-dep/ \ No newline at end of file diff --git a/test/version-filters-source-dep/.no_build b/test/version-filters-source-dep/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-source-dep/.no_run b/test/version-filters-source-dep/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-source-dep/.no_test b/test/version-filters-source-dep/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters-source-dep/dub.sdl b/test/version-filters-source-dep/dub.sdl index 73d4834dc3..1e789ae9b5 100644 --- a/test/version-filters-source-dep/dub.sdl +++ b/test/version-filters-source-dep/dub.sdl @@ -2,4 +2,4 @@ name "version-filters-source-dep" versions "Parent" debugVersions "dParent" x:versionFilters "none" -dependency "source-dep" path="source-dep" +dependency "version-filters-source-dep-ex" path="source-dep" diff --git a/test/version-filters-source-dep/source-dep/dub.sdl b/test/version-filters-source-dep/source-dep/dub.sdl index d9b7c63f06..eb98c2c8eb 100644 --- a/test/version-filters-source-dep/source-dep/dub.sdl +++ b/test/version-filters-source-dep/source-dep/dub.sdl @@ -1,4 +1,4 @@ -name "source-dep" +name "version-filters-source-dep-ex" versions "SourceDep" debugVersions "dSourceDep" # filter of sourceOnly libs are merged with dependents diff --git a/test/version-filters-source-dep/test.config b/test/version-filters-source-dep/test.config new file mode 100644 index 0000000000..1da4c146a2 --- /dev/null +++ b/test/version-filters-source-dep/test.config @@ -0,0 +1,2 @@ +dub_command = build +extra_dub_args = --filter-versions diff --git a/test/version-filters.sh b/test/version-filters.sh deleted file mode 100755 index e92f3fa099..0000000000 --- a/test/version-filters.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -$DUB build --root="$CURR_DIR/version-filters" --filter-versions -$DUB build --root="$CURR_DIR/version-filters-diamond" --filter-versions -$DUB build --root="$CURR_DIR/version-filters-source-dep" --filter-versions -$DUB build --root="$CURR_DIR/version-filters-none" --filter-versions diff --git a/test/version-filters/.gitignore b/test/version-filters/.gitignore index c09a5970c4..e6e221b63f 100644 --- a/test/version-filters/.gitignore +++ b/test/version-filters/.gitignore @@ -1,15 +1,2 @@ -.dub -docs.json -__dummy.html -docs/ -issue1262-version-inheritance-diamond -issue1262-version-inheritance-diamond.so -issue1262-version-inheritance-diamond.dylib -issue1262-version-inheritance-diamond.dll -issue1262-version-inheritance-diamond.a -issue1262-version-inheritance-diamond.lib -issue1262-version-inheritance-diamond-test-* -*.exe -*.o -*.obj -*.lst +!/son/ +!/daughter \ No newline at end of file diff --git a/test/version-filters/.no_build b/test/version-filters/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters/.no_run b/test/version-filters/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters/.no_test b/test/version-filters/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-filters/daughter/.gitignore b/test/version-filters/daughter/.gitignore deleted file mode 100644 index f190acb869..0000000000 --- a/test/version-filters/daughter/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -daughter.so -daughter.dylib -daughter.dll -daughter.a -daughter.lib -daughter-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/version-filters/daughter/dub.sdl b/test/version-filters/daughter/dub.sdl index 7eb94da3fa..8b41b3c13a 100644 --- a/test/version-filters/daughter/dub.sdl +++ b/test/version-filters/daughter/dub.sdl @@ -1,4 +1,4 @@ -name "daughter" +name "version-filters-daughter" versions "Daughter" debugVersions "dDaughter" x:versionFilters "Daughter" "Parent" diff --git a/test/version-filters/dub.sdl b/test/version-filters/dub.sdl index 9f79da4533..9ddaefad2f 100644 --- a/test/version-filters/dub.sdl +++ b/test/version-filters/dub.sdl @@ -3,5 +3,5 @@ versions "Parent" debugVersions "dParent" x:versionFilters "Parent" x:debugVersionFilters "dParent" -dependency "daughter" path="daughter" -dependency "son" path="son" +dependency "version-filters-daughter" path="daughter" +dependency "version-filters-son" path="son" diff --git a/test/version-filters/son/.gitignore b/test/version-filters/son/.gitignore deleted file mode 100644 index 601a33b470..0000000000 --- a/test/version-filters/son/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.dub -docs.json -__dummy.html -docs/ -son.so -son.dylib -son.dll -son.a -son.lib -son-test-* -*.exe -*.o -*.obj -*.lst diff --git a/test/version-filters/son/dub.sdl b/test/version-filters/son/dub.sdl index e851dd692a..0793dfd848 100644 --- a/test/version-filters/son/dub.sdl +++ b/test/version-filters/son/dub.sdl @@ -1,4 +1,4 @@ -name "son" +name "version-filters-son" versions "Son" debugVersions "dSon" x:versionFilters "Son" diff --git a/test/version-filters/test.config b/test/version-filters/test.config new file mode 100644 index 0000000000..187d256a67 --- /dev/null +++ b/test/version-filters/test.config @@ -0,0 +1,2 @@ +dub_command = build +extra_dub_args = --filter-versions \ No newline at end of file diff --git a/test/version-spec.sh b/test/version-spec.sh deleted file mode 100755 index 77020da259..0000000000 --- a/test/version-spec.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh - -# When pipeing the dub output it is possible for head/tail to extract -# the output line before dub finished printing leading to dub -# receiving SIGPIPE. With pipefail this would fail the whole $() -# invocation leading to a ERROR result but, since $() invokes a -# subshell, the rest of the test still continue (and passes). The end -# result are 2 log lines, one for success and one for failure, for -# this single test file. -# -# The command that consistently fails for me is: -# $DUB list foo@'>0.1.0' | head -n 2 | tail -n 1 -set +o pipefail - -DUBPKGPATH=${DPATH+"$DPATH/dub/packages/dub"} -DUBPKGPATH=${DUBPKGPATH:-"$HOME/.dub/packages/dub"} - -$DUB add-local "$CURR_DIR/version-spec/newfoo" -$DUB add-local "$CURR_DIR/version-spec/oldfoo" - -[[ $($DUB describe foo | grep path | head -n 1) == *"/newfoo/"* ]] -[[ $($DUB describe foo@1.0.0 | grep path | head -n 1) == *"/newfoo/"* ]] -[[ $($DUB describe foo@0.1.0 | grep path | head -n 1) == *"/oldfoo/"* ]] - -[[ $($DUB describe foo@'<1.0.0' | grep path | head -n 1) == *"/oldfoo/"* ]] -[[ $($DUB describe foo@'>0.1.0' | grep path | head -n 1) == *"/newfoo/"* ]] -[[ $($DUB describe foo@'>0.2.0' | grep path | head -n 1) == *"/newfoo/"* ]] -[[ $($DUB describe foo@'<=0.2.0' | grep path | head -n 1) == *"/oldfoo/"* ]] -[[ $($DUB describe foo@'*' | grep path | head -n 1) == *"/newfoo/"* ]] -[[ $($DUB describe foo@'>0.0.1 <2.0.0' | grep path | head -n 1) == *"/newfoo/"* ]] - -[[ $($DUB test foo | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB test foo@1.0.0 | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB test foo@0.1.0 | tail -n +1 | head -n 1) == *"/oldfoo/" ]] - -[[ $($DUB lint foo | tail -n 1) == *"/newfoo/" ]] -[[ $($DUB lint foo@1.0.0 | tail -n 1) == *"/newfoo/" ]] -[[ $($DUB lint foo@0.1.0 | tail -n 1) == *"/oldfoo/" ]] - -[[ $($DUB generate cmake foo | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB generate cmake foo@1.0.0 | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB generate cmake foo@0.1.0 | tail -n +1 | head -n 1) == *"/oldfoo/" ]] - -[[ $($DUB build -n foo | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB build -n foo@1.0.0 | tail -n +1 | head -n 1) == *"/newfoo/" ]] -[[ $($DUB build -n foo@0.1.0 | tail -n +1 | head -n 1) == *"/oldfoo/" ]] - -[[ $($DUB run -n foo | tail -n 1) == 'new-foo' ]] -[[ $($DUB run -n foo@1.0.0 | tail -n 1) == 'new-foo' ]] -[[ $($DUB run -n foo@0.1.0 | tail -n 1) == 'old-foo' ]] - -[[ $($DUB list foo | wc -l) == '4' ]] -[[ $($DUB list foo@0.1.0 | wc -l) == '3' ]] -[[ $($DUB list foo@'>0.1.0' | head -n 2 | tail -n 1) == *"/newfoo"* ]] - -$DUB remove-local "$CURR_DIR/version-spec/newfoo" -$DUB remove-local "$CURR_DIR/version-spec/oldfoo" - -$DUB fetch dub@1.9.0 && [ -d $DUBPKGPATH/1.9.0/dub ] -$DUB fetch dub=1.10.0 && [ -d $DUBPKGPATH/1.10.0/dub ] -$DUB remove dub@1.9.0 -$DUB remove dub=1.10.0 -if [ -d $DUBPKGPATH/1.9.0/dub ] || [ -d $DUBPKGPATH/1.10.0/dub ]; then - die $LINENO 'Failed to remove specified versions' -fi diff --git a/test/version-spec/.gitignore b/test/version-spec/.gitignore new file mode 100644 index 0000000000..5a481496dc --- /dev/null +++ b/test/version-spec/.gitignore @@ -0,0 +1,7 @@ +/sample/** +!/sample/ +!/sample/newfoo/ +!/sample/oldfoo/ +!/sample/*/dub.sdl +!/sample/*/source/ +!/sample/*/source/** \ No newline at end of file diff --git a/test/version-spec/.no_build b/test/version-spec/.no_build deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-spec/.no_run b/test/version-spec/.no_run deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-spec/.no_test b/test/version-spec/.no_test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/version-spec/dub.json b/test/version-spec/dub.json new file mode 100644 index 0000000000..558363bcb2 --- /dev/null +++ b/test/version-spec/dub.json @@ -0,0 +1,8 @@ +{ + "name": "version-spec", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/version-spec/newfoo/dub.sdl b/test/version-spec/sample/newfoo/dub.sdl similarity index 100% rename from test/version-spec/newfoo/dub.sdl rename to test/version-spec/sample/newfoo/dub.sdl diff --git a/test/version-spec/newfoo/source/app.d b/test/version-spec/sample/newfoo/source/app.d similarity index 100% rename from test/version-spec/newfoo/source/app.d rename to test/version-spec/sample/newfoo/source/app.d diff --git a/test/version-spec/oldfoo/dub.sdl b/test/version-spec/sample/oldfoo/dub.sdl similarity index 100% rename from test/version-spec/oldfoo/dub.sdl rename to test/version-spec/sample/oldfoo/dub.sdl diff --git a/test/version-spec/oldfoo/source/app.d b/test/version-spec/sample/oldfoo/source/app.d similarity index 100% rename from test/version-spec/oldfoo/source/app.d rename to test/version-spec/sample/oldfoo/source/app.d diff --git a/test/version-spec/source/app.d b/test/version-spec/source/app.d new file mode 100644 index 0000000000..338516f731 --- /dev/null +++ b/test/version-spec/source/app.d @@ -0,0 +1,134 @@ +import common; + +import std.algorithm; +import std.conv; +import std.file; +import std.path; +import std.process; +import std.range; +import std.string; + +void main () { + if (spawnProcess([dub, "add-local", getcwd.buildPath("sample", "newfoo")]).wait != 0) + die("dub add-local newfoo failed"); + if (spawnProcess([dub, "add-local", getcwd.buildPath("sample", "oldfoo")]).wait != 0) + die("dub add-local oldfoo failed"); + + string[] getLines(string[] args) { + log("Running ", text(dub ~ args), " ..."); + immutable p = execute(dub ~ args); + if (p.status != 0) { + log("Dub output:"); + log(p.output); + die("failed to run ", text(dub ~ args)); + } + return p.output.splitLines; + } + + void tc(string[] args, string delegate(const string[]) mapper, string needle) { + const lines = getLines(args); + immutable targetLine = mapper(lines); + + if (!targetLine.canFind(needle)) { + log("Dub output:"); + foreach (line; lines) + log(line); + log("The found line: ", targetLine); + log("needle: ", needle); + die("failed ", text(args)); + } + } + + void findOnPathLine(string[] args, string needle) { + tc(args, a => a.find!`a.canFind("path")`.front, needle); + } + + immutable newFooDir = dirSeparator ~ "newfoo" ~ dirSeparator; + immutable oldFooDir = dirSeparator ~ "oldfoo" ~ dirSeparator; + + findOnPathLine(["describe", "foo"], newFooDir); + findOnPathLine(["describe", "foo@1.0.0"], newFooDir); + findOnPathLine(["describe", "foo@0.1.0"], oldFooDir); + findOnPathLine(["describe", "foo@<1.0.0"], oldFooDir); + findOnPathLine(["describe", "foo@>0.1.0"], newFooDir); + findOnPathLine(["describe", "foo@>0.2.0"], newFooDir); + findOnPathLine(["describe", "foo@<=0.2.0"], oldFooDir); + findOnPathLine(["describe", "foo@*"], newFooDir); + findOnPathLine(["describe", "foo@>0.0.1 <2.0.0"], newFooDir); + + void findOnFirstLine(string[] args, string needle) { + tc(args, a => a[0], needle); + } + + findOnFirstLine(["test", "foo"], newFooDir); + findOnFirstLine(["test", "foo@1.0.0"], newFooDir); + findOnFirstLine(["test", "foo@0.1.0"], oldFooDir); + + log("The lint tests can take longer on the first run"); + findOnFirstLine(["lint", "foo"], newFooDir); + findOnFirstLine(["lint", "foo@1.0.0"], newFooDir); + findOnFirstLine(["lint", "foo@0.1.0"], oldFooDir); + + findOnFirstLine(["generate", "cmake", "foo"], newFooDir); + findOnFirstLine(["generate", "cmake", "foo@1.0.0"], newFooDir); + findOnFirstLine(["generate", "cmake", "foo@0.1.0"], oldFooDir); + + findOnFirstLine(["build", "-n", "foo"], newFooDir); + findOnFirstLine(["build", "-n", "foo@1.0.0"], newFooDir); + findOnFirstLine(["build", "-n", "foo@0.1.0"], oldFooDir); + + void findOnLastLine(string[] args, string needle) { + tc(args, a => a[$ - 1], needle); + } + + findOnLastLine(["run", "-n", "foo"], "new-foo"); + findOnLastLine(["run", "-n", "foo@1.0.0"], "new-foo"); + findOnLastLine(["run", "-n", "foo@0.1.0"], "old-foo"); + + void countLines(string[] args, int expected) { + const lines = getLines(args); + if (lines.length != expected) + die(text(args), " didn't produce ", text(expected), " lines"); + } + countLines(["list", "foo"], 4); + countLines(["list", "foo@0.1.0"], 3); + tc(["list", "foo@>0.1.0"], a => a[1], newFooDir); + + + if (spawnProcess([dub, "remove-local", "sample/newfoo"]).wait != 0) + die("dub remove-local newfoo failed"); + if (spawnProcess([dub, "remove-local", "sample/oldfoo"]).wait != 0) + die("dub remove-local oldfoo failed"); + + void assertIsDir(string path) { + if (!exists(path)) + die(path, " doesn't exist"); + if (!isDir(path)) + die(path, " exists but it's a directory"); + } + + immutable dubPkgPath = dubHome.buildPath("packages", "dub"); + if (spawnProcess([dub, "fetch", "dub@1.9.0"]).wait != 0) + die("dub fetch dub@1.9.0 failed"); + assertIsDir(dubPkgPath.buildPath("1.9.0", "dub")); + + if (spawnProcess([dub, "fetch", "dub=1.10.0"]).wait != 0) + die("dub fetch dub=1.10.0 failed"); + assertIsDir(dubPkgPath.buildPath("1.10.0", "dub")); + + + if (spawnProcess([dub, "remove", "dub@1.9.0"]).wait != 0) + die("dub remove dub@1.9.0 failed"); + if (spawnProcess([dub, "remove", "dub=1.10.0"]).wait != 0) + die("dub remove dub=1.10.0 failed"); + + bool existsDir(string path) { + return exists(path) && isDir(path); + } + if (existsDir(dubPkgPath.buildPath("dub", "1.9.0"))) + die("Failed to remove dub@1.9.0"); + if (existsDir(dubPkgPath.buildPath("dub", "1.10.0"))) + die("Failed to remove dub=1.10.0"); +} + +// "" diff --git a/test/win32_default.script.d b/test/win32_default.script.d deleted file mode 100644 index dd96ed9e75..0000000000 --- a/test/win32_default.script.d +++ /dev/null @@ -1,89 +0,0 @@ -/+ dub.json: { - "name": "win32_default_test" -} +/ - -module win32_default.script; - -int main() -{ - import std.stdio; - - version (Windows) - { - version (DigitalMars) - enum disabled = null; - else - enum disabled = "DMD as the host compiler"; - } - else - enum disabled = "Windows"; - - static if (disabled) - { - writeln("Test `win32_default` requires " ~ disabled); - return 0; - } - else - { - import std.algorithm; - import std.path; - import std.process; - - const dir = __FILE_FULL_PATH__.dirName(); - const file = buildPath(dir, "win32_default.d"); - - const dub = environment.get("DUB", buildPath(dirName(dir), "bin", "dub.exe")); - const dmd = environment.get("DMD", "dmd"); - - int exitCode; - - void runTest(scope const string[] cmd) - { - const result = execute(cmd); - - if (result.status || result.output.canFind("Failed")) - { - writefln("\n> %-(%s %)", cmd); - writeln("==========================================================="); - writeln(result.output); - writeln("==========================================================="); - writeln("Last command failed with exit code ", result.status, '\n'); - exitCode = 1; - } - } - - // Test without --arch - runTest([ - dub, "build", - "--compiler", dmd, - "--config", "MsCoff64", - "--single", file, - ]); - - // Test with different --arch - const string[2][] tests = [ - [ "x86", "Default" ], - [ "x86_omf", "MsCoff" ], - [ "x86_mscoff", "MsCoff" ], - [ "x86_64", "MsCoff64" ], - ]; - - foreach (string[2] test; tests) - { - const arch = test[0]; - const config = test[1]; - - runTest([ - dub, "build", - "--compiler", dmd, - "--arch", arch, - "--config", config, - "--single", file, - ]); - } - - - - return exitCode; - } -} diff --git a/test/win32_default/.gitignore b/test/win32_default/.gitignore new file mode 100644 index 0000000000..96d3e27157 --- /dev/null +++ b/test/win32_default/.gitignore @@ -0,0 +1 @@ +!/sample.d \ No newline at end of file diff --git a/test/win32_default/dub.json b/test/win32_default/dub.json new file mode 100644 index 0000000000..42a668d3c4 --- /dev/null +++ b/test/win32_default/dub.json @@ -0,0 +1,8 @@ +{ + "name": "win32_default", + "dependencies": { + "common": { + "path": "../common" + } + } +} diff --git a/test/win32_default.d b/test/win32_default/sample.d similarity index 100% rename from test/win32_default.d rename to test/win32_default/sample.d diff --git a/test/win32_default/source/app.d b/test/win32_default/source/app.d new file mode 100644 index 0000000000..ed90b1e26b --- /dev/null +++ b/test/win32_default/source/app.d @@ -0,0 +1,62 @@ +import common; + +import std.algorithm; +import std.file; +import std.path; +import std.process; +import std.stdio; + +void main() +{ + const file = buildPath(getcwd, "sample.d"); + + const dmd = environment.get("DC"); + + int exitCode; + + void runTest(scope const string[] cmd) + { + const result = execute(cmd); + + if (result.status || result.output.canFind("Failed")) + { + writefln("\n> %-(%s %)", cmd); + writeln("==========================================================="); + writeln(result.output); + writeln("==========================================================="); + writeln("Last command failed with exit code ", result.status, '\n'); + exitCode = 1; + } + } + + // Test without --arch + runTest([ + dub, "build", + "--config", "MsCoff64", + "--single", file, + ]); + + // Test with different --arch + const string[2][] tests = [ + [ "x86", "Default" ], + [ "x86_omf", "MsCoff" ], + [ "x86_mscoff", "MsCoff" ], + [ "x86_64", "MsCoff64" ], + ]; + + foreach (string[2] test; tests) + { + const arch = test[0]; + const config = test[1]; + + runTest([ + dub, "build", + "--arch", arch, + "--config", config, + "--single", file, + ]); + } + + if (exitCode) + die("some tests failed"); +} diff --git a/test/win32_default/test.config b/test/win32_default/test.config new file mode 100644 index 0000000000..82dbd3cff3 --- /dev/null +++ b/test/win32_default/test.config @@ -0,0 +1,2 @@ +os = windows +dc_backend = dmd \ No newline at end of file