#!/usr/bin/env php
<?php

echo "Running tests... ";

try{
    exec('vendor/bin/phpunit --colors=always', $output, $returnCode);
} catch(\Exception $e) {
    echo $e->getMessage();
    exit(1);
} catch(\Throwable $e) {
    echo $e->getMessage();
    exit(1);
}

if ($returnCode !== 0) {
    echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
    echo "Aborting commit..." . PHP_EOL;
    exit(1);
}

echo array_pop($output) . PHP_EOL;

exit(0);
