Skip to content

Commit

Permalink
Merge pull request #399 from jolicode/fix/transient-tests
Browse files Browse the repository at this point in the history
chore(tests): make some tests less sensible to user environment
  • Loading branch information
pyrech authored Apr 8, 2024
2 parents 2229671 + 5af6ba7 commit e5a7acc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/failure.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#[AsTask(description: 'A failing task not authorized to fail')]
function failure(): void
{
run('i_do_not_exist', workingDirectory: '/tmp', pty: false);
run('bash -c i_do_not_exist', workingDirectory: '/tmp', pty: false);
}

#[AsTask(description: 'A failing task authorized to fail')]
function allow_failure(): void
{
run('i_do_not_exist', allowFailure: true, pty: false);
run('bash -c i_do_not_exist', allowFailure: true, pty: false);
}
2 changes: 1 addition & 1 deletion examples/ssh.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function whoami(): void
#[AsTask(description: 'Uploads a file to the remote server')]
function upload(): void
{
ssh_upload('/tmp/test.html', '/var/www/index.html', host: 'server-1.example.com', user: 'debian');
ssh_upload(__FILE__, '/var/www/index.html', host: 'server-1.example.com', user: 'debian');
}

#[AsTask(description: 'Downloads a file from the remote server')]
Expand Down
2 changes: 1 addition & 1 deletion tests/Generated/FailureAllowFailureTest.php.err.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sh: 1: i_do_not_exist: not found
bash: line 1: i_do_not_exist: command not found
4 changes: 2 additions & 2 deletions tests/Generated/FailureFailureTest.php.err.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sh: 1: i_do_not_exist: not found
bash: line 1: i_do_not_exist: command not found

In failure.php line 12:

The command "i_do_not_exist" failed.
The command "bash -c i_do_not_exist" failed.


failure:failure
Expand Down
2 changes: 1 addition & 1 deletion tests/Generated/SshUploadTest.php.err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ssh: Could not resolve hostname server-1.example.com: Name or service not known

In SshRunner.php line XXXX:

The command "scp -r /tmp/test.html [email protected]:/var/www/index.html" failed.
The command "scp -r .../examples/ssh.php [email protected]:/var/www/index.html" failed.


ssh:upload
Expand Down
8 changes: 8 additions & 0 deletions tests/Slow/CompileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
namespace Castor\Tests\Slow;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Process;

class CompileCommandTest extends TestCase
{
public function test()
{
$finder = new ExecutableFinder();
$box = $finder->find('box');

if (null === $box) {
$this->markTestSkipped('box is not installed.');
}

$castorAppDirPath = RepackCommandTest::setupRepackedCastorApp('castor-test-compile');

(new Process(
Expand Down
8 changes: 8 additions & 0 deletions tests/Slow/RepackCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Process;

class RepackCommandTest extends TestCase
{
public function test()
{
$finder = new ExecutableFinder();
$box = $finder->find('box');

if (null === $box) {
$this->markTestSkipped('box is not installed.');
}

$castorAppDirPath = self::setupRepackedCastorApp('castor-test-repack');

(new Process([
Expand Down

0 comments on commit e5a7acc

Please sign in to comment.