Skip to content

Commit

Permalink
introduce per-combination output file and add to the arguments for po…
Browse files Browse the repository at this point in the history
…st-test scripts
  • Loading branch information
braddr committed Sep 25, 2012
1 parent 660cdab commit 260e7d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
5 changes: 4 additions & 1 deletion test/Makefile
Expand Up @@ -31,12 +31,15 @@
# default: the make variable ARGS (see below)
#
# POST_SCRIPT: name of script to execute after test run
# note: arguments to the script may be included after the name.
# additionally, the name of the file that contains the output
# of the compile/link/run steps is added as the last parameter.
# default: (none)
#
# REQUIRED_ARGS: arguments to add to the $(DMD) command line
# default: (none)
#
# DISABLED: text describing why the test is disabled (if empty, the test is
# DISABLED: text describing why the test is disabled (if empty, the test is
# considered to be enabled).
# default: (none, enabled)

Expand Down
25 changes: 17 additions & 8 deletions test/d_do_test.d
Expand Up @@ -341,6 +341,16 @@ int main(string[] args)
string[] toCleanup;
scope(exit) foreach (file; toCleanup) collectException(std.file.remove(file));

auto thisRunName = genTempFilename();
auto fThisRun = File(thisRunName, "w");
scope(exit)
{
fThisRun.close();
f.write(readText(thisRunName));
f.writeln();
removeIfExists(thisRunName);
}

string compile_output;
if (!testArgs.compileSeparately)
{
Expand All @@ -357,7 +367,7 @@ int main(string[] args)
join(testArgs.sources, " "));
version(Windows) command ~= " -map nul.map";

compile_output = execute(f, command, testArgs.mode != TestMode.FAIL_COMPILE);
compile_output = execute(fThisRun, command, testArgs.mode != TestMode.FAIL_COMPILE);
}
else
{
Expand All @@ -369,7 +379,7 @@ int main(string[] args)

string command = format("%s -m%s -I%s %s %s -od%s -c %s", envData.dmd, envData.model, input_dir,
testArgs.requiredArgs, c, output_dir, filename);
compile_output ~= execute(f, command, testArgs.mode != TestMode.FAIL_COMPILE);
compile_output ~= execute(fThisRun, command, testArgs.mode != TestMode.FAIL_COMPILE);
}

if (testArgs.mode == TestMode.RUN)
Expand All @@ -381,7 +391,7 @@ int main(string[] args)
// add after building the command so that before now, it's purely the .o's involved
toCleanup ~= test_app_dmd;

execute(f, command, true);
execute(fThisRun, command, true);
}
}

Expand All @@ -400,18 +410,17 @@ int main(string[] args)
string command = test_app_dmd;
if (testArgs.executeArgs) command ~= " " ~ testArgs.executeArgs;

execute(f, command, true);
execute(fThisRun, command, true);
}

fThisRun.close();

if (testArgs.postScript)
{
f.write("Executing post-test script: ");
version (Windows) testArgs.postScript = "bash " ~ testArgs.postScript;
execute(f, testArgs.postScript, true);
execute(f, testArgs.postScript ~ " " ~ thisRunName, true);
}

f.writeln();

}
catch(Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion test/runnable/extra-files/statictor-postscript.sh
Expand Up @@ -2,7 +2,7 @@

# trim off the first line which contains the path of the file which differs between windows and non-windows
# also trim off compiler debug message
grep -v "runnable\|DEBUG" ${RESULTS_DIR}/runnable/statictor.d.out > ${RESULTS_DIR}/runnable/statictor.d.out.2
grep -v "runnable\|DEBUG" $1 > ${RESULTS_DIR}/runnable/statictor.d.out.2

diff --strip-trailing-cr runnable/extra-files/statictor.d.out ${RESULTS_DIR}/runnable/statictor.d.out.2
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 260e7d8

Please sign in to comment.