kylekatarnls / multi-tester

Compare da3c24f ... +0 ... c1d4545

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -59,6 +59,11 @@
Loading
59 59
     */
60 60
    public $adds = [];
61 61
62 +
    /**
63 +
     * @var string|callable
64 +
     */
65 +
    public $executor = 'shell_exec';
66 +
62 67
    /**
63 68
     * Config constructor.
64 69
     *

@@ -4,18 +4,27 @@
Loading
4 4
5 5
class GitHub
6 6
{
7 +
    /**
8 +
     * @var string
9 +
     */
7 10
    private $repo;
8 11
9 -
    public function __construct(string $repo)
12 +
    /**
13 +
     * @var string
14 +
     */
15 +
    private $executor;
16 +
17 +
    public function __construct(string $repo, $executor = 'shell_exec')
10 18
    {
11 19
        $this->repo = $repo;
20 +
        $this->executor = $executor;
12 21
    }
13 22
14 23
    private function getCurl(string $url): ?string
15 24
    {
16 25
        $token = getenv('GITHUB_TOKEN');
17 26
18 -
        return shell_exec(
27 +
        return ($this->executor)(
19 28
            'curl -s ' .
20 29
            '-H "Accept: application/vnd.github.antiope-preview+json" ' .
21 30
            (empty($token) ? '' : '-H "Authorization: token ' . $token . '" ') .

@@ -88,7 +88,7 @@
Loading
88 88
        $replace = (array) $this->config->data['replace'];
89 89
90 90
        foreach ($replace as $package => $version) {
91 -
            (new Directory('vendor/' . $package))->remove();
91 +
            (new Directory('vendor/' . $package, $this->config->executor))->remove();
92 92
        }
93 93
    }
94 94
@@ -231,7 +231,7 @@
Loading
231 231
                        throw new MultiTesterException('success_only can be used only with github.com source URLs for now.');
232 232
                    }
233 233
234 -
                    $gitHub = new GitHub($match[1]);
234 +
                    $gitHub = new GitHub($match[1], $this->config->executor);
235 235
                    $reference = $gitHub->getFirstSuccessfulCommit($reference);
236 236
                }
237 237
@@ -319,7 +319,7 @@
Loading
319 319
320 320
        $this->seedCloneSetting($settings);
321 321
322 -
        (new Directory('.'))->clean();
322 +
        (new Directory('.', $this->config->executor))->clean();
323 323
324 324
        if (!$config->quiet) {
325 325
            $tester->info("empty current directory\n");
@@ -389,7 +389,7 @@
Loading
389 389
390 390
        $this->removeReplacedPackages();
391 391
392 -
        (new Directory($config->projectDirectory))->copy('vendor/' . $config->packageName, ['.git', 'vendor']);
392 +
        (new Directory($config->projectDirectory, $this->config->executor))->copy('vendor/' . $config->packageName, ['.git', 'vendor']);
393 393
394 394
        $this->autoload();
395 395

@@ -9,9 +9,15 @@
Loading
9 9
     */
10 10
    protected $path;
11 11
12 -
    public function __construct($path)
12 +
    /**
13 +
     * @var string
14 +
     */
15 +
    private $executor;
16 +
17 +
    public function __construct($path, $executor = 'shell_exec')
13 18
    {
14 19
        $this->path = $path;
20 +
        $this->executor = $executor;
15 21
    }
16 22
17 23
    public function copy($destination, $exceptions = [])
@@ -45,7 +51,7 @@
Loading
45 51
46 52
        clearstatcache();
47 53
        $arg = escapeshellarg($dir);
48 -
        shell_exec('rm -rf ' . $arg . '/.* 2>&1 && rm -rf ' . $arg . '/* 2>&1');
54 +
        ($this->executor)('rm -rf ' . $arg . '/.* 2>&1 && rm -rf ' . $arg . '/* 2>&1');
49 55
        $success = true;
50 56
51 57
        foreach (@scandir($dir) as $file) {

@@ -138,7 +138,7 @@
Loading
138 138
139 139
            chdir($cwd);
140 140
141 -
            (new Directory($this->getWorkingDirectory()))->remove();
141 +
            (new Directory($this->getWorkingDirectory(), $config->executor))->remove();
142 142
        }
143 143
144 144
        $this->removeDirectories($directories);

Learn more Showing 1 files with coverage changes found.

Changes in src/MultiTester/GitHub.php
-3
+3
Loading file...
Files Complexity Coverage
src/MultiTester ø +1.91% 95.60%
Project Totals (13 files) 206 95.60%
Loading