Skip to content

Commit

Permalink
Merge pull request #936 from llucax/disabled-tests
Browse files Browse the repository at this point in the history
Add a new DISABLED option for tests
  • Loading branch information
WalterBright committed May 12, 2012
2 parents eb00878 + a360038 commit c4c0bf3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/Makefile
Expand Up @@ -35,6 +35,10 @@
#
# 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
# considered to be enabled).
# default: (none, enabled)

ifeq (,$(OS))
OS:=$(shell uname)
Expand Down
21 changes: 20 additions & 1 deletion test/d_do_test.d
Expand Up @@ -51,6 +51,9 @@ struct TestArgs
string permuteArgs;
string postScript;
string requiredArgs;
// reason for disabling the test (if empty, the test is not disabled)
string disabled_reason;
@property bool disabled() { return disabled_reason != ""; }
}

struct EnvData
Expand Down Expand Up @@ -143,6 +146,8 @@ void gatherTestParameters(ref TestArgs testArgs, string input_dir, string input_
string compileSeparatelyStr;
testArgs.compileSeparately = findTestParameter(file, "COMPILE_SEPARATELY", compileSeparatelyStr);

findTestParameter(file, "DISABLED", testArgs.disabled_reason);

if (findTestParameter(file, "POST_SCRIPT", testArgs.postScript))
testArgs.postScript = replace(testArgs.postScript, "/", to!string(envData.sep));
}
Expand Down Expand Up @@ -274,12 +279,17 @@ int main(string[] args)

gatherTestParameters(testArgs, input_dir, input_file, envData);

writefln(" ... %-30s %s%s(%s)",
writef(" ... %-30s %s%s(%s)",
input_file,
testArgs.requiredArgs,
(testArgs.requiredArgs ? " " : ""),
testArgs.permuteArgs);

if (testArgs.disabled)
writefln("!!! [DISABLED: %s]", testArgs.disabled_reason);
else
write("\n");

if (std.file.exists(output_file))
std.file.remove(output_file);

Expand Down Expand Up @@ -355,9 +365,14 @@ int main(string[] args)
collectException(std.file.remove(file));

f.writeln();

}
catch(Exception e)
{
// it failed but it was disabled, exit as if it was successful
if (testArgs.disabled)
return 0;

f.writeln();
f.writeln("==============================");
f.writeln("Test failed: ", e.msg);
Expand All @@ -373,6 +388,10 @@ int main(string[] args)
}
}

// it was disabled but it passed! print an informational message
if (testArgs.disabled)
writefln(" !!! %-30s DISABLED but PASSES!", input_file);

return 0;
}

0 comments on commit c4c0bf3

Please sign in to comment.