testsuite: use relative paths, set PATH to absolute path

This approach works better with autotools, which supports the build
directory being complete outside the source tree.
This commit is contained in:
Michael Stapelberg 2016-10-10 21:14:59 +02:00
parent 4a52a7e9fb
commit 84e70a19a8
10 changed files with 41 additions and 62 deletions

View File

@ -17,19 +17,8 @@ use TAP::Parser::Aggregator;
use Time::HiRes qw(time); use Time::HiRes qw(time);
use IO::Handle; use IO::Handle;
my $dirname;
BEGIN {
use File::Basename;
use Cwd qw(abs_path);
# fileparse()[1] contains the directory portion of the specified path.
# See File::Basename(3p) for more details.
$dirname = (fileparse(abs_path($0)))[1];
}
# these are shipped with the testsuite # these are shipped with the testsuite
use lib $dirname . 'lib'; use lib qw(@abs_top_builddir@/testcases/lib @abs_top_srcdir@/testcases/lib);
use i3test::Util qw(slurp); use i3test::Util qw(slurp);
use StartXServer; use StartXServer;
use StatusLine; use StatusLine;
@ -82,17 +71,15 @@ my $result = GetOptions(
pod2usage(-verbose => 2, -exitcode => 0) if $help; pod2usage(-verbose => 2, -exitcode => 0) if $help;
chdir $dirname or die "Could not chdir into $dirname";
# Check for missing executables # Check for missing executables
my @binaries = qw( my @binaries = qw(
../i3 @abs_top_builddir@/i3
../i3bar/i3bar @abs_top_builddir@/i3bar/i3bar
../i3-config-wizard/i3-config-wizard @abs_top_builddir@/i3-config-wizard/i3-config-wizard
../i3-dump-log/i3-dump-log @abs_top_builddir@/i3-dump-log/i3-dump-log
../i3-input/i3-input @abs_top_builddir@/i3-input/i3-input
../i3-msg/i3-msg @abs_top_builddir@/i3-msg/i3-msg
../i3-nagbar/i3-nagbar @abs_top_builddir@/i3-nagbar/i3-nagbar
); );
foreach my $binary (@binaries) { foreach my $binary (@binaries) {
@ -100,15 +87,16 @@ foreach my $binary (@binaries) {
die "$binary is not an executable" unless -x $binary; die "$binary is not an executable" unless -x $binary;
} }
if ($options{coverage}) { $ENV{PATH} = join(':',
qx(command -v lcov &> /dev/null); '@abs_top_builddir@/i3-nagbar',
die "Cannot find lcov needed for coverage testing." if $?; '@abs_top_builddir@/i3-msg',
qx(command -v genhtml &> /dev/null); '@abs_top_builddir@/i3-input',
die "Cannot find genhtml needed for coverage testing." if $?; '@abs_top_builddir@/i3-dump-log',
'@abs_top_builddir@/i3-config-wizard',
# clean out the counters that may be left over from previous tests. '@abs_top_builddir@/i3bar',
qx(lcov -d ../ --zerocounters &> /dev/null); '@abs_top_builddir@',
} '@abs_top_srcdir@',
$ENV{PATH});
qx(Xephyr -help 2>&1); qx(Xephyr -help 2>&1);
die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on Debian)." if $?; die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on Debian)." if $?;
@ -120,7 +108,17 @@ die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on
my @testfiles = @ARGV; my @testfiles = @ARGV;
# if no files were passed on command line, run all tests from t/ # if no files were passed on command line, run all tests from t/
@testfiles = <t/*.t> if @testfiles == 0; if (scalar @testfiles == 0) {
@testfiles = <@abs_top_srcdir@/testcases/t/*.t> if @testfiles == 0;
} else {
@testfiles = map {
# Fully qualify each specified file if necessary
if (! -e $_) {
$_ = "@abs_top_srcdir@/testcases/$_";
}
$_
} @testfiles;
}
my $numtests = scalar @testfiles; my $numtests = scalar @testfiles;
@ -251,17 +249,6 @@ if ($numtests == 1) {
END { cleanup() } END { cleanup() }
if ($options{coverage}) {
print("\nGenerating test coverage report...\n");
qx(lcov -d ../ -b ../ --capture -o latest/i3-coverage.info);
qx(genhtml -o latest/i3-coverage latest/i3-coverage.info);
if ($?) {
print("Could not generate test coverage html. Did you compile i3 with test coverage support?\n");
} else {
print("Test coverage report generated in latest/i3-coverage\n");
}
}
# Report logfiles that match “(Leak|Address)Sanitizer:”. # Report logfiles that match “(Leak|Address)Sanitizer:”.
my @logs_with_leaks; my @logs_with_leaks;
for my $log (<$outdir/i3-log-for-*>) { for my $log (<$outdir/i3-log-for-*>) {

View File

@ -62,14 +62,6 @@ sub activate_i3 {
mkdir $ENV{XDG_RUNTIME_DIR}; mkdir $ENV{XDG_RUNTIME_DIR};
} }
$ENV{DISPLAY} = $args{display}; $ENV{DISPLAY} = $args{display};
$ENV{PATH} = join(':',
'../i3-nagbar',
'../i3-msg',
'../i3-config-wizard',
'../i3bar',
'..',
$ENV{PATH}
);
# We are about to exec, but we did not modify $^F to include $socket # We are about to exec, but we did not modify $^F to include $socket
# when creating the socket (because the file descriptor could have a # when creating the socket (because the file descriptor could have a
@ -96,7 +88,7 @@ sub activate_i3 {
# the interactive signalhandler to make it crash immediately instead. # the interactive signalhandler to make it crash immediately instead.
# Also disable logging to SHM since we redirect the logs anyways. # Also disable logging to SHM since we redirect the logs anyways.
# Force Xinerama because we use Xdmx for multi-monitor tests. # Force Xinerama because we use Xdmx for multi-monitor tests.
my $i3cmd = abs_path("../i3") . q| --shmlog-size=0 --disable-signalhandler --force-xinerama|; my $i3cmd = q|i3 --shmlog-size=0 --disable-signalhandler --force-xinerama|;
if (!$args{validate_config}) { if (!$args{validate_config}) {
# We only set logging if i3 is actually started, but not if we only # We only set logging if i3 is actually started, but not if we only
# validate the config file. This is to keep logging to a minimum as # validate the config file. This is to keep logging to a minimum as

View File

@ -125,7 +125,7 @@ sub worker_wait {
package main; package main;
local $@; local $@;
do "./$file"; do $file;
$test->ok(undef, "$@") if $@; $test->ok(undef, "$@") if $@;
# XXX hack, we need to trigger the read watcher once more # XXX hack, we need to trigger the read watcher once more

View File

@ -836,7 +836,7 @@ sub launch_with_config {
if ($config ne '-default') { if ($config ne '-default') {
say $fh $config; say $fh $config;
} else { } else {
open(my $conf_fh, '<', './i3-test.config') open(my $conf_fh, '<', '@abs_top_srcdir@/testcases/i3-test.config')
or $tester->BAIL_OUT("could not open default config: $!"); or $tester->BAIL_OUT("could not open default config: $!");
local $/; local $/;
say $fh scalar <$conf_fh>; say $fh scalar <$conf_fh>;

View File

@ -29,7 +29,7 @@ sub migrate_config {
print $fh $config; print $fh $config;
close($fh); close($fh);
my $cmd = "sh -c 'exec " . abs_path("../i3-migrate-config-to-v4") . " --v3 <$tmpfile'"; my $cmd = "sh -c 'exec i3-migrate-config-to-v4 --v3 <$tmpfile'";
return [ split /\n/, qx($cmd) ]; return [ split /\n/, qx($cmd) ];
} }

View File

@ -25,7 +25,7 @@ sub parser_calls {
# TODO: use a timeout, so that we can error out if it doesnt terminate # TODO: use a timeout, so that we can error out if it doesnt terminate
# TODO: better way of passing arguments # TODO: better way of passing arguments
my $stdout = qx(../test.commands_parser '$command' 2>&1 >&-); my $stdout = qx(test.commands_parser '$command' 2>&1 >&-);
# Filter out all debugging output. # Filter out all debugging output.
my @lines = split("\n", $stdout); my @lines = split("\n", $stdout);

View File

@ -28,7 +28,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
workspace 2 output DVI-I_1/digital workspace 2 output DVI-I_1/digital
EOT EOT
my $output = qx(../i3 -C -c $filename); my $output = qx(i3 -C -c $filename);
unlike($output, qr/ERROR/, 'no errors in i3 -C'); unlike($output, qr/ERROR/, 'no errors in i3 -C');
close($fh); close($fh);

View File

@ -25,7 +25,7 @@ sub parser_calls {
my ($command) = @_; my ($command) = @_;
my $stdout; my $stdout;
run [ '../test.config_parser', $command ], run [ 'test.config_parser', $command ],
'>/dev/null', '>/dev/null',
'2>', \$stdout; '2>', \$stdout;
# TODO: use a timeout, so that we can error out if it doesnt terminate # TODO: use a timeout, so that we can error out if it doesnt terminate

View File

@ -33,7 +33,7 @@ my $pid = launch_with_config($config);
my $stdout; my $stdout;
my $stderr; my $stderr;
run [ '../i3-dump-log/i3-dump-log' ], run [ 'i3-dump-log' ],
'>', \$stdout, '>', \$stdout,
'2>', \$stderr; '2>', \$stderr;
@ -49,7 +49,7 @@ cmd 'shmlog on';
my $random_nop = mktemp('nop.XXXXXX'); my $random_nop = mktemp('nop.XXXXXX');
cmd "nop $random_nop"; cmd "nop $random_nop";
run [ '../i3-dump-log/i3-dump-log' ], run [ 'i3-dump-log' ],
'>', \$stdout, '>', \$stdout,
'2>', \$stderr; '2>', \$stderr;
@ -62,7 +62,7 @@ like($stderr, qr#^$#, 'stderr empty');
cmd 'shmlog ' . (23 * 1024 * 1024); cmd 'shmlog ' . (23 * 1024 * 1024);
run [ '../i3-dump-log/i3-dump-log' ], run [ 'i3-dump-log' ],
'>', \$stdout, '>', \$stdout,
'2>', \$stderr; '2>', \$stderr;
@ -75,7 +75,7 @@ like($stderr, qr#^$#, 'stderr empty');
cmd 'shmlog off'; cmd 'shmlog off';
run [ '../i3-dump-log/i3-dump-log' ], run [ 'i3-dump-log' ],
'>', \$stdout, '>', \$stdout,
'2>', \$stderr; '2>', \$stderr;

View File

@ -26,7 +26,7 @@ sub check_config {
my ($config) = @_; my ($config) = @_;
my ($fh, $tmpfile) = tempfile(UNLINK => 1); my ($fh, $tmpfile) = tempfile(UNLINK => 1);
print $fh $config; print $fh $config;
my $output = qx(DISPLAY= ../i3 -C -c $tmpfile 2>&1); my $output = qx(DISPLAY= i3 -C -c $tmpfile 2>&1);
my $retval = $?; my $retval = $?;
$fh->flush; $fh->flush;
close($fh); close($fh);