Skip to content

Commit

Permalink
[try fix]
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Dec 17, 2023
1 parent 1a226bb commit 013df08
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 17 additions & 2 deletions rdmd_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 013df08

Please sign in to comment.