Browse Source

Removed ScopedJuceInitialiser_GUI from UnitTestRunner and added a --seed command-line option for specifying the random seed to be used for the tests

tags/2021-05-28
ed 6 years ago
parent
commit
fc392ee3a5
1 changed files with 20 additions and 25 deletions
  1. +20
    -25
      extras/UnitTestRunner/Source/Main.cpp

+ 20
- 25
extras/UnitTestRunner/Source/Main.cpp View File

@@ -52,39 +52,34 @@ class ConsoleUnitTestRunner : public UnitTestRunner
//==============================================================================
int main (int argc, char **argv)
{
// Needed for tests that require a message thread
ScopedJuceInitialiser_GUI guiInitialiser;
ArgumentList args (argc, argv);
if (args.containsOption ("--help|-h"))
{
std::cout << argv[0] << " [--help|-h] [--list-categories] [--category category] [--seed seed]" << std::endl;
return 0;
}
if (args.containsOption ("--list-categories"))
{
for (auto& category : UnitTest::getAllCategories())
std::cout << category << std::endl;
return 0;
}
ConsoleLogger logger;
Logger::setCurrentLogger (&logger);
ConsoleUnitTestRunner runner;
ArgumentList args (argc, argv);
auto seed = (args.containsOption ("--seed") ? args.getValueForOption ("--seed").getLargeIntValue()
: Random::getSystemRandom().nextInt64());
if (args.size() == 0)
{
runner.runAllTests();
}
if (args.containsOption ("--category"))
runner.runTestsInCategory (args.getValueForOption ("--category"), seed);
else
{
if (args.containsOption ("--help|-h"))
{
std::cout << argv[0] << " [--help|-h] [--category category] [--list-categories]" << std::endl;
return 0;
}
if (args.containsOption ("--list-categories"))
{
for (auto& category : UnitTest::getAllCategories())
std::cout << category << std::endl;
return 0;
}
if (args.containsOption ("--category"))
runner.runTestsInCategory (args.getValueForOption ("--category"));
}
runner.runAllTests (seed);
Logger::setCurrentLogger (nullptr);


Loading…
Cancel
Save