Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand All @@ -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
Expand Down Expand Up @@ -140,6 +158,8 @@ jobs:
rm -rf test/use-c-sources
fi
test/run-unittest.sh

dub run --root test/run_unittest -- -v
fi
shell: bash

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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", "--" ]
40 changes: 30 additions & 10 deletions scripts/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,41 @@

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

# 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

if [[ ! ${DC} =~ gdc|gdmd ]]; then
DUB=`pwd`/bin/dub DC=${DC} dub --single ./test/run-unittest.d
DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh
fi
DUB=`pwd`/bin/dub DC=${DC} dub --single ./test/run-unittest.d
DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ version-filters-source-dep/version-filters-source-dep
version-filters/version-filters
version-spec/newfoo/foo-test-application
version-spec/oldfoo/foo-test-application

!new_tests/*
11 changes: 11 additions & 0 deletions test/new_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test.log
*/*
!*/dub.json
!*/dub.sdl
!*/package.json
!*/run.d
!*/run.sh
!*/source
!*/.gitignore
!*/test.config
!extra/*
Empty file added test/new_tests/.no_build
Empty file.
2 changes: 2 additions & 0 deletions test/new_tests/0-init-fail-json/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-fail-json"
dependency "common" path="../common"
21 changes: 21 additions & 0 deletions test/new_tests/0-init-fail-json/source/app.d
Original file line number Diff line number Diff line change
@@ -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");
}
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-fail/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-fail"
dependency "common" path="../common"
21 changes: 21 additions & 0 deletions test/new_tests/0-init-fail/source/app.d
Original file line number Diff line number Diff line change
@@ -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");
}
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-interactive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!/exp
!/exp/*
2 changes: 2 additions & 0 deletions test/new_tests/0-init-interactive/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-interactive"
dependency "common" path="../common"
5 changes: 5 additions & 0 deletions test/new_tests/0-init-interactive/exp/default_name.dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "new-package"
description "desc"
authors "author"
copyright "copy"
license "gpl"
9 changes: 9 additions & 0 deletions test/new_tests/0-init-interactive/exp/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "desc",
"license": "gpl",
"authors": [
"author"
],
"copyright": "copy",
"name": "test"
}
5 changes: 5 additions & 0 deletions test/new_tests/0-init-interactive/exp/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "test"
description "desc"
authors "author"
copyright "copy"
license "gpl"
5 changes: 5 additions & 0 deletions test/new_tests/0-init-interactive/exp/license_gpl3.dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "test"
description "desc"
authors "author"
copyright "copy"
license "GPL-3.0-only"
5 changes: 5 additions & 0 deletions test/new_tests/0-init-interactive/exp/license_mpl2.dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "test"
description "desc"
authors "author"
copyright "copy"
license "MPL-2.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "test"
description "desc"
authors "author"
copyright "copy"
license "proprietary"
63 changes: 63 additions & 0 deletions test/new_tests/0-init-interactive/source/app.d
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-multi-json/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-multi-json"
dependency "common" path="../common"
27 changes: 27 additions & 0 deletions test/new_tests/0-init-multi-json/source/app.d
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-multi/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-multi"
dependency "common" path="../common"
27 changes: 27 additions & 0 deletions test/new_tests/0-init-multi/source/app.d
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-simple-json/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-simple-json"
dependency "common" path="../common"
17 changes: 17 additions & 0 deletions test/new_tests/0-init-simple-json/source/app.d
Original file line number Diff line number Diff line change
@@ -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");
}
2 changes: 2 additions & 0 deletions test/new_tests/0-init-simple/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name "0-init-simple"
dependency "common" path="../common"
Loading