mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Support running individual tests or suites
Add back some functionality that got dropped with the move to a custom
runner in 39ea3b6ea5
Add option --list to print all available test grouped by suite.
Add option --suite to limit the run to a specific testsuite.
Add option --test to limit the run to a specific test.
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
019374d5c7
commit
a7d65d4a34
1 changed files with 65 additions and 7 deletions
|
|
@ -1,21 +1,23 @@
|
|||
// vim: set filetype=cpp :
|
||||
|
||||
#include <cstring>
|
||||
#include <cxxtest/Descriptions.h>
|
||||
#include <cxxtest/ErrorPrinter.h>
|
||||
#include <cxxtest/XmlPrinter.h>
|
||||
|
||||
#include <ps/DllLoader.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <ps/DllLoader.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
void usage(const char* prog) {
|
||||
const std::string help = std::string("Usage: ") + prog + R"( [options]
|
||||
|
||||
--libdir dir Where to find extra shared libraries, used for running tests in staging area
|
||||
--format junit|simple simple: default, good for cli - junit: for use by CI
|
||||
--output file File to write to, defaults to stdout
|
||||
--help This message
|
||||
--libdir dir Where to find extra shared libraries, used for running tests in staging area
|
||||
--list List available test by suite
|
||||
--output file File to write to, defaults to stdout
|
||||
--suite suite Only run named suite
|
||||
--test test Only run named test of given suite
|
||||
)";
|
||||
std::printf("%s\n", help.c_str());
|
||||
}
|
||||
|
|
@ -23,6 +25,8 @@ void usage(const char* prog) {
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
char* suite = nullptr;
|
||||
char* test = nullptr;
|
||||
bool xml = false;
|
||||
std::ostream* output = &std::cout;
|
||||
std::ofstream out;
|
||||
|
|
@ -60,7 +64,6 @@ int main(int argc, char **argv)
|
|||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else if (std::strcmp(argv[i], "--output") == 0)
|
||||
{
|
||||
if (++i >= argc)
|
||||
|
|
@ -73,6 +76,36 @@ int main(int argc, char **argv)
|
|||
out.open(argv[i]);
|
||||
output = &out;
|
||||
}
|
||||
else if (std::strcmp(argv[i], "--list") == 0)
|
||||
{
|
||||
for (CxxTest::SuiteDescription *sd = CxxTest::RealWorldDescription().firstSuite(); sd; sd = sd->next())
|
||||
{
|
||||
std::printf("%s\n", sd->suiteName());
|
||||
for (CxxTest::TestDescription *td = sd->firstTest(); td; td = td->next())
|
||||
std::printf(" %s\n", td->testName());
|
||||
}
|
||||
std::exit(0);
|
||||
}
|
||||
else if (std::strcmp(argv[i], "--suite") == 0)
|
||||
{
|
||||
if (++i >= argc)
|
||||
{
|
||||
std::printf("Option suite requires an optarg\n\n");
|
||||
usage(argv[0]);
|
||||
std::exit(1);
|
||||
}
|
||||
suite = argv[i];
|
||||
}
|
||||
else if (std::strcmp(argv[i], "--test") == 0)
|
||||
{
|
||||
if (++i >= argc)
|
||||
{
|
||||
std::printf("Option test requires an optarg\n\n");
|
||||
usage(argv[0]);
|
||||
std::exit(1);
|
||||
}
|
||||
test = argv[i];
|
||||
}
|
||||
else if (std::strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
usage(argv[0]);
|
||||
|
|
@ -86,6 +119,31 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (test)
|
||||
{
|
||||
if (!suite)
|
||||
{
|
||||
std::printf("test needs a suite specified\n\n");
|
||||
usage(argv[0]);
|
||||
std::exit(1);
|
||||
}
|
||||
if (!CxxTest::leaveOnly(suite, test))
|
||||
{
|
||||
std::printf("Unknown test '%s' in suite '%s'\n\n", test, suite);
|
||||
usage(argv[0]);
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
else if (suite)
|
||||
{
|
||||
if (!CxxTest::leaveOnly(suite))
|
||||
{
|
||||
std::printf("Unknown suite '%s'\n\n", suite);
|
||||
usage(argv[0]);
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (xml)
|
||||
return CxxTest::XmlPrinter(*output).run();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue