mirror of
https://github.com/ovh/the-bastion.git
synced 2025-02-24 23:54:27 +08:00
chore: use TAP::Harness for unit tests
This commit is contained in:
parent
faaa2ed651
commit
0e2138a389
5 changed files with 26 additions and 17 deletions
|
@ -758,20 +758,11 @@ runtests()
|
|||
|
||||
if [ "$opt_unit_tests" = 1 ]; then
|
||||
echo '=== running unit tests ==='
|
||||
# a while read loop doesn't work well here:
|
||||
# shellcheck disable=SC2044
|
||||
for f in $(find "$basedir/tests/unit/" -mindepth 1 -maxdepth 1 -type f -name "*.pl" -print)
|
||||
do
|
||||
fbasename=$(basename "$f")
|
||||
echo "-> $fbasename"
|
||||
set +e
|
||||
$r0 perl "$opt_remote_basedir/tests/unit/$fbasename"; ret=$?
|
||||
set -e
|
||||
if [ $ret != 0 ]; then
|
||||
printf "%b%b%b\\n" "$WHITE_ON_RED" "Unit tests failed (ret=$ret) :(" "$NOC"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
$r0 perl "$opt_remote_basedir/tests/unit/run-tests.pl"; ret=$?
|
||||
if [ $ret != 0 ]; then
|
||||
printf "%b%b%b\\n" "$WHITE_ON_RED" "Unit tests failed (ret=$ret) :(" "$NOC"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$opt_functional_tests" = 1 ]; then
|
||||
|
|
18
tests/unit/run-tests.pl
Executable file
18
tests/unit/run-tests.pl
Executable file
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/env perl
|
||||
# vim: set filetype=perl ts=4 sw=4 sts=4 et:
|
||||
use common::sense;
|
||||
use TAP::Harness;
|
||||
|
||||
use FindBin qw{ $RealDir };
|
||||
|
||||
my @testfiles = glob("$RealDir/tests/*.t");
|
||||
print "Got " . @testfiles . " unit test files to run:\n";
|
||||
|
||||
my $harness = TAP::Harness->new(
|
||||
{
|
||||
verbosity => 0,
|
||||
failures => 1,
|
||||
color => 1,
|
||||
}
|
||||
);
|
||||
exit($harness->runtests(@testfiles)->all_passed ? 0 : 1);
|
2
tests/unit/run.pl → tests/unit/tests/base.t
Executable file → Normal file
2
tests/unit/run.pl → tests/unit/tests/base.t
Executable file → Normal file
|
@ -5,7 +5,7 @@ use Test::More;
|
|||
use Test::Deep;
|
||||
|
||||
use File::Basename;
|
||||
use lib dirname(__FILE__) . '/../../lib/perl';
|
||||
use lib dirname(__FILE__) . '/../../../lib/perl';
|
||||
use OVH::Bastion;
|
||||
use OVH::Result;
|
||||
use JSON;
|
2
tests/unit/is_access_granted_ipv4.pl → tests/unit/tests/is_access_granted_ipv4.t
Executable file → Normal file
2
tests/unit/is_access_granted_ipv4.pl → tests/unit/tests/is_access_granted_ipv4.t
Executable file → Normal file
|
@ -5,7 +5,7 @@ use Test::More;
|
|||
use Test::Deep;
|
||||
|
||||
use File::Basename;
|
||||
use lib dirname(__FILE__) . '/../../lib/perl';
|
||||
use lib dirname(__FILE__) . '/../../../lib/perl';
|
||||
use OVH::Bastion;
|
||||
use OVH::Result;
|
||||
|
2
tests/unit/is_access_granted_ipv6.pl → tests/unit/tests/is_access_granted_ipv6.t
Executable file → Normal file
2
tests/unit/is_access_granted_ipv6.pl → tests/unit/tests/is_access_granted_ipv6.t
Executable file → Normal file
|
@ -5,7 +5,7 @@ use Test::More;
|
|||
use Test::Deep;
|
||||
|
||||
use File::Basename;
|
||||
use lib dirname(__FILE__) . '/../../lib/perl';
|
||||
use lib dirname(__FILE__) . '/../../../lib/perl';
|
||||
use OVH::Bastion;
|
||||
use OVH::Result;
|
||||
|
Loading…
Reference in a new issue