Run all tests

master
Anton Smirnov 9 months ago
parent f62bb3e4ab
commit cb50d608ce

1
.gitignore vendored

@ -2,3 +2,4 @@
!.gitignore
!composer.json
!README.md
!run_tests.php

@ -33,6 +33,9 @@
"sandfoxme/private-access": "*",
"sandfoxme/torrent-file": "*"
},
"require-dev": {
"symfony/filesystem": ">= 2.0"
},
"extra": {
"arokettu/composer-license-manager": {
"licenses": {

@ -0,0 +1,82 @@
<?php
use Symfony\Component\Filesystem\Filesystem;
try {
require __DIR__ . '/vendor/autoload.php';
$fs = new Filesystem();
chdir(__DIR__);
$composerJson = json_decode(file_get_contents('composer.json'), true);
$composerLock = json_decode(file_get_contents('composer.lock'), true);
$packageData = array_reduce($composerLock['packages'], function ($pkgs, $p) {
$pkgs[$p['name']] = $p;
return $pkgs;
}, []);
$packages = array_keys($composerJson['require']);
$skip = [
];
$packages = array_diff($packages, $skip);
foreach ($packages as $p) {
chdir(__DIR__);
echo "Testing ", $p, '... ';
$url = $packageData[$p]['source']['url'];
if (is_dir('run_tests/' . $p)) {
chdir('run_tests/' . $p);
run("git pull 2>&1") === 0 || die("git error\n");
echo 'updated... ';
} else {
$fs->mkdir('run_tests/' . $p);
chdir('run_tests/' . $p);
$urlSh = escapeshellarg($url);
run("git clone $urlSh . 2>&1") === 0 || die("git error\n");
echo 'cloned... ';
}
run('composer update --no-interaction 2>&1') === 0 || die("composer error\n");
echo 'installed... ';
$testExec = $p === 'arokettu/is-resource' ? 'tests/tests.sh' : 'vendor/bin/phpunit';
if (!file_exists($testExec)) {
echo 'no tests!', PHP_EOL;
continue;
}
if (run($testExec, $output) === 0) {
echo 'successful!', PHP_EOL;
continue;
}
echo 'failure:', PHP_EOL;
echo implode(PHP_EOL, $output);
die("\n");
}
} catch (Exception $e) {
echo strval($e);
} catch (Throwable $e) {
echo strval($e);
}
function run($command, &$output = null) {
$output = null;
ob_start();
exec($command, $output, $ret);
ob_end_clean();
return $ret;
}
Loading…
Cancel
Save