7
7
use Illuminate \Process \Exceptions \ProcessTimedOutException ;
8
8
use Illuminate \Process \Factory ;
9
9
use OutOfBoundsException ;
10
+ use PHPUnit \Framework \Attributes \RequiresOperatingSystem ;
10
11
use PHPUnit \Framework \TestCase ;
11
12
use RuntimeException ;
12
13
@@ -424,12 +425,9 @@ public function testFakeProcessesDontThrowIfFalse()
424
425
$ this ->assertTrue (true );
425
426
}
426
427
428
+ #[RequiresOperatingSystem('Linux|DAR ' )]
427
429
public function testRealProcessesCanHaveErrorOutput ()
428
430
{
429
- if (windows_os ()) {
430
- $ this ->markTestSkipped ('Requires Linux. ' );
431
- }
432
-
433
431
$ factory = new Factory ;
434
432
$ result = $ factory ->path (__DIR__ )->run ('echo "Hello World" >&2; exit 1; ' );
435
433
@@ -455,12 +453,9 @@ public function testFakeProcessesCanThrowWithoutOutput()
455
453
$ result ->throw ();
456
454
}
457
455
456
+ #[RequiresOperatingSystem('Linux|DAR ' )]
458
457
public function testRealProcessesCanThrowWithoutOutput ()
459
458
{
460
- if (windows_os ()) {
461
- $ this ->markTestSkipped ('Requires Linux. ' );
462
- }
463
-
464
459
$ this ->expectException (ProcessFailedException::class);
465
460
$ this ->expectExceptionMessage (<<<'EOT'
466
461
The command "exit 1;" failed.
@@ -496,12 +491,9 @@ public function testFakeProcessesCanThrowWithErrorOutput()
496
491
$ result ->throw ();
497
492
}
498
493
494
+ #[RequiresOperatingSystem('Linux|DAR ' )]
499
495
public function testRealProcessesCanThrowWithErrorOutput ()
500
496
{
501
- if (windows_os ()) {
502
- $ this ->markTestSkipped ('Requires Linux. ' );
503
- }
504
-
505
497
$ this ->expectException (ProcessFailedException::class);
506
498
$ this ->expectExceptionMessage (<<<'EOT'
507
499
The command "echo "Hello World" >&2; exit 1;" failed.
@@ -541,12 +533,9 @@ public function testFakeProcessesCanThrowWithOutput()
541
533
$ result ->throw ();
542
534
}
543
535
536
+ #[RequiresOperatingSystem('Linux|DAR ' )]
544
537
public function testRealProcessesCanThrowWithOutput ()
545
538
{
546
- if (windows_os ()) {
547
- $ this ->markTestSkipped ('Requires Linux. ' );
548
- }
549
-
550
539
$ this ->expectException (ProcessFailedException::class);
551
540
$ this ->expectExceptionMessage (<<<'EOT'
552
541
The command "echo "Hello World" >&1; exit 1;" failed.
@@ -565,12 +554,9 @@ public function testRealProcessesCanThrowWithOutput()
565
554
$ result ->throw ();
566
555
}
567
556
557
+ #[RequiresOperatingSystem('Linux|DAR ' )]
568
558
public function testRealProcessesCanTimeout ()
569
559
{
570
- if (windows_os ()) {
571
- $ this ->markTestSkipped ('Requires Linux. ' );
572
- }
573
-
574
560
$ this ->expectException (ProcessTimedOutException::class);
575
561
$ this ->expectExceptionMessage (
576
562
'The process "sleep 2; exit 1;" exceeded the timeout of 1 seconds. '
@@ -582,12 +568,9 @@ public function testRealProcessesCanTimeout()
582
568
$ result ->throw ();
583
569
}
584
570
571
+ #[RequiresOperatingSystem('Linux|DAR ' )]
585
572
public function testRealProcessesCanThrowIfTrue ()
586
573
{
587
- if (windows_os ()) {
588
- $ this ->markTestSkipped ('Requires Linux. ' );
589
- }
590
-
591
574
$ this ->expectException (ProcessFailedException::class);
592
575
593
576
$ factory = new Factory ;
@@ -596,12 +579,9 @@ public function testRealProcessesCanThrowIfTrue()
596
579
$ result ->throwIf (true );
597
580
}
598
581
582
+ #[RequiresOperatingSystem('Linux|DAR ' )]
599
583
public function testRealProcessesDoesntThrowIfFalse ()
600
584
{
601
- if (windows_os ()) {
602
- $ this ->markTestSkipped ('Requires Linux. ' );
603
- }
604
-
605
585
$ factory = new Factory ;
606
586
$ result = $ factory ->path (__DIR__ )->run ('echo "Hello World" >&2; exit 1; ' );
607
587
@@ -610,24 +590,18 @@ public function testRealProcessesDoesntThrowIfFalse()
610
590
$ this ->assertTrue (true );
611
591
}
612
592
593
+ #[RequiresOperatingSystem('Linux|DAR ' )]
613
594
public function testRealProcessesCanUseStandardInput ()
614
595
{
615
- if (windows_os ()) {
616
- $ this ->markTestSkipped ('Requires Linux. ' );
617
- }
618
-
619
596
$ factory = new Factory ();
620
597
$ result = $ factory ->input ('foobar ' )->run ('cat ' );
621
598
622
599
$ this ->assertSame ('foobar ' , $ result ->output ());
623
600
}
624
601
602
+ #[RequiresOperatingSystem('Linux|DAR ' )]
625
603
public function testProcessPipe ()
626
604
{
627
- if (windows_os ()) {
628
- $ this ->markTestSkipped ('Requires Linux. ' );
629
- }
630
-
631
605
$ factory = new Factory ;
632
606
$ factory ->fake ([
633
607
'cat * ' => "Hello, world \nfoo \nbar " ,
@@ -641,12 +615,9 @@ public function testProcessPipe()
641
615
$ this ->assertSame ("foo \n" , $ pipe ->output ());
642
616
}
643
617
618
+ #[RequiresOperatingSystem('Linux|DAR ' )]
644
619
public function testProcessPipeFailed ()
645
620
{
646
- if (windows_os ()) {
647
- $ this ->markTestSkipped ('Requires Linux. ' );
648
- }
649
-
650
621
$ factory = new Factory ;
651
622
$ factory ->fake ([
652
623
'cat * ' => $ factory ->result (exitCode: 1 ),
@@ -660,12 +631,9 @@ public function testProcessPipeFailed()
660
631
$ this ->assertTrue ($ pipe ->failed ());
661
632
}
662
633
634
+ #[RequiresOperatingSystem('Linux|DAR ' )]
663
635
public function testProcessSimplePipe ()
664
636
{
665
- if (windows_os ()) {
666
- $ this ->markTestSkipped ('Requires Linux. ' );
667
- }
668
-
669
637
$ factory = new Factory ;
670
638
$ factory ->fake ([
671
639
'cat * ' => "Hello, world \nfoo \nbar " ,
@@ -679,12 +647,9 @@ public function testProcessSimplePipe()
679
647
$ this ->assertSame ("foo \n" , $ pipe ->output ());
680
648
}
681
649
650
+ #[RequiresOperatingSystem('Linux|DAR ' )]
682
651
public function testProcessSimplePipeFailed ()
683
652
{
684
- if (windows_os ()) {
685
- $ this ->markTestSkipped ('Requires Linux. ' );
686
- }
687
-
688
653
$ factory = new Factory ;
689
654
$ factory ->fake ([
690
655
'cat * ' => $ factory ->result (exitCode: 1 ),
0 commit comments