Skip to content

Commit 7d000ba

Browse files
authored
various small improvements (#119)
* Add newLines to usage-information Closes: #116 * group flags in usage-text by functionality make sure that the lines are no longer than 80chars and fix some typos * Use ISO-8601 as the time-format for logfiles Related: #117 * Allow specifying the output-filename Closes: #117 * Print "SUCCESS" after successully validating a plugin Closes: #118
1 parent 60d1332 commit 7d000ba

File tree

3 files changed

+90
-30
lines changed

3 files changed

+90
-30
lines changed

Source/CommandLine.cpp

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ namespace
178178
return getOptionValue (args, "--output-dir", {}, "Missing output-dir path argument!").toString();
179179
}
180180

181+
juce::String getOutputFilename (const juce::ArgumentList& args)
182+
{
183+
return getOptionValue (args, "--output-filename", {}, "Missing output-filename path argument!").toString();
184+
}
185+
181186
std::vector<double> getSampleRates (const juce::ArgumentList& args)
182187
{
183188
juce::StringArray input = juce::StringArray::fromTokens (getOptionValue (args,
@@ -272,6 +277,7 @@ static Option possibleOptions[] =
272277
{ "--skip-gui-tests", false },
273278
{ "--data-file", true },
274279
{ "--output-dir", true },
280+
{ "--output-filename", true },
275281
{ "--repeat", true },
276282
{ "--randomise", false },
277283
{ "--sample-rates", true },
@@ -323,48 +329,82 @@ static juce::String getHelpMessage()
323329
<< " Validate plugins to test compatibility with hosts and verify plugin API conformance" << newLine << newLine
324330
<< "Usage: "
325331
<< newLine
332+
// commands
333+
<< " --version" << newLine
334+
<< " Print pluginval version." << newLine
326335
<< " --validate [pathToPlugin]" << newLine
327336
<< " Validates the plugin at the given path." << newLine
328-
<< " N.B. the --validate flag is optional if the path is the last argument. This enables you to validate a plugin with simply \"pluginval path_to_plugin\"." << newLine
329-
<< " --strictness-level [1-10]" << newLine
330-
<< " Sets the strictness level to use. A minimum level of 5 (also the default) is recomended for compatibility. Higher levels include longer, more thorough tests such as fuzzing." << newLine
337+
<< " N.B. the \"--validate\" flag is optional if the path is the last argument." << newLine
338+
<< " This enables you to validate a plugin with simply \"pluginval path_to_plugin\"." << newLine
339+
<< newLine
340+
// what to test
341+
<< " --sample-rates [list of comma separated sample rates]" << newLine
342+
<< " If specified, sets the list of sample rates at which tests will be executed" << newLine
343+
<< " (default=44100,48000,96000)" << newLine
344+
<< " --block-sizes [list of comma separated block sizes]" << newLine
345+
<< " If specified, sets the list of block sizes at which tests will be executed" << newLine
346+
<< " (default=64,128,256,512,1024)" << newLine
331347
<< " --random-seed [hex or int]" << newLine
332-
<< " Sets the random seed to use for the tests. Useful for replicating test environments." << newLine
348+
<< " Sets the random seed to use for the tests. Useful for replicating test" << newLine
349+
<< " environments." << newLine
350+
<< " --data-file [pathToFile]" << newLine
351+
<< " If specified, sets a path to a data file which can be used by tests to" << newLine
352+
<< " configure themselves. This can be useful for things like known audio output." << newLine
353+
<< newLine
354+
// how to test
355+
<< " --strictness-level [1-10]" << newLine
356+
<< " Sets the strictness level to use. A minimum level of 5 (also the default)" << newLine
357+
<< " is recomended for compatibility." << newLine
358+
<< " Higher levels include longer, more thorough tests such as fuzzing." << newLine
333359
<< " --timeout-ms [numMilliseconds]" << newLine
334-
<< " Sets a timout which will stop validation with an error if no output from any test has happened for this number of ms." << newLine
360+
<< " Sets a timout which will stop validation with an error if no output from any" << newLine
361+
<< " test has happened for this number of ms." << newLine
335362
<< " By default this is 30s but can be set to -1 to never timeout." << newLine
336-
<< " --verbose" << newLine
337-
<< " If specified, outputs additional logging information. It can be useful to turn this off when building with CI to avoid huge log files." << newLine
338-
<< " --skip-gui-tests" << newLine
339-
<< " If specified, avoids tests that create GUI windows, which can cause problems on headless CI systems." << newLine
363+
<< newLine
364+
// repeating tests
340365
<< " --repeat [num repeats]" << newLine
341-
<< " If specified repeats the tests a given number of times. Note that this does not delete and re-instantiate the plugin for each repeat."
366+
<< " If specified repeats the tests a given number of times. Note that this does" << newLine
367+
<< " not delete and re-instantiate the plugin for each repeat." << newLine
342368
<< " --randomise" << newLine
343-
<< " If specified the tests are run in a random order per repeat."
344-
<< " --data-file [pathToFile]" << newLine
345-
<< " If specified, sets a path to a data file which can be used by tests to configure themselves. This can be useful for things like known audio output." << newLine
346-
<< " --output-dir [pathToDir]" << newLine
347-
<< " If specified, sets a directory to store the log files. This can be useful for continuous integration." << newLine
369+
<< " If specified, the tests are run in a random order per repeat." << newLine
370+
<< newLine
371+
// test selection
372+
<< " --skip-gui-tests" << newLine
373+
<< " If specified, avoids tests that create GUI windows, which can cause problems" << newLine
374+
<< " on headless CI systems." << newLine
348375
<< " --disabled-tests [pathToFile]" << newLine
349-
<< " If specified, sets a path to a file that should have the names of disabled tests on each row." << newLine
350-
<< " --sample-rates [list of comma separated sample rates]" << newLine
351-
<< " If specified, sets the list of sample rates at which tests will be executed (default=44100,48000,96000)" << newLine
352-
<< " --block-sizes [list of comma separated block sizes]" << newLine
353-
<< " If specified, sets the list of block sizes at which tests will be executed (default=64,128,256,512,1024)" << newLine
376+
<< " If specified, sets a path to a file that should have the names of disabled" << newLine
377+
<< " tests on each row." << newLine
378+
// external validators
354379
<< " --vst3validator [pathToValidator]" << newLine
355380
<< " If specified, this will run the VST3 validator as part of the test process." << newLine
356-
<< " --version" << newLine
357-
<< " Print pluginval version." << newLine
381+
<< newLine
382+
// output
383+
<< " --output-dir [pathToDir]" << newLine
384+
<< " If specified, sets a directory to store the log files. This can be useful" << newLine
385+
<< " for continuous integration." << newLine
386+
<< " --output-filename [filename]" << newLine
387+
<< " If specified, sets a filename for the log files (within 'output-dir' or" << newLine
388+
<< " (lacking that) the current directory." << newLine
389+
<< " By default, the name is constructed from the plugin metainformation" << newLine
390+
<< " --verbose" << newLine
391+
<< " If specified, outputs additional logging information. It can be useful to" << newLine
392+
<< " turn this off when building with CI to avoid huge log files." << newLine
393+
394+
// end of options
358395
<< newLine
359396
<< "Exit code: "
360397
<< newLine
361398
<< " 0 if all tests complete successfully" << newLine
362399
<< " 1 if there are any errors" << newLine
363400
<< newLine
364-
<< "Additionally, you can specify any of the command line options as environment varibles by removing prefix dashes,"
365-
" converting internal dashes to underscores and captialising all letters e.g. \"--skip-gui-tests\" > \"SKIP_GUI_TESTS=1\","
366-
" \"--timeout-ms 30000\" > \"TIMEOUT_MS=30000\"" << newLine
367-
<< "Specifying specific command-line options will override any environment variables set for that option." << newLine;
401+
<< "Additionally, you can specify any of the command line options as environment" << newLine
402+
<< "variables by removing prefix dashes, converting internal dashes to underscores" << newLine
403+
<< "and capitalising all letters, a.g." << newLine
404+
<< " \"--skip-gui-tests\" > \"SKIP_GUI_TESTS=1\"" << newLine
405+
<< " \"--timeout-ms 30000\" > \"TIMEOUT_MS=30000\"" << newLine
406+
<< "Specifying specific command-line options will override any environment variables" << newLine
407+
<< "set for that option." << newLine;
368408

369409
return help;
370410
}
@@ -504,6 +544,7 @@ std::pair<juce::String, PluginTests::Options> parseCommandLine (const juce::Argu
504544
options.randomiseTestOrder = args.containsOption ("--randomise");
505545
options.dataFile = getDataFile (args);
506546
options.outputDir = getOutputDir (args);
547+
options.outputFilename = getOutputFilename (args);
507548
options.withGUI = ! args.containsOption ("--skip-gui-tests");
508549
options.disabledTests = getDisabledTests (args);
509550
options.sampleRates = getSampleRates (args);
@@ -550,6 +591,9 @@ juce::StringArray createCommandLine (juce::String fileOrID, PluginTests::Options
550591
if (options.outputDir != defaults.outputDir)
551592
args.addArray ({ "--output-dir", options.outputDir.getFullPathName() });
552593

594+
if (options.outputFilename != defaults.outputFilename)
595+
args.addArray ({ "--output-filename", options.outputFilename });
596+
553597
if (options.disabledTests != defaults.disabledTests)
554598
args.addArray ({ "--disabled-tests", options.disabledTests.joinIntoString (",") });
555599

Source/PluginTests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct PluginTests : public juce::UnitTest
3535
bool withGUI = true; /**< Whether or not avoid tests that instantiate a gui. */
3636
juce::File dataFile; /**< juce::File which tests can use to run user provided data. */
3737
juce::File outputDir; /**< Directory in which to write the log files for each test run. */
38+
juce::String outputFilename; /**< Filename to write logs into */
3839
juce::StringArray disabledTests; /**< List of disabled tests. */
3940
std::vector<double> sampleRates; /**< List of sample rates. */
4041
std::vector<int> blockSizes; /**< List of block sizes. */

Source/Validator.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,30 @@ static juce::String getFileNameFromDescription (PluginTests& test)
119119
return "pluginval Log";
120120
};
121121

122-
return getBaseName() + "_" + juce::Time::getCurrentTime().toString (true, true).replace (":", ",") + ".txt";
122+
return getBaseName() + "_" + juce::Time::getCurrentTime().toISO8601 (false).replace (":", ",") + ".txt";
123123
}
124124

125125
static juce::File getDestinationFile (PluginTests& test)
126126
{
127127
const auto dir = test.getOptions().outputDir;
128+
const auto filename = test.getOptions().outputFilename;
128129

129130
if (dir == juce::File())
130-
return {};
131+
{
132+
if (juce::String() == filename)
133+
return {};
134+
return juce::File(filename);
135+
}
131136

132137
if (dir.existsAsFile() || ! dir.createDirectory())
133138
{
134139
jassertfalse;
135140
return {};
136141
}
137142

138-
return dir.getChildFile (getFileNameFromDescription (test));
143+
if (juce::String() == filename)
144+
return dir.getChildFile (getFileNameFromDescription (test));
145+
return dir.getChildFile (filename);
139146
}
140147

141148
static std::unique_ptr<juce::FileOutputStream> createDestinationFileStream (PluginTests& test)
@@ -162,7 +169,8 @@ static void updateFileNameIfPossible (PluginTests& test, PluginsUnitTestRunner&
162169
if (auto os = runner.getOutputFileStream())
163170
{
164171
const auto sourceFile = os->getFile();
165-
const auto destName = getFileNameFromDescription (test);
172+
const auto filename = test.getOptions().outputFilename;
173+
const auto destName = (filename == juce::String())?getFileNameFromDescription (test) : filename;
166174

167175
if (destName.isEmpty() || sourceFile.getFileName() == destName)
168176
return;
@@ -176,6 +184,8 @@ static void updateFileNameIfPossible (PluginTests& test, PluginsUnitTestRunner&
176184

177185
//==============================================================================
178186
//==============================================================================
187+
inline int getNumFailures (juce::Array<juce::UnitTestRunner::TestResult> results);
188+
179189
inline juce::Array<juce::UnitTestRunner::TestResult> runTests (PluginTests& test, std::function<void (const juce::String&)> callback)
180190
{
181191
const auto options = test.getOptions();
@@ -191,6 +201,11 @@ inline juce::Array<juce::UnitTestRunner::TestResult> runTests (PluginTests& test
191201
results.add (*testRunner.getResult (i));
192202

193203
updateFileNameIfPossible (test, testRunner);
204+
const int failures = getNumFailures (results);
205+
if (!failures)
206+
testRunner.logMessage("SUCCESS");
207+
else
208+
testRunner.logMessage("FAILURE");
194209

195210
return results;
196211
}

0 commit comments

Comments
 (0)