Skip to content

Commit

Permalink
Add failing unit test in the single file package
Browse files Browse the repository at this point in the history
to check if unit tests from the main source file run at all. Because by default the main source file is excluded from tests.
  • Loading branch information
drug007 committed Dec 22, 2020
1 parent 4f21720 commit 4597c96
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,33 @@ unittest
else
writeln("\nOk. Unittest passed.");

return rc1;
// Check if dub `test` command runs unittests for single file package
{
filename = tempDir.buildPath("issue2051_fail.d");
auto f = File(filename, "w");
f.write(
`#!/usr/bin/env dub
/+ dub.sdl:
name "issue2051"
+/
version(unittest) {}
else void main()
{
}
unittest
{
assert(0);
}
` );
}

const rc2 = text(dub, " test --single ", filename).executeCommand;
if (rc2)
writeln("\nOk. Unittests failed.");
else
writeln("\nError. Unittest passed.");

return rc1 | !rc2;
}

0 comments on commit 4597c96

Please sign in to comment.