From 5ffca7b0e097644fbcffbee8ba755e4ae48c9d9f Mon Sep 17 00:00:00 2001 From: anonymous Date: Mon, 20 Feb 2017 11:43:34 +0100 Subject: [PATCH] fix issue 17198 - rdmd does not recompile when --extra-file is added --- rdmd.d | 1 + rdmd_test.d | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/rdmd.d b/rdmd.d index 9caa945..7ac2731 100644 --- a/rdmd.d +++ b/rdmd.d @@ -412,6 +412,7 @@ private string getWorkPath(in string root, in string[] compilerFlags) if (irrelevantSwitches.canFind(flag)) continue; context.put(flag.representation); } + foreach (f; extraFiles) context.put(f.representation); auto digest = context.finish(); string hash = toHexString(digest); diff --git a/rdmd_test.d b/rdmd_test.d index 1b2e2ac..33a0187 100644 --- a/rdmd_test.d +++ b/rdmd_test.d @@ -446,7 +446,7 @@ void runTests() /* [REG2.072.0] pragma(lib) is broken with rdmd: https://issues.dlang.org/show_bug.cgi?id=16978 */ version (linux) - { + {{ TmpDir srcDir = "rdmdTest"; string libSrcName = srcDir.buildPath("libfun.d"); std.file.write(libSrcName, `extern(C) void fun() {}`); @@ -460,7 +460,7 @@ void runTests() res = execute([rdmdApp, compilerSwitch, "-L-L" ~ srcDir, mainSrcName]); assert(res.status == 0, res.output); - } + }} /* https://issues.dlang.org/show_bug.cgi?id=16966 */ { @@ -473,6 +473,25 @@ void runTests() assert(exists(voidMainExe)); remove(voidMainExe); } + + /* https://issues.dlang.org/show_bug.cgi?id=17198 - rdmd does not recompile + when --extra-file is added */ + { + TmpDir srcDir = "rdmdTest"; + immutable string src1 = srcDir.buildPath("test.d"); + immutable string src2 = srcDir.buildPath("test2.d"); + std.file.write(src1, "int x = 1; int main() { return x; }"); + std.file.write(src2, "import test; static this() { x = 0; }"); + + res = execute([rdmdApp, compilerSwitch, src1]); + assert(res.status == 1, res.output); + + res = execute([rdmdApp, compilerSwitch, "--extra-file=" ~ src2, src1]); + assert(res.status == 0, res.output); + + res = execute([rdmdApp, compilerSwitch, src1]); + assert(res.status == 1, res.output); + } } void runConcurrencyTest()