From fee329f00d404e28e6537b592154b53d4763f298 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 19 Aug 2023 02:23:04 +0200 Subject: [PATCH] [convert test/dynLib-monolith.sh to dynLib-monolith.script.d for Windows support] --- test/dynLib-monolith.script.d | 40 +++++++++++++++++++++++++++++++++++ test/dynLib-monolith.sh | 16 -------------- 2 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 test/dynLib-monolith.script.d delete mode 100755 test/dynLib-monolith.sh diff --git a/test/dynLib-monolith.script.d b/test/dynLib-monolith.script.d new file mode 100644 index 000000000..1c3c14dbe --- /dev/null +++ b/test/dynLib-monolith.script.d @@ -0,0 +1,40 @@ +/+ dub.json: { + "name": "dynlib-monolith-script" +} +/ +module dynlib_monolith_script; + +import std.algorithm, std.path, std.process, std.stdio; + +int main() +{ + const dc = environment.get("DC", "dmd"); + if (!dc.startsWith("ldc")) + { + writeln("Skipping test, needs LDC"); + return 0; + } + + // enforce a full build (2 static libs, 1 dynamic one) and collect -v output + enum projDir = dirName(__FILE_FULL_PATH__).buildPath("dynLib-monolith"); + const res = execute([environment.get("DUB", "dub"), "build", "-f", "-v", "--root", projDir]); + + if (res.status != 0) + { + writeln("The dub invocation failed:"); + writeln(); + writeln(res.output); + return 1; + } + + version (Windows) enum needle = " -fvisibility=hidden -dllimport=defaultLibsOnly"; + else enum needle = " -fvisibility=hidden"; + if (res.output.count(needle) != 3) + { + writeln("Didn't find 3 occurrences of '" ~ needle ~ "' in the verbose dub output:"); + writeln(); + writeln(res.output); + return 1; + } + + return 0; +} diff --git a/test/dynLib-monolith.sh b/test/dynLib-monolith.sh deleted file mode 100755 index b13c9a83e..000000000 --- a/test/dynLib-monolith.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -DIR=$(dirname "${BASH_SOURCE[0]}") -. "$DIR"/common.sh - -if [[ "$DC" != ldc* ]]; then - echo "Skipping test, needs LDC" - exit 0 -fi - -# enforce a full build (2 static libs, 1 dynamic one) and collect -v output -output=$("$DUB" build -v -f --root "$DIR"/dynLib-monolith) - -if [[ $(grep -c -- '-fvisibility=hidden' <<<"$output") -ne 3 ]]; then - die $LINENO "Didn't find 3 occurrences of '-fvisibility=hidden' in the verbose dub output!" "$output" -fi