aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Horodniceanu <a.horodniceanu@proton.me>2024-03-22 08:53:22 +0200
committerAndrei Horodniceanu <a.horodniceanu@proton.me>2024-04-14 02:00:58 +0300
commit79bb15a181cd764a02097382d13c5461eb0ef4e1 (patch)
tree97ce144977b4d35390e78a3d10888c95b2107a34
parentx11-terms/tilix: port to dlang-single.eclass (diff)
downloaddlang-79bb15a1.tar.gz
dlang-79bb15a1.tar.bz2
dlang-79bb15a1.zip
dev-lang/ldc2: add tests
Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
-rw-r--r--dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch56
-rw-r--r--dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch26
-rw-r--r--dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch13
-rw-r--r--dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch13
-rw-r--r--dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch17
-rw-r--r--dev-lang/ldc2/ldc2-1.36.0-r2.ebuild138
6 files changed, 255 insertions, 8 deletions
diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch b/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch
new file mode 100644
index 0000000..e086e2d
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-disable-compiler-rt-sanitizers-tests.patch
@@ -0,0 +1,56 @@
+diff --git a/tests/PGO/lit.local.cfg b/tests/PGO/lit.local.cfg
+index 9638e26..4578f1a 100644
+--- a/tests/PGO/lit.local.cfg
++++ b/tests/PGO/lit.local.cfg
+@@ -1,2 +1,2 @@
+ # Add "PGO_RT" feature, assuming the `profile` compiler-rt library is available
+-config.available_features.add('PGO_RT')
++#config.available_features.add('PGO_RT')
+diff --git a/tests/instrument/lit.local.cfg b/tests/instrument/lit.local.cfg
+index 9366e7b..5030a1e 100644
+--- a/tests/instrument/lit.local.cfg
++++ b/tests/instrument/lit.local.cfg
+@@ -2,4 +2,5 @@ import platform
+
+ # Add "XRay_RT" feature on non-Windows, assuming the compiler-rt libraries are available
+ if (platform.system() != 'Windows'):
+- config.available_features.add('XRay_RT')
++ #config.available_features.add('XRay_RT')
++ pass
+diff --git a/tests/sanitizers/lit.local.cfg b/tests/sanitizers/lit.local.cfg
+index ce12558..6bd5021 100644
+--- a/tests/sanitizers/lit.local.cfg
++++ b/tests/sanitizers/lit.local.cfg
+@@ -4,24 +4,27 @@ import platform
+ sys = platform.system()
+
+ # Add "LSan" feature, assuming the compiler-rt library is available
+-config.available_features.add('LSan')
++#config.available_features.add('LSan')
+
+ # FreeBSD TSan doesn't seem to work,
+ # Linux TSan currently only works with static druntime,
+ # and there's no Windows TSan (yet?).
+ if (sys != 'FreeBSD') and (sys != 'Windows') and not (sys == 'Linux' and config.shared_rt_libs_only):
+- config.available_features.add('TSan')
++ #config.available_features.add('TSan')
++ pass
+
+ # FreeBSD ASan and MSan don't cope well with ASLR (might do with FreeBSD 14 according to https://github.com/llvm/llvm-project/pull/73439)
+ if sys != 'FreeBSD':
+- config.available_features.add('ASan')
++ #config.available_features.add('ASan')
++ pass
+
+ # MSan is supported on Linux, FreeBSD (modulo ASLR issue), and OpenBSD: https://clang.llvm.org/docs/MemorySanitizer.html#supported-platforms
+ if (sys == 'Linux') or (sys == 'OpenBSD'):
+- config.available_features.add('MSan')
++ #config.available_features.add('MSan')
++ pass
+
+ # Add "Fuzzer" feature, assuming the compiler-rt library is available
+-config.available_features.add('Fuzzer')
++#config.available_features.add('Fuzzer')
+
+ if 'ASan' in config.available_features:
+ # On Darwin, ASan defaults to `abort_on_error=1`, which would make tests run
diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch b/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch
new file mode 100644
index 0000000..5b67c5d
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-fix-phobos-OS-dependent-test-string.patch
@@ -0,0 +1,26 @@
+diff --git a/runtime/phobos/std/file.d b/runtime/phobos/std/file.d
+index 5b8925d..f1b19b3 100644
+--- a/runtime/phobos/std/file.d
++++ b/runtime/phobos/std/file.d
+@@ -1082,6 +1082,7 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
+
+ @safe unittest
+ {
++ import std.algorithm.searching : startsWith;
+ import std.exception : collectExceptionMsg, assertThrown;
+
+ string filename = null; // e.g. as returned by File.tmpfile.name
+@@ -1090,12 +1091,10 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t
+ {
+ // exact exception message is OS-dependent
+ auto msg = filename.remove.collectExceptionMsg!FileException;
+- assert("Failed to remove file (null): Bad address" == msg, msg);
++ assert(msg.startsWith("Failed to remove file (null):"), msg);
+ }
+ else version (Windows)
+ {
+- import std.algorithm.searching : startsWith;
+-
+ // don't test exact message on windows, it's language dependent
+ auto msg = filename.remove.collectExceptionMsg!FileException;
+ assert(msg.startsWith("(null):"), msg);
diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch b/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch
new file mode 100644
index 0000000..9809440
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-lit-cfg-disable-gdb.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/lit.site.cfg.in b/tests/lit.site.cfg.in
+index 9b0b9c8..320a6d8 100644
+--- a/tests/lit.site.cfg.in
++++ b/tests/lit.site.cfg.in
+@@ -200,7 +200,7 @@ if (platform.system() == 'Windows') and os.path.isfile( cdb ):
+ config.substitutions.append( ('%cdb', '"' + cdb.replace('\\', '\\\\') + '"') )
+
+ # Check whether GDB is present
+-if (platform.system() != 'Windows') and lit.util.which('gdb', config.environment['PATH']):
++if False:
+ config.available_features.add('gdb')
+ gdb_dflags = ''
+ command = ['gdb', '--version']
diff --git a/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch b/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch
new file mode 100644
index 0000000..6c1180c
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-1.36.0-tests-dshell-remove--m-switch.patch
@@ -0,0 +1,13 @@
+diff --git a/tests/dmd/dshell/dll_cxx.d b/tests/dmd/dshell/dll_cxx.d
+index 77393ba331..b39ec0bc6a 100644
+--- a/tests/dmd/dshell/dll_cxx.d
++++ b/tests/dmd/dshell/dll_cxx.d
+@@ -45,7 +45,7 @@ int main()
+ }
+ else
+ {
+- dllCmd ~= [ `-m` ~ Vars.MODEL, `-shared`, `-fPIC`, `-o`, Vars.DLL ];
++ dllCmd ~= [ `-shared`, `-fPIC`, `-o`, Vars.DLL ];
+ mainExtra = `-fPIC -L-L$OUTPUT_BASE -L$DLL -L-lstdc++ -L--no-demangle`;
+ if (environment.get("NO_ARCH_VARIANT", "") != "1")
+ dllCmd ~= `-m` ~ Vars.MODEL;
diff --git a/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch b/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch
new file mode 100644
index 0000000..bed0a83
--- /dev/null
+++ b/dev-lang/ldc2/files/ldc2-remove-dmd-common-int128-unittest.patch
@@ -0,0 +1,17 @@
+diff --git a/dmd/common/int128.d b/dmd/common/int128.d
+index 796687b1f7..b020cf92ce 100644
+--- a/dmd/common/int128.d
++++ b/dmd/common/int128.d
+@@ -770,6 +770,7 @@ version (unittest)
+ }
+ }
+
++/+
+ unittest
+ {
+ const C0 = Zero;
+@@ -919,3 +920,4 @@ unittest
+ assert(rol(C7_9, 1) == rol1(C7_9));
+ assert(ror(C7_9, 1) == ror1(C7_9));
+ }
+++/
diff --git a/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild b/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
index 84a0413..95fe554 100644
--- a/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
+++ b/dev-lang/ldc2/ldc2-1.36.0-r2.ebuild
@@ -3,7 +3,10 @@
EAPI=8
-inherit flag-o-matic multilib-build cmake
+# Upstream supports LLVM 11.0 through 17.0.
+LLVM_COMPAT=( {15..17} )
+PYTHON_COMPAT=( python3_{10..12} )
+inherit cmake flag-o-matic llvm-r1 multilib-build multiprocessing python-any-r1 toolchain-funcs
MY_PV="${PV//_/-}"
MY_P="ldc-${MY_PV}-src"
@@ -18,14 +21,12 @@ LICENSE="BSD"
# is an actual ABI bkreakage.
SLOT="$(ver_cut 1-2)/$(ver_cut 3)"
-IUSE="static-libs"
-RESTRICT="test"
+IUSE="static-libs test"
+RESTRICT="!test? ( test )"
-# Upstream supports LLVM 11.0 through 17.0.
-LLVM_COMPAT=( {15..17} )
DLANG_COMPAT=( dmd-2_{106..107} gdc-13 ldc2-1_{35..36} )
-inherit llvm-r1 dlang-single
+inherit dlang-single
REQUIRED_USE=${DLANG_REQUIRED_USE}
DEPEND="
@@ -33,15 +34,53 @@ DEPEND="
$(llvm_gen_dep '
sys-devel/llvm:${LLVM_SLOT}=
')
+ net-misc/curl[${MULTILIB_USEDEP}]
"
IDEPEND=">=app-eselect/eselect-dlang-20140709"
RDEPEND="
${DEPEND}
${IDEPEND}
"
-BDEPEND=${DLANG_DEPS}
+BDEPEND="
+ ${DLANG_DEPS}
+ test? (
+ ${PYTHON_DEPS}
+ $(python_gen_any_dep '
+ dev-python/lit[${PYTHON_USEDEP}]
+ ')
+ )
+"
+
+python_check_deps() {
+ python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
+}
-PATCHES="${FILESDIR}/ldc2-1.15.0-link-defaultlib-shared.patch"
+PATCHES=(
+ "${FILESDIR}"/ldc2-1.15.0-link-defaultlib-shared.patch
+ "${FILESDIR}/${PN}"-1.36.0-disable-compiler-rt-sanitizers-tests.patch
+ "${FILESDIR}/${PN}"-1.36.0-lit-cfg-disable-gdb.patch
+
+ # https://github.com/dlang/phobos/pull/8956
+ "${FILESDIR}/${PN}"-1.36.0-fix-phobos-OS-dependent-test-string.patch
+ # https://github.com/ldc-developers/ldc/pull/4612
+ "${FILESDIR}/${PN}"-1.36.0-tests-dshell-remove--m-switch.patch
+ # https://github.com/ldc-developers/ldc/issues/4614#issuecomment-2034169152
+ "${FILESDIR}/${PN}"-remove-dmd-common-int128-unittest.patch
+)
+
+pkg_setup() {
+ dlang_setup
+ llvm-r1_pkg_setup
+ use test && python_setup
+}
+
+src_prepare(){
+ # Disable GDB tests by passing GDB_FLAGS=OFF
+ # Put this here to avoid trigerring reconfigurations later on.
+ sed -i 's/\(GDB_FLAGS=\)\S\+/\1OFF/' "${S}"/tests/dmd/CMakeLists.txt
+
+ cmake_src_prepare
+}
src_configure() {
# We disable assertions so we have to apply the same workaround as for
@@ -63,6 +102,89 @@ src_configure() {
cmake_src_configure
}
+src_test()
+{
+ # Call the same tests that .github/actions/main.yml does
+
+ local jobs=$(get_makeopts_jobs)
+
+ ### 4a-test-ldc2 ###
+
+ # We build it explicitly so that MAKEOPTS is respected
+ cmake_src_compile ldc2-unittest
+ cmake_src_test -R ldc2-unittest
+
+ ### 4b-test-lit ###
+
+ # https://github.com/ldc-developers/ldc/pull/4611
+ sed -i '1 iREQUIRES: PGO_RT' "${S}"/tests/PGO/final_switch_release.d || die
+
+ if [[ ${ARCH} == x86 ]]; then
+ # Fails on x86 due to stack coruption unrelated to the test.
+ # It has been fixed since.
+ rm -f "${S}"/tests/codegen/mangling.d || die
+ fi
+
+ # Instead of running cmake_src_test -R lit-tests we call lit directly
+ pushd "${BUILD_DIR}"/tests > /dev/null || die
+ "${EPYTHON}" runlit.py -j${jobs} -v . || die 'lit tests failed'
+ popd > /dev/null || die
+
+ ### 4c-test-dmd ###
+
+ # https://github.com/dlang/dmd/pull/16353
+ # Requires gdb but isn't named appropriately
+ mv "${S}"/tests/dmd/runnable/{,gdb-}b18504.d || die
+ # Calss gcc directly
+ sed -i "s/gcc/$(tc-getCC)/" "${S}"/tests/dmd/runnable/importc-test1.sh || die
+ # Fails on aarch64 due to int128
+ if [[ ${ARCH} == arm64 ]]; then
+ # https://github.com/dlang/dmd/pull/16352
+ rm -f "${S}"/tests/dmd/compilable/stdcheaders.c || die
+ fi
+
+ # These tests invoke a runner that runs the tests in parallel so
+ # specify the jobs only to the runner and not cmake. I'm pretty sure
+ # that some of the tests can't be run simultaniously by multiple
+ # runners so keep the cmake jobs to 1.
+ DMD_TESTSUITE_MAKE_ARGS=-j${jobs} cmake_src_test -j 1 -V -R dmd-testsuite
+
+ ### 4d-test-libs ###
+
+ # We compile the tests first so that $MAKEOPTS is respect, if
+ # compiled during the tests, nproc jobs will be used.
+ cmake_src_compile all-test-runners
+
+ local CMAKE_SKIP_TESTS=(
+ # These are the targets tested above
+ ldc2-unittest
+ lit-tests
+ dmd-testsuite
+
+ # These tests call gdb
+ druntime-test-exceptions
+ # Require valgrind
+ druntime-test-gc
+ druntime-test-valgrind
+
+ # This one fails due to an uncaught error, probably due to the
+ # sandbox.
+ druntime-test-cycles
+ )
+ if [[ ${ARCH} == arm64 ]]; then
+ # https://github.com/ldc-developers/ldc/issues/4613
+
+ # Hangs with optimizations (or segfaults)
+ CMAKE_SKIP_TESTS+=( core.thread.fiber )
+ # fails due to "innacuracy"
+ CMAKE_SKIP_TESTS+=( std.internal.math.gammafunction )
+ # Bad code generation with optimizations?
+ CMAKE_SKIP_TESTS+=( std.math.exponential )
+ fi
+
+ cmake_src_test
+}
+
src_install() {
cmake_src_install