- $test['desc'] = $test['test'];
- $this->tests[] = $test;
-
- if ( $tidy !== false ) {
- $test['options'] .= " tidy";
- $test['desc'] .= ' (with tidy)';
- $test['result'] = ParserTestRunner::chomp( $this->sectionData[$tidy] );
- $this->tests[] = $test;
+
+ if ( $nonTidySection !== false ) {
+ // Add non-tidy test
+ $this->tests[] = [
+ 'result' => $data[$nonTidySection],
+ ] + $commonInfo;
+
+ if ( $tidySection !== false ) {
+ // Add tidy subtest
+ $this->tests[] = [
+ 'desc' => $data['test'] . ' (with tidy)',
+ 'result' => $data[$tidySection],
+ 'options' => $data['options'] . ' tidy',
+ ] + $commonInfo;
+ }
+ } elseif ( $tidySection !== false ) {
+ // No need to override desc when there is no subtest
+ $this->tests[] = [
+ 'result' => $data[$tidySection],
+ 'options' => $data['options'] . ' tidy'
+ ] + $commonInfo;
+ } else {
+ throw new MWException( "Test at {$this->file}:{$this->sectionLineNum['test']} " .
+ "lacks result section" );