@@ -56,7 +56,6 @@ protected function configure()
56
56
'i ' ,
57
57
InputOption::VALUE_REQUIRED ,
58
58
'Used in combination with a parallel configuration, determines desired group size (in minutes) ' ,
59
- self ::PARALLEL_DEFAULT_TIME
60
59
)->addOption (
61
60
'groups ' ,
62
61
'g ' ,
@@ -97,7 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
97
96
$ config = $ input ->getOption ('config ' );
98
97
$ json = $ input ->getOption ('tests ' ); // for backward compatibility
99
98
$ force = $ input ->getOption ('force ' );
100
- $ time = $ input ->getOption ('time ' ) * 60 * 1000 ; // convert from minutes to milliseconds
99
+ $ time = $ input ->getOption ('time ' );
100
+ //$time = $input->getOption('time') * 60 * 1000; // convert from minutes to milliseconds
101
101
$ groups = $ input ->getOption ('groups ' );
102
102
$ debug = $ input ->getOption ('debug ' ) ?? MftfApplicationConfig::LEVEL_DEVELOPER ; // for backward compatibility
103
103
$ remove = $ input ->getOption ('remove ' );
@@ -132,25 +132,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
132
132
throw new TestFrameworkException ("JSON could not be parsed: " . json_last_error_msg ());
133
133
}
134
134
135
- $ configNumber = null ;
136
135
if ($ config === 'parallel ' ) {
137
- $ config = 'parallelByTime ' ;
138
- if ($ groups ) {
139
- $ groups = $ groups * 1 ;
140
- $ config = 'parallelByGroup ' ;
141
- if ($ time !== self ::PARALLEL_DEFAULT_TIME * 60 * 1000 ) {
142
- throw new TestFrameworkException (
143
- "'time' and 'groups' options are mutually exclusive, only one can be used at a time "
144
- );
145
- }
146
- if (!is_int ($ groups ) || $ groups <= 0 ) {
147
- throw new TestFrameworkException ("'groups' option must be an integer and greater than 0 " );
148
- }
149
- } elseif ($ time <= 0 ) {
150
- throw new TestFrameworkException ("'time' option cannot be less than or equal to 0 " );
151
- }
152
-
153
- $ configNumber = $ groups ?? $ time ;
136
+ list ($ config , $ configNumber ) = $ this ->parseConfigureParalleOptions ($ time , $ groups );
154
137
}
155
138
156
139
// Remove previous GENERATED_DIR if --remove option is used
@@ -279,4 +262,51 @@ private function parseTestsConfigJson($json, array $testConfiguration)
279
262
$ jsonTestConfiguration ['suites ' ] = $ testConfigArray ['suites ' ] ?? null ;
280
263
return $ jsonTestConfiguration ;
281
264
}
265
+
266
+ /**
267
+ * Parse console command options --time and/or --groups and return config type and config number in an array
268
+ *
269
+ * @param mixed $time
270
+ * @param mixed $groups
271
+ * @return array
272
+ * @throws FastFailException
273
+ */
274
+ private function parseConfigureParalleOptions ($ time , $ groups )
275
+ {
276
+ $ config = null ;
277
+ $ configNumber = null ;
278
+ if ($ time !== null && $ groups !== null ) {
279
+ throw new FastFailException (
280
+ "'time' and 'groups' options are mutually exclusive. "
281
+ . "Only one can be specified for 'config parallel' "
282
+ );
283
+ } elseif ($ time === null && $ groups === null ) {
284
+ $ config = 'parallelByTime ' ;
285
+ $ configNumber = self ::PARALLEL_DEFAULT_TIME * 60 * 1000 ; // convert from minutes to milliseconds
286
+ } elseif ($ time ) {
287
+ if (is_numeric ($ time )) {
288
+ $ time = $ time * 60 * 1000 ; // convert from minutes to milliseconds
289
+ if (is_int ($ time ) && $ time > 0 ) {
290
+ $ config = 'parallelByTime ' ;
291
+ $ configNumber = $ time ;
292
+ }
293
+ }
294
+ } else {
295
+ if (is_numeric ($ groups )) {
296
+ $ groups = $ groups * 1 ;
297
+ if (is_int ($ groups ) && $ groups > 0 ) {
298
+ $ config = 'parallelByGroup ' ;
299
+ $ configNumber = $ groups ;
300
+ }
301
+ }
302
+ }
303
+
304
+ if ($ config && $ configNumber ) {
305
+ return [$ config , $ configNumber ];
306
+ } elseif ($ time ) {
307
+ throw new FastFailException ("'time' option must be an integer and greater than 0 " );
308
+ } else {
309
+ throw new FastFailException ("'groups' option must be an integer and greater than 0 " );
310
+ }
311
+ }
282
312
}
0 commit comments