Passed
Pull Request — master (#18)
by Harry
04:35 queued 23s
created

TableTest::outputData()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 209
Code Lines 97

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 97
dl 0
loc 209
rs 8.0654
c 0
b 0
f 0
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * This file is part of graze/parallel-process.
4
 *
5
 * Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/parallel-process/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/parallel-process
12
 */
13
14
namespace Graze\ParallelProcess\Test\Unit\Display;
15
16
use Graze\ParallelProcess\PriorityPool;
17
use Graze\ParallelProcess\ProcessRun;
18
use Graze\ParallelProcess\Display\Table;
19
use Graze\ParallelProcess\Test\BufferDiffOutput;
20
use Graze\ParallelProcess\Test\TestCase;
21
use Mockery;
22
use Symfony\Component\Console\Output\ConsoleOutputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
use Symfony\Component\Process\Exception\ProcessFailedException;
25
use Symfony\Component\Process\Process;
26
27
class TableTest extends TestCase
28
{
29
    /** @var BufferDiffOutput */
30
    private $bufferOutput;
31
    /** @var mixed */
32
    private $pool;
33
    /** @var Table */
34
    private $table;
35
36
    public function setUp()
37
    {
38
        mb_internal_encoding("UTF-8");
39
        $this->bufferOutput = new BufferDiffOutput();
40
        $this->pool = new PriorityPool();
41
        $this->table = new Table($this->bufferOutput, $this->pool);
42
    }
43
44
    public function testConstructWithNonBufferedOutput()
45
    {
46
        $output = Mockery::mock(ConsoleOutputInterface::class);
47
        $table = new Table($output);
0 ignored issues
show
Bug introduced by
$output of type Mockery\MockInterface is incompatible with the type Symfony\Component\Console\Output\OutputInterface expected by parameter $output of Graze\ParallelProcess\Display\Table::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
        $table = new Table(/** @scrutinizer ignore-type */ $output);
Loading history...
48
49
        $this->assertInstanceOf(Table::class, $table);
50
    }
51
52
    public function testShowOutput()
53
    {
54
        $output = Mockery::mock(ConsoleOutputInterface::class);
55
        $table = new Table($output);
0 ignored issues
show
Bug introduced by
$output of type Mockery\MockInterface is incompatible with the type Symfony\Component\Console\Output\OutputInterface expected by parameter $output of Graze\ParallelProcess\Display\Table::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        $table = new Table(/** @scrutinizer ignore-type */ $output);
Loading history...
56
57
        $this->assertTrue($table->isShowOutput());
58
59
        $this->assertSame($table, $table->setShowOutput(false));
60
61
        $this->assertFalse($table->isShowOutput());
62
    }
63
64
    public function testShowSummary()
65
    {
66
        $output = Mockery::mock(ConsoleOutputInterface::class);
67
        $table = new Table($output);
0 ignored issues
show
Bug introduced by
$output of type Mockery\MockInterface is incompatible with the type Symfony\Component\Console\Output\OutputInterface expected by parameter $output of Graze\ParallelProcess\Display\Table::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

67
        $table = new Table(/** @scrutinizer ignore-type */ $output);
Loading history...
68
69
        $this->assertTrue($table->isShowSummary());
70
71
        $this->assertSame($table, $table->setShowSummary(false));
72
73
        $this->assertFalse($table->isShowSummary());
74
    }
75
76
    public function testSpinnerLoop()
77
    {
78
        $this->table->setShowSummary(false);
79
        $this->bufferOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
80
81
        $process = Mockery::mock(Process::class);
82
        $process->shouldReceive('stop');
83
        $process->shouldReceive('start')->once();
84
        $process->shouldReceive('isStarted')->andReturn(false, false, false, true); //add, add2, start, run
85
        $process->shouldReceive('isRunning')->andReturn(
86
            false, // add
87
            false, // add2
88
            true,  // check
89
            true,  // ...
90
            true,
91
            true,
92
            true,
93
            true,
94
            true,
95
            true,
96
            true,
97
            true,
98
            true,
99
            false // complete
100
        );
101
        $process->shouldReceive('isSuccessful')->atLeast()->once()->andReturn(true);
102
103
        $this->pool->add($process, ['key' => 'value']);
104
105
        $this->table->run(0);
106
107
        $expected = [
108
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) %'],
109
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠋%'],
110
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠙%'],
111
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠹%'],
112
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠸%'],
113
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠼%'],
114
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠴%'],
115
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠦%'],
116
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠧%'],
117
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠇%'],
118
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠏%'],
119
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) ⠋%'],
120
            ['%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
121
        ];
122
123
        $this->compareOutputs($expected, $this->bufferOutput->getWritten());
124
    }
125
126
    public function testProgressBar()
127
    {
128
        $this->table->setShowSummary(false);
129
        $this->bufferOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
130
131
        $process = Mockery::mock(Process::class);
132
        $process->shouldReceive('stop');
133
        $process->shouldReceive('start')->once();
134
        $process->shouldReceive('isStarted')->andReturn(false, false, false, true); // add, add2, start, run
135
        $process->shouldReceive('isRunning')->andReturn(
136
            false, // add
137
            false, // add
138
            true,  // check
139
            true,  // ...
140
            true,
141
            true,
142
            true,
143
            true,
144
            true,
145
            true,
146
            true,
147
            true,
148
            true,
149
            true,
150
            true,
151
            true,
152
            true,
153
            true,
154
            true,
155
            true,
156
            true,
157
            true,
158
            false // complete
159
        );
160
        $process->shouldReceive('isSuccessful')->atLeast()->once()->andReturn(true);
161
162
        $run = Mockery::mock(ProcessRun::class, [$process, ['key' => 'value']])->makePartial();
163
        $this->pool->add($run);
164
165
        $run->allows()
166
            ->getProgress()
167
            ->andReturns(
168
                [0, 100, 0],
169
                [5, 100, 0.05],
170
                [10, 100, 0.1],
171
                [15, 100, 0.15],
172
                [20, 100, 0.2],
173
                [25, 100, 0.25],
174
                [30, 100, 0.3],
175
                [35, 100, 0.35],
176
                [40, 100, 0.4],
177
                [45, 100, 0.45],
178
                [50, 100, 0.5],
179
                [55, 100, 0.55],
180
                [60, 100, 0.6],
181
                [65, 100, 0.65],
182
                [70, 100, 0.7],
183
                [75, 100, 0.75],
184
                [80, 100, 0.8],
185
                [85, 100, 0.85],
186
                [90, 100, 0.9],
187
                [95, 100, 0.95],
188
                [100, 100, 1]
189
            );
190
        $run->allows()
191
            ->getDuration()
192
            ->andReturns(
193
                0,
194
                0.05,
195
                0.1,
196
                0.15,
197
                0.2,
198
                0.25,
199
                0.3,
200
                0.35,
201
                0.4,
202
                0.45,
203
                0.5,
204
                0.55,
205
                0.6,
206
                0.65,
207
                0.7,
208
                0.75,
209
                0.8,
210
                0.85,
211
                0.9,
212
                0.95,
213
                1
214
            );
215
216
        $this->table->run(0);
217
218
        $expected = [
219
            ['/<info>key<\/info>: value \(<comment>  0.00s<\/comment>\) /'],
220
            ['/<info>key<\/info>: value \(<comment>  0.00s<\/comment>\) ▕<comment>  <\/comment>▏<info>  0%<\/info>/'],
221
            ['/<info>key<\/info>: value \(<comment>  0.05s<\/comment>\) ▕<comment>▏ <\/comment>▏<info>  5%<\/info>/'],
222
            ['/<info>key<\/info>: value \(<comment>  0.10s<\/comment>\) ▕<comment>▎ <\/comment>▏<info> 10%<\/info>/'],
223
            ['/<info>key<\/info>: value \(<comment>  0.15s<\/comment>\) ▕<comment>▍ <\/comment>▏<info> 15%<\/info>/'],
224
            ['/<info>key<\/info>: value \(<comment>  0.20s<\/comment>\) ▕<comment>▍ <\/comment>▏<info> 20%<\/info>/'],
225
            ['/<info>key<\/info>: value \(<comment>  0.25s<\/comment>\) ▕<comment>▌ <\/comment>▏<info> 25%<\/info>/'],
226
            ['/<info>key<\/info>: value \(<comment>  0.30s<\/comment>\) ▕<comment>▋ <\/comment>▏<info> 30%<\/info>/'],
227
            ['/<info>key<\/info>: value \(<comment>  0.35s<\/comment>\) ▕<comment>▋ <\/comment>▏<info> 35%<\/info>/'],
228
            ['/<info>key<\/info>: value \(<comment>  0.40s<\/comment>\) ▕<comment>▊ <\/comment>▏<info> 40%<\/info>/'],
229
            ['/<info>key<\/info>: value \(<comment>  0.45s<\/comment>\) ▕<comment>▉ <\/comment>▏<info> 45%<\/info>/'],
230
            ['/<info>key<\/info>: value \(<comment>  0.50s<\/comment>\) ▕<comment>█ <\/comment>▏<info> 50%<\/info>/'],
231
            ['/<info>key<\/info>: value \(<comment>  0.55s<\/comment>\) ▕<comment>█▏<\/comment>▏<info> 55%<\/info>/'],
232
            ['/<info>key<\/info>: value \(<comment>  0.60s<\/comment>\) ▕<comment>█▎<\/comment>▏<info> 60%<\/info>/'],
233
            ['/<info>key<\/info>: value \(<comment>  0.65s<\/comment>\) ▕<comment>█▍<\/comment>▏<info> 65%<\/info>/'],
234
            ['/<info>key<\/info>: value \(<comment>  0.70s<\/comment>\) ▕<comment>█▍<\/comment>▏<info> 70%<\/info>/'],
235
            ['/<info>key<\/info>: value \(<comment>  0.75s<\/comment>\) ▕<comment>█▌<\/comment>▏<info> 75%<\/info>/'],
236
            ['/<info>key<\/info>: value \(<comment>  0.80s<\/comment>\) ▕<comment>█▋<\/comment>▏<info> 80%<\/info>/'],
237
            ['/<info>key<\/info>: value \(<comment>  0.85s<\/comment>\) ▕<comment>█▋<\/comment>▏<info> 85%<\/info>/'],
238
            ['/<info>key<\/info>: value \(<comment>  0.90s<\/comment>\) ▕<comment>█▊<\/comment>▏<info> 90%<\/info>/'],
239
            ['/<info>key<\/info>: value \(<comment>  0.95s<\/comment>\) ▕<comment>█▉<\/comment>▏<info> 95%<\/info>/'],
240
            ['/<info>key<\/info>: value \(<comment>  1.00s<\/comment>\) <info>✓<\/info>/'],
241
        ];
242
243
        $this->compareOutputs($expected, $this->bufferOutput->getWritten());
244
    }
245
246
    public function testValueDataArrayDoesNotShowTheKey()
247
    {
248
        $this->table->setShowSummary(false);
249
        $this->bufferOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
250
251
        $process = Mockery::mock(Process::class);
252
        $process->shouldReceive('stop');
253
        $process->shouldReceive('start')->once();
254
        $process->shouldReceive('isStarted')->andReturn(false, false, false, true); // add, start, run
255
        $process->shouldReceive('isRunning')->andReturn(
256
            false, // add
257
            false, // add2
258
            true,  // check
259
            false // complete
260
        );
261
        $process->shouldReceive('isSuccessful')->atLeast()->once()->andReturn(true);
262
263
        $this->pool->add($process, ['value', 'value2']);
264
265
        $this->table->run(0);
266
267
        $expected = [
268
            ['%value value2 \(<comment>[ 0-9\.s]+</comment>\) %'],
269
            ['%value value2 \(<comment>[ 0-9\.s]+</comment>\) ⠋%'],
270
            ['%value value2 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
271
        ];
272
273
        $this->compareOutputs($expected, $this->bufferOutput->getWritten());
274
    }
275
276
    public function testSummaryIsWaitingBeforeTheProcessStarts()
277
    {
278
        $this->bufferOutput->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
279
        $this->table->setShowOutput(true);
280
        $this->table->setShowSummary(true);
281
282
        $oneFails = false;
283
284
        $process = Mockery::mock(Process::class);
285
        $process->shouldReceive('stop');
286
        $process->shouldReceive('start')->with(Mockery::on(function ($closure) {
287
            call_user_func($closure, Process::OUT, 'some text');
288
            return true;
289
        }))->once();
290
        $process->shouldReceive('isStarted')
291
                ->andReturn(false, false, false, false, true); // add, add2, summary, start, run
292
        $process->shouldReceive('isRunning')->andReturn(false, false, true, false); // add, add2, check, check
293
        $process->shouldReceive('isSuccessful')->atLeast()->once()->andReturn(true);
294
        $process->shouldReceive('getOutput')->andReturn('some text');
295
296
        $this->pool->add($process, ['key' => 'value']);
297
298
        try {
299
            $this->table->run(0);
300
        } catch (\Exception $e) {
301
            if (!$oneFails || !$e instanceof ProcessFailedException) {
0 ignored issues
show
introduced by
The condition $oneFails is always false.
Loading history...
302
                throw $e;
303
            }
304
        }
305
306
        $expected = [
307
            [
308
                '%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) %',
309
                '%waiting...%',
310
            ],
311
            [
312
                '%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) %',
313
                '%<comment>Total</comment>:  1, <comment>Running</comment>:  1, <comment>Waiting</comment>:  0%',
314
            ],
315
            [
316
                '%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
317
                '%<comment>Total</comment>:  1, <comment>Running</comment>:  1, <comment>Waiting</comment>:  0%',
318
            ],
319
            [
320
                '%<info>key</info>: value \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
321
                '%^$%',
322
            ],
323
        ];
324
325
        $this->compareOutputs($expected, $this->bufferOutput->getWritten());
326
    }
327
328
    /**
329
     * Runs a series of processes, each doing initial state, single on progress run, single complete entry
330
     *
331
     * @dataProvider outputData
332
     *
333
     * @param int        $verbosity     OutputInterface::VERBOSITY_*
334
     * @param bool       $showOutput    Should it display some output text
335
     * @param bool       $showSummary   Should we show a summary
336
     * @param bool[]     $processStates an entry for each process to run, true = success, false = failure
337
     * @param string[][] $outputs       Regex patterns for the output string
338
     *
339
     * @throws \Exception
340
     */
341
    public function testOutput($verbosity, $showOutput, $showSummary, array $processStates, array $outputs)
342
    {
343
        $this->bufferOutput->setVerbosity($verbosity);
344
        $this->table->setShowOutput($showOutput);
345
        $this->table->setShowSummary($showSummary);
346
347
        $oneFails = false;
348
349
        for ($i = 0; $i < count($processStates); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
350
            $process = Mockery::mock(Process::class);
351
            $process->shouldReceive('stop');
352
            $process->shouldReceive('start')->with(Mockery::on(function ($closure) {
353
                call_user_func($closure, Process::OUT, 'some text');
354
                return true;
355
            }))->once();
356
            if ($showSummary) {
357
                $process->shouldReceive('isStarted')
358
                        ->andReturn(false, false, false, false, true); // add, add2, summary, start, run
359
            } else {
360
                $process->shouldReceive('isStarted')->andReturn(false, false, false, true); // add, add2, start, run
361
            }
362
            $process->shouldReceive('isRunning')->andReturn(false, false, true, false); // add, add2, check, check
363
            $process->shouldReceive('isSuccessful')->atLeast()->once()->andReturn($processStates[$i]);
364
            $process->shouldReceive('getOutput')->andReturn('some text');
365
366
            if (!$processStates[$i]) {
367
                $process->shouldReceive('getCommandLine')->andReturn('test');
368
                $process->shouldReceive('getExitCode')->andReturn(1);
369
                $process->shouldReceive('getExitCodeText')->andReturn('failed');
370
                $process->shouldReceive('getWorkingDirectory')->andReturn('/tmp');
371
                $process->shouldReceive('isOutputDisabled')->andReturn(false);
372
                $process->shouldReceive('getErrorOutput')->andReturn('some error text');
373
                $oneFails = true;
374
            }
375
376
            $this->pool->add($process, ['key' => 'value', 'run' => $i]);
377
        }
378
379
        try {
380
            $this->table->run(0);
381
        } catch (\Exception $e) {
382
            if (!$oneFails || !$e instanceof ProcessFailedException) {
383
                throw $e;
384
            }
385
        }
386
387
        $this->compareOutputs($outputs, $this->bufferOutput->getWritten());
388
    }
389
390
    /**
391
     * @return array
392
     */
393
    public function outputData()
394
    {
395
        return [
396
            [ // verbose with single valid run
397
              OutputInterface::VERBOSITY_VERBOSE,
398
              false,
399
              false,
400
              [true],
401
              [
402
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'],
403
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'],
404
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
405
              ],
406
            ],
407
            [ // normal verbosity only writes a single line
408
              OutputInterface::VERBOSITY_NORMAL,
409
              false,
410
              false,
411
              [true],
412
              [
413
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
414
              ],
415
            ],
416
            [
417
                OutputInterface::VERBOSITY_NORMAL,
418
                false,
419
                false,
420
                [true, true],
421
                [
422
                    ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
423
                    ['%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'],
424
                ],
425
            ],
426
            [ // multiple runs with verbosity will update each item one at a time
427
              OutputInterface::VERBOSITY_VERBOSE,
428
              false,
429
              false,
430
              [true, true],
431
              [
432
                  [
433
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %',
434
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
435
                  ],
436
                  [
437
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
438
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
439
                  ],
440
                  [
441
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
442
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
443
                  ],
444
                  [
445
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
446
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
447
                  ],
448
                  [
449
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
450
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
451
                  ],
452
              ],
453
            ],
454
            [ // errors will display an error
455
              OutputInterface::VERBOSITY_VERBOSE,
456
              false,
457
              false,
458
              [false],
459
              [
460
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'],
461
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'],
462
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'],
463
                  [
464
                      <<<DOC
465
%The command "test" failed.
466
467
Exit Code: 1\(failed\)
468
469
Working directory: /tmp
470
471
Output:
472
================
473
some text
474
475
Error Output:
476
================
477
some error text%
478
DOC
479
                      ,
480
                  ],
481
              ],
482
            ],
483
            [ // errors will display an error
484
              OutputInterface::VERBOSITY_NORMAL,
485
              false,
486
              false,
487
              [false],
488
              [
489
                  ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'],
490
                  [
491
                      <<<DOC
492
%The command "test" failed.
493
494
Exit Code: 1\(failed\)
495
496
Working directory: /tmp
497
498
Output:
499
================
500
some text
501
502
Error Output:
503
================
504
some error text%
505
DOC
506
                      ,
507
                  ],
508
              ],
509
            ],
510
            [ // multiple runs with verbosity will update each item one at a time
511
              OutputInterface::VERBOSITY_VERBOSE,
512
              false,
513
              false,
514
              [true, false],
515
              [
516
                  [
517
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %',
518
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
519
                  ],
520
                  [
521
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
522
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
523
                  ],
524
                  [
525
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
526
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
527
                  ],
528
                  [
529
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
530
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
531
                  ],
532
                  [
533
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
534
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%',
535
                  ],
536
                  [
537
                      <<<DOC
538
%The command "test" failed.
539
540
Exit Code: 1\(failed\)
541
542
Working directory: /tmp
543
544
Output:
545
================
546
some text
547
548
Error Output:
549
================
550
some error text%
551
DOC
552
                      ,
553
                  ],
554
              ],
555
            ],
556
            [ // include output
557
              OutputInterface::VERBOSITY_VERBOSE,
558
              true,
559
              false,
560
              [true],
561
              [
562
                  ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'],
563
                  ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]  some text%'],
564
                  ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>  some text%'],
565
              ],
566
            ],
567
            [ // include a summary
568
              OutputInterface::VERBOSITY_VERBOSE,
569
              false,
570
              true,
571
              [true, true],
572
              [
573
                  [
574
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %',
575
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
576
                      '%^waiting...$%',
577
                  ],
578
                  [
579
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
580
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %',
581
                      '%<comment>Total</comment>:  2, <comment>Running</comment>:  2, <comment>Waiting</comment>:  0%',
582
                  ],
583
                  [
584
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
585
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
586
                      '%<comment>Total</comment>:  2, <comment>Running</comment>:  2, <comment>Waiting</comment>:  0%',
587
                  ],
588
                  [
589
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
590
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%',
591
                      '%<comment>Total</comment>:  2, <comment>Running</comment>:  2, <comment>Waiting</comment>:  0%',
592
                  ],
593
                  [
594
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
595
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
596
                      '%<comment>Total</comment>:  2, <comment>Running</comment>:  1, <comment>Waiting</comment>:  0%',
597
                  ],
598
                  [
599
                      '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
600
                      '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%',
601
                      '%^$%',
602
                  ],
603
              ],
604
            ],
605
        ];
606
    }
607
}
608