mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Convert appveyor to use run-tests.pl.
This commit is contained in:
parent
2ec239da2a
commit
fffa090583
4 changed files with 213 additions and 1 deletions
|
@ -18,6 +18,7 @@ install:
|
|||
- SET PERL_MB_OPT=--install_base C:/_P5
|
||||
- SET PERL_MM_OPT=INSTALL_BASE=C:/_P5
|
||||
- perl -v
|
||||
- cpanm --notest File::Find::Object Task::FreecellSolver::Testing Test::TrailingSpace
|
||||
- echo %PATH%
|
||||
build: off
|
||||
test_script:
|
||||
|
@ -29,7 +30,8 @@ test_script:
|
|||
- set PATH=C:\libtap\bin;%PATH%
|
||||
- set HARNESS_BREAK=1
|
||||
- set FCS_USE_TEST_RUN=1
|
||||
- gmake test
|
||||
- gmake pretest
|
||||
- perl run-tests.pl
|
||||
cache:
|
||||
- C:\libtap -> .appveyor.yml
|
||||
- C:\_P5 -> .appveyor.yml
|
||||
|
|
199
run-tests.pl
Normal file
199
run-tests.pl
Normal file
|
@ -0,0 +1,199 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use autodie;
|
||||
|
||||
use Cwd ();
|
||||
use File::Spec ();
|
||||
use File::Copy qw/ copy /;
|
||||
use File::Path qw/ mkpath /;
|
||||
use Getopt::Long qw/ GetOptions /;
|
||||
use Env::Path ();
|
||||
use Path::Tiny qw/ path /;
|
||||
use File::Basename qw/ basename dirname /;
|
||||
|
||||
my $bindir = dirname(__FILE__);
|
||||
my $abs_bindir = File::Spec->rel2abs($bindir);
|
||||
|
||||
# Whether to use prove instead of runprove.
|
||||
my $use_prove = $ENV{FCS_USE_TEST_RUN} ? 0 : 1;
|
||||
my $num_jobs = $ENV{TEST_JOBS};
|
||||
|
||||
sub _is_parallized
|
||||
{
|
||||
return ( $use_prove && $num_jobs );
|
||||
}
|
||||
|
||||
sub _calc_prove
|
||||
{
|
||||
return [ 'prove',
|
||||
( defined($num_jobs) ? sprintf( "-j%d", $num_jobs ) : () ) ];
|
||||
}
|
||||
|
||||
my $exit_success;
|
||||
|
||||
sub run_tests
|
||||
{
|
||||
my $tests = shift;
|
||||
|
||||
my @cmd = ( ( $use_prove ? @{ _calc_prove() } : 'runprove' ), @$tests );
|
||||
if ( $ENV{RUN_TESTS_VERBOSE} )
|
||||
{
|
||||
print "Running [@cmd]\n";
|
||||
}
|
||||
|
||||
# Workaround for Windows spawning-SNAFU.
|
||||
my $exit_code = system(@cmd);
|
||||
exit( $exit_success ? 0 : $exit_code ? (-1) : 0 );
|
||||
}
|
||||
|
||||
my $tests_glob = "*.{t.exe,py,t}";
|
||||
my $exclude_re_s;
|
||||
|
||||
my @execute;
|
||||
GetOptions(
|
||||
'--exclude-re=s' => \$exclude_re_s,
|
||||
'--execute|e=s' => \@execute,
|
||||
'--exit0!' => \$exit_success,
|
||||
'--glob=s' => \$tests_glob,
|
||||
'--prove!' => \$use_prove,
|
||||
'--jobs|j=n' => \$num_jobs,
|
||||
) or die "Wrong opts - $!";
|
||||
|
||||
sub myglob
|
||||
{
|
||||
return glob( shift . "/$tests_glob" );
|
||||
}
|
||||
|
||||
{
|
||||
my $fcs_path = Cwd::getcwd();
|
||||
local $ENV{FCS_PATH} = $fcs_path;
|
||||
local $ENV{FCS_SRC_PATH} = $abs_bindir;
|
||||
|
||||
local $ENV{FREECELL_SOLVER_QUIET} = 1;
|
||||
Env::Path->PATH->Prepend(
|
||||
File::Spec->catdir( Cwd::getcwd(), "board_gen" ),
|
||||
File::Spec->catdir( $abs_bindir, "t", "scripts" ),
|
||||
);
|
||||
|
||||
my $IS_WIN = ( $^O eq "MSWin32" );
|
||||
Env::Path->CPATH->Prepend( $abs_bindir, );
|
||||
|
||||
Env::Path->LD_LIBRARY_PATH->Prepend($fcs_path);
|
||||
if ($IS_WIN)
|
||||
{
|
||||
# For the shared objects.
|
||||
Env::Path->PATH->Append($fcs_path);
|
||||
}
|
||||
|
||||
my $foo_lib_dir = File::Spec->catdir( $abs_bindir, "tests", "lib" );
|
||||
foreach my $add_lib ( Env::Path->PERL5LIB(), Env::Path->PYTHONPATH() )
|
||||
{
|
||||
$add_lib->Append($foo_lib_dir);
|
||||
$add_lib->Append($abs_bindir);
|
||||
}
|
||||
|
||||
my $get_config_fn = sub {
|
||||
my $basename = shift;
|
||||
|
||||
return File::Spec->rel2abs(
|
||||
File::Spec->catdir( $bindir, "tests", "config", $basename ),
|
||||
);
|
||||
};
|
||||
|
||||
local $ENV{HARNESS_ALT_INTRP_FILE} = $get_config_fn->(
|
||||
$IS_WIN
|
||||
? "alternate-interpreters--mswin.yml"
|
||||
: "alternate-interpreters.yml"
|
||||
);
|
||||
|
||||
local $ENV{HARNESS_TRIM_FNS} = 'keep:1';
|
||||
|
||||
local $ENV{HARNESS_PLUGINS} = join(
|
||||
' ', qw(
|
||||
BreakOnFailure ColorSummary ColorFileVerdicts AlternateInterpreters
|
||||
TrimDisplayedFilenames
|
||||
)
|
||||
);
|
||||
|
||||
my $is_ninja = ( -e "build.ninja" );
|
||||
my $MAKE = $IS_WIN ? 'gmake' : 'make';
|
||||
if ($is_ninja)
|
||||
{
|
||||
system( "ninja", "pretest" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( system( $MAKE, "-s", "pretest" ) )
|
||||
{
|
||||
die "$MAKE failed";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$is_ninja )
|
||||
{
|
||||
if ( system( $MAKE, "-s" ) )
|
||||
{
|
||||
die "$MAKE failed";
|
||||
}
|
||||
}
|
||||
|
||||
# Put the valgrind tests last, because they take a long time.
|
||||
my @tests =
|
||||
sort {
|
||||
( ( ( $a =~ /valgrind/ ) <=> ( $b =~ /valgrind/ ) ) *
|
||||
( _is_parallized() ? -1 : 1 ) )
|
||||
|| ( basename($a) cmp basename($b) )
|
||||
|| ( $a cmp $b )
|
||||
} (
|
||||
( myglob("$abs_bindir/tests/*") )
|
||||
);
|
||||
|
||||
# print "tests = @tests \n";
|
||||
if ( defined($exclude_re_s) )
|
||||
{
|
||||
my $re = qr/$exclude_re_s/ms;
|
||||
@tests = grep { basename($_) !~ $re } @tests;
|
||||
}
|
||||
|
||||
if ( !$ENV{FCS_TEST_BUILD} )
|
||||
{
|
||||
@tests = grep { !/build-process/ } @tests;
|
||||
}
|
||||
|
||||
if ( $ENV{FCS_TEST_WITHOUT_VALGRIND} )
|
||||
{
|
||||
@tests = grep { !/valgrind/ } @tests;
|
||||
}
|
||||
local $ENV{FCS_TEST_TAGS} = $ENV{FCS_TEST_TAGS} // '';
|
||||
print STDERR "FCS_PATH = $ENV{FCS_PATH}\n";
|
||||
print STDERR "FCS_SRC_PATH = $ENV{FCS_SRC_PATH}\n";
|
||||
print STDERR "FCS_TEST_TAGS = <$ENV{FCS_TEST_TAGS}>\n";
|
||||
if ( $ENV{FCS_TEST_SHELL} )
|
||||
{
|
||||
system("bash");
|
||||
}
|
||||
elsif (@execute)
|
||||
{
|
||||
system(@execute);
|
||||
}
|
||||
else
|
||||
{
|
||||
run_tests( \@tests );
|
||||
}
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This file is part of Freecell Solver. It is subject to the license terms in
|
||||
the COPYING.txt file found in the top-level directory of this distribution
|
||||
and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of
|
||||
Freecell Solver, including this file, may be copied, modified, propagated,
|
||||
or distributed except according to the terms contained in the COPYING file.
|
||||
|
||||
Copyright (c) 2000 Shlomi Fish
|
||||
|
||||
=cut
|
7
tests/config/alternate-interpreters--mswin.yml
Normal file
7
tests/config/alternate-interpreters--mswin.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- cmd: python3
|
||||
pattern: \.py(?:\.t)?\z
|
||||
type: regex
|
||||
- cmd: unity
|
||||
pattern: \.exe\z
|
||||
type: regex
|
4
tests/config/alternate-interpreters.yml
Normal file
4
tests/config/alternate-interpreters.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- cmd: unity
|
||||
pattern: \.exe\z
|
||||
type: regex
|
Loading…
Add table
Reference in a new issue