@@ -22,7 +22,7 @@ struct CommandLineTests : public UnitTest
2222
2323 void runTest () override
2424 {
25-
25+
2626 beginTest (" Merge environment variables" );
2727 {
2828 StringPairArray envVars;
@@ -61,13 +61,84 @@ struct CommandLineTests : public UnitTest
6161
6262 beginTest (" Command line parser" );
6363 {
64- ArgumentList args ({}, " --strictness-level 7 --random-seed 1234 --timeout-ms 20000 --repeat 11 --data-file <path_to_file> --output-dir <path_to_dir> " );
64+ ArgumentList args ({}, " --strictness-level 7 --random-seed 1234 --timeout-ms 20000 --repeat 11 --data-file /path/to/file --output-dir /path/to/dir --validate /path/to/plugin " );
6565 expectEquals (getStrictnessLevel (args), 7 );
6666 expectEquals (getRandomSeed (args), (int64) 1234 );
6767 expectEquals (getTimeout (args), (int64) 20000 );
6868 expectEquals (getNumRepeats (args), 11 );
69- expectEquals (getOptionValue (args, " --data-file" , {}, " Missing data-file path argument!" ).toString (), String (" <path_to_file>" ));
70- expectEquals (getOptionValue (args, " --output-dir" , {}, " Missing output-dir path argument!" ).toString (), String (" <path_to_dir>" ));
69+ expectEquals (getOptionValue (args, " --data-file" , {}, " Missing data-file path argument!" ).toString (), String (" /path/to/file" ));
70+ expectEquals (getOptionValue (args, " --output-dir" , {}, " Missing output-dir path argument!" ).toString (), String (" /path/to/dir" ));
71+ expectEquals (getOptionValue (args, " --validate" , {}, " Missing validate argument!" ).toString (), String (" /path/to/plugin" ));
72+ }
73+
74+ beginTest (" Handles an absolute path to the plugin" );
75+ {
76+ const auto homeDir = File::getSpecialLocation (File::userHomeDirectory).getFullPathName ();
77+ const auto commandLineString = " --validate " + homeDir + " /path/to/MyPlugin" ;
78+ const auto args = createCommandLineArgs (commandLineString);
79+ expectEquals (parseCommandLine (args).first , homeDir + " /path/to/MyPlugin" );
80+ }
81+
82+ beginTest (" Handles a quoted absolute path to the plugin" );
83+ {
84+ const auto homeDir = File::getSpecialLocation (File::userHomeDirectory).getFullPathName ();
85+ const auto pathToQuote = homeDir + " /path/to/MyPlugin" ;
86+ const auto commandLineString = " --validate " + pathToQuote.quoted ();
87+ const auto args = createCommandLineArgs (commandLineString);
88+ expectEquals (parseCommandLine (args).first , homeDir + " /path/to/MyPlugin" );
89+ }
90+
91+ beginTest (" Handles a relative path" );
92+ {
93+ const auto currentDir = File::getCurrentWorkingDirectory ();
94+ const auto args = createCommandLineArgs (" --validate MyPlugin.vst3" );
95+ expectEquals (parseCommandLine (args).first , currentDir.getChildFile (" MyPlugin.vst3" ).getFullPathName ());
96+ }
97+
98+ beginTest (" Handles a quoted relative path with spaces to the plugin" );
99+ {
100+ const auto currentDir = File::getCurrentWorkingDirectory ();
101+ const auto args = createCommandLineArgs (R"( --validate "My Plugin.vst3")" );
102+ expectEquals (parseCommandLine (args).first , currentDir.getChildFile (" My Plugin.vst3" ).getFullPathName ());
103+ }
104+
105+ #if !JUCE_WINDOWS
106+
107+ beginTest (" Handles a relative path with ./ to the plugin" );
108+ {
109+ const auto currentDir = File::getCurrentWorkingDirectory ().getFullPathName ();
110+ const auto commandLineString = " --validate ./path/to/MyPlugin" ;
111+ const auto args = createCommandLineArgs (commandLineString);
112+ expectEquals (parseCommandLine (args).first , currentDir + " /path/to/MyPlugin" );
113+ }
114+
115+ beginTest (" Handles a home directory relative path to the plugin" );
116+ {
117+ const auto commandLineString = " --validate ~/path/to/MyPlugin" ;
118+ const auto args = createCommandLineArgs (commandLineString);
119+ expectEquals (parseCommandLine (args).first , File::getSpecialLocation (File::userHomeDirectory).getFullPathName () + " /path/to/MyPlugin" );
120+ }
121+
122+ beginTest (" Handles quoted strings, spaces, and home directory relative path to the plugin" );
123+ {
124+ const auto commandLineString = R"( --data-file "~/path/to/My File" --output-dir "~/path/to/My Directory" --validate "~/path/to/My Plugin")" ;
125+ const auto args = createCommandLineArgs (commandLineString);
126+ expectEquals (parseCommandLine (args).first , File::getSpecialLocation (File::userHomeDirectory).getFullPathName () + " /path/to/My Plugin" );
127+ }
128+ #endif
129+
130+ beginTest (" Implicit validate with a relative path" );
131+ {
132+ const auto currentDir = File::getCurrentWorkingDirectory ();
133+ const auto args = createCommandLineArgs (" MyPlugin.vst3" );
134+ expectEquals (parseCommandLine (args).first , currentDir.getChildFile (" MyPlugin.vst3" ).getFullPathName ());
135+ }
136+
137+ beginTest (" Doesn't alter component IDs" );
138+ {
139+ const auto commandLineString = " --validate MyPluginID" ;
140+ const auto args = createCommandLineArgs (commandLineString);
141+ expectEquals (parseCommandLine (args).first , String (" MyPluginID" ));
71142 }
72143
73144 beginTest (" Command line random" );
@@ -82,6 +153,14 @@ struct CommandLineTests : public UnitTest
82153 expect (temp.getFile ().create ());
83154 expect (shouldPerformCommandLine (temp.getFile ().getFullPathName ()));
84155 }
156+
157+ beginTest (" Allows for other options after explicit --validate" );
158+ {
159+ const auto currentDir = File::getCurrentWorkingDirectory ();
160+ const auto args = createCommandLineArgs (" --validate MyPlugin.vst3 --randomise" );
161+ expectEquals (parseCommandLine (args).first , currentDir.getChildFile (" MyPlugin.vst3" ).getFullPathName ());
162+ expect (parseCommandLine (args).second .randomiseTestOrder );
163+ }
85164 }
86165};
87166
0 commit comments