Skip to content

Commit

Permalink
Merge pull request #275 from marler8997/rdmd_test_relative
Browse files Browse the repository at this point in the history
Make rdmd_test.exe work with relative --compiler binary
merged-on-behalf-of: Petar Kirov <[email protected]>
  • Loading branch information
dlang-bot authored Dec 18, 2017
2 parents fd97cae + d337ac4 commit 193492c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rdmd_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ string rdmdApp; // path/to/rdmd.exe (once built)
string compiler = "dmd"; // e.g. dmd/gdmd/ldmd
string model = "64"; // build architecture for dmd
string[] rdmdArgs; // path to rdmd + common arguments (compiler, model)
bool verbose = false;

void main(string[] args)
{
Expand All @@ -56,13 +57,18 @@ void main(string[] args)
"rdmd", &rdmd,
"concurrency", &concurrencyTest,
"m|model", &model,
"v|verbose", &verbose,
);

enforce(rdmd.exists, "Path to rdmd does not exist: %s".format(rdmd));

rdmdApp = tempDir().buildPath("rdmd_app_") ~ binExt;
if (rdmdApp.exists) std.file.remove(rdmdApp);

// compiler needs to be an absolute path because we change directories
if (compiler.canFind!isDirSeparator)
compiler = buildNormalizedPath(compiler.absolutePath());

auto res = execute([compiler, modelSwitch, "-of" ~ rdmdApp, rdmd]);

enforce(res.status == 0, res.output);
Expand All @@ -78,6 +84,14 @@ void main(string[] args)
@property string compilerSwitch() { return "--compiler=" ~ compiler; }
@property string modelSwitch() { return "-m" ~ model; }

auto execute(T...)(T args)
{
import std.stdio : writefln;
if (verbose)
writefln("[execute] %s", args[0]);
return std.process.execute(args);
}

void runTests()
{
/* Test help string output when no arguments passed. */
Expand Down

0 comments on commit 193492c

Please sign in to comment.