From 4491303014785a88a9aa6ca3d5b70ae661f44a6c Mon Sep 17 00:00:00 2001 From: Ali Akhtarzada Date: Thu, 18 Jan 2018 23:44:40 +0100 Subject: [PATCH] Fix paths in benchmark runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On osx I was getting a “No such file” exception for Dante.txt because CWD depended on where I executed `rdmd benchmark.d` from. And the object files were generated in a directory also depending on that. This fixes obj dir to same level as bin dir within the benchmarks dir, and allows the runCmd to take a workDir parameter for running the benchmark executables --- benchmark/runbench.d | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/benchmark/runbench.d b/benchmark/runbench.d index 5284a7ea55..50c4e3a615 100755 --- a/benchmark/runbench.d +++ b/benchmark/runbench.d @@ -17,13 +17,13 @@ struct Config uint repeat = 10; } -string runCmd(string cmd, bool verbose) +string runCmd(string cmd, bool verbose, in char[] workDir = null) { import std.exception : enforce; - import std.process : executeShell; + import std.process : executeShell, Config; if (verbose) writeln(cmd); - auto res = executeShell(cmd); + auto res = executeShell(cmd, null, Config.none, size_t.max, workDir); enforce(res.status == 0, res.output); return res.output; } @@ -72,13 +72,15 @@ void runTests(Config cfg) import std.parallelism : parallel; immutable bindir = absolutePath("bin", cwd); + immutable objdir = absolutePath("obj", cwd); foreach(ref src; sources.parallel(1)) { writeln("COMPILING ", src); version (Windows) enum exe = "exe"; else enum exe = ""; auto bin = buildPath(bindir, src.relativePath(cwd).setExtension(exe)); - auto cmd = std.string.format("%s %s -op -odobj -of%s %s", cfg.dmd, cfg.dflags, bin, src); + auto obj = buildPath(objdir, src.relativePath(cwd).setExtension(exe)); + auto cmd = std.string.format("%s %s -op -od%s -of%s %s", cfg.dmd, cfg.dflags, obj, bin, src); if (auto ex = src in extra_sources) cmd ~= " -I" ~ src[0..$-2] ~ ".extra" ~ *ex; runCmd(cmd, cfg.verbose); @@ -109,7 +111,7 @@ void runTests(Config cfg) foreach (_; 0 .. cfg.repeat) { sw.reset; - auto output = runCmd(cmd, cfg.verbose); + auto output = runCmd(cmd, cfg.verbose, cwd); auto dur = cast(Duration)sw.peek; auto parts = dur.split!("seconds", "msecs");