Skip to content

Commit ff67d05

Browse files
committed
Avoided running internal unit tests at start in release builds. You can now do this with a --run-tests argument if needed
1 parent 6a26c08 commit ff67d05

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

Source/CommandLine.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,27 @@ static void validate (CommandLineValidator& validator, const ArgumentList& args)
356356
}
357357
}
358358

359+
int getNumTestFailures (UnitTestRunner& testRunner)
360+
{
361+
int numFailures = 0;
362+
363+
for (int i = 0; i < testRunner.getNumResults(); ++i)
364+
if (auto result = testRunner.getResult (i))
365+
numFailures += result->failures;
366+
367+
return numFailures;
368+
}
369+
370+
void runUnitTests()
371+
{
372+
UnitTestRunner testRunner;
373+
testRunner.runTestsInCategory ("pluginval");
374+
const int numFailures = getNumTestFailures (testRunner);
375+
376+
if (numFailures > 0)
377+
ConsoleApplication::fail (String (numFailures) + " tests failed!!!");
378+
}
379+
359380
//==============================================================================
360381
void performCommandLine (CommandLineValidator& validator, const ArgumentList& args)
361382
{
@@ -368,6 +389,10 @@ void performCommandLine (CommandLineValidator& validator, const ArgumentList& ar
368389
"--validate [list]",
369390
"Validates the files (or IDs for AUs).", String(),
370391
[&validator] (const auto& args) { validate (validator, args); }});
392+
cli.addCommand ({ "--run-tests",
393+
"--run-tests",
394+
"Runs the internal unit tests.", String(),
395+
[] (const auto&) { runUnitTests(); }});
371396

372397
JUCEApplication::getInstance()->setApplicationReturnValue (cli.findAndRunCommand (args));
373398

@@ -380,7 +405,8 @@ bool shouldPerformCommandLine (const ArgumentList& args)
380405
{
381406
return args.containsOption ("--help|-h")
382407
|| args.containsOption ("--version")
383-
|| args.containsOption ("--validate");
408+
|| args.containsOption ("--validate")
409+
|| args.containsOption ("--run-tests");
384410
}
385411

386412
//==============================================================================

Source/Main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ class PluginValidatorApplication : public JUCEApplication,
4848
//==============================================================================
4949
void initialise (const String& commandLine) override
5050
{
51+
#if JUCE_DEBUG
5152
UnitTestRunner testRunner;
5253
testRunner.runTestsInCategory ("pluginval");
54+
#endif
5355

5456
if (shouldPerformCommandLine (commandLine))
5557
{

install/linux_build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ cd "$ROOT/Builds/LinuxMakefile"
7171
rm -rf $ROOT/Builds/LinuxMakefile/build/
7272
#make clean
7373
make CONFIG=Release -j4
74+
"$APP_FILE" --run-tests || exit 1
7475

7576

7677
#============================================================

install/mac_build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ rm -rf $ROOT/Builds/MacOSX/build/$PROJECT_NAME.build
7171
xcodebuild -configuration Release clean
7272
xcodebuild -configuration Release GCC_TREAT_WARNINGS_AS_ERRORS=YES
7373

74+
"$APP_FILE/Contents/MacOS/$PROJECT_NAME" --run-tests || exit 1
75+
7476
#============================================================
7577
# Sign with hardened runtime
7678
#============================================================

install/windows_build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ echo "Building products"
7575
cd "%ROOT%/Builds/VisualStudio2017"
7676
rd /S /Q "x64/Release"
7777
"%MSBUILD_EXE%" %PROJECT_NAME%.sln /p:VisualStudioVersion=15.0 /m /t:Build /p:Configuration=Release /p:Platform=x64 /p:PreferredToolArchitecture=x64 /p:TreatWarningsAsErrors=true
78-
78+
call "%APP_FILE%" --run-tests || exit 1
7979

8080
::============================================================
8181
:: Copy to deployment directory

0 commit comments

Comments
 (0)