From 013df087ae87409af4510ea3ecda3dfca92caa5c Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 17 Dec 2023 20:30:06 +0100 Subject: [PATCH] [try fix] --- Makefile | 15 ++++++++++++--- rdmd_test.d | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c020f81a7..a28438844 100644 --- a/Makefile +++ b/Makefile @@ -97,12 +97,21 @@ $(ROOT)/tests_extractor$(DOTEXE): tests_extractor.d # Build & run tests ################################################################################ +ifeq (windows,$(OS)) + # for some reason, --strip-trailing-cr isn't enough - need to dos2unix stdin + DIFF := dos2unix | diff --strip-trailing-cr +else + DIFF := diff +endif + +DOS2UNIX:=$(if $(findstring windows,$(OS)),| dos2unix,) + test_tests_extractor: $(ROOT)/tests_extractor$(DOTEXE) for file in ascii iteration ; do \ - $< -i "./test/tests_extractor/$${file}.d" | diff -u --strip-trailing-cr -p - "./test/tests_extractor/$${file}.d.ext"; \ + $< -i "./test/tests_extractor/$${file}.d" | $(DIFF) -u -p - "./test/tests_extractor/$${file}.d.ext"; \ done - $< -a betterc -i "./test/tests_extractor/attributes.d" | diff -u --strip-trailing-cr -p - "./test/tests_extractor/attributes.d.ext"; - $< --betterC -i "./test/tests_extractor/betterc.d" | diff -u --strip-trailing-cr -p - "./test/tests_extractor/betterc.d.ext"; + $< -a betterc -i "./test/tests_extractor/attributes.d" | $(DIFF) -u -p - "./test/tests_extractor/attributes.d.ext"; + $< --betterC -i "./test/tests_extractor/betterc.d" | $(DIFF) -u -p - "./test/tests_extractor/betterc.d.ext"; RDMD_TEST_COMPILERS = $(DMD) RDMD_TEST_EXECUTABLE = $(ROOT)/rdmd$(DOTEXE) diff --git a/rdmd_test.d b/rdmd_test.d index 77f02e0bd..cb7cd2f07 100755 --- a/rdmd_test.d +++ b/rdmd_test.d @@ -684,11 +684,26 @@ void runFallbackTest(string rdmdApp, string buildCompiler, string model) if an explicit --compiler flag is not provided, rdmd should search its own binary path first when looking for the default compiler (determined by the compiler used to build it) */ - string localDMD = buildPath(tempDir(), baseName(buildCompiler).setExtension(binExt)); + string localDMD = buildPath(dirName(rdmdApp), baseName(buildCompiler).setExtension(binExt)); std.file.write(localDMD, ""); // An empty file avoids the "Not a valid 16-bit application" pop-up on Windows scope(exit) std.file.remove(localDMD); auto res = execute(rdmdApp ~ [modelSwitch(model), "--force", "--chatty", "--eval=writeln(`Compiler found.`);"]); enforce(res.status == 1, res.output); - enforce(res.output.canFind(format(`spawn [%(%s%),`, localDMD.only)), localDMD ~ " would not have been executed. Output:\n" ~ res.output); + + bool didSpawnExecutable(string executable) { + return res.output.canFind(format(`spawn [%(%s%),`, executable.only)); + } + + auto spawned = didSpawnExecutable(localDMD); + version (OSX) + { + // weird stuff for GitHub Actions at least: + // * localDMD is absolute `/var/folders/3s/vfzpb5r51gs6y328rmlgzm7c0000gn/T/dmd` + // * rdmd tries to spawn `/private/var/folders/3s/vfzpb5r51gs6y328rmlgzm7c0000gn/T/dmd` + if (!spawned) + spawned = didSpawnExecutable("/private" ~ localDMD); + } + + enforce(spawned, localDMD ~ " would not have been executed. Output:\n" ~ res.output); }