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 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
use lib $dirname . 'lib';
use lib qw(@abs_top_builddir@/testcases/lib @abs_top_srcdir@/testcases/lib);
use i3test::Util qw(slurp);
use StartXServer;
use StatusLine;
@ -82,17 +71,15 @@ my $result = GetOptions(
pod2usage(-verbose => 2, -exitcode => 0) if $help;
chdir $dirname or die "Could not chdir into $dirname";
# Check for missing executables
my @binaries = qw(
../i3
../i3bar/i3bar
../i3-config-wizard/i3-config-wizard
../i3-dump-log/i3-dump-log
../i3-input/i3-input
../i3-msg/i3-msg
../i3-nagbar/i3-nagbar
@abs_top_builddir@/i3
@abs_top_builddir@/i3bar/i3bar
@abs_top_builddir@/i3-config-wizard/i3-config-wizard
@abs_top_builddir@/i3-dump-log/i3-dump-log
@abs_top_builddir@/i3-input/i3-input
@abs_top_builddir@/i3-msg/i3-msg
@abs_top_builddir@/i3-nagbar/i3-nagbar
);
foreach my $binary (@binaries) {
@ -100,15 +87,16 @@ foreach my $binary (@binaries) {
die "$binary is not an executable" unless -x $binary;
}
if ($options{coverage}) {
qx(command -v lcov &> /dev/null);
die "Cannot find lcov needed for coverage testing." if $?;
qx(command -v genhtml &> /dev/null);
die "Cannot find genhtml needed for coverage testing." if $?;
# clean out the counters that may be left over from previous tests.
qx(lcov -d ../ --zerocounters &> /dev/null);
}
$ENV{PATH} = join(':',
'@abs_top_builddir@/i3-nagbar',
'@abs_top_builddir@/i3-msg',
'@abs_top_builddir@/i3-input',
'@abs_top_builddir@/i3-dump-log',
'@abs_top_builddir@/i3-config-wizard',
'@abs_top_builddir@/i3bar',
'@abs_top_builddir@',
'@abs_top_srcdir@',
$ENV{PATH});
qx(Xephyr -help 2>&1);
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;
# 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;
@ -251,17 +249,6 @@ if ($numtests == 1) {
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:”.
my @logs_with_leaks;
for my $log (<$outdir/i3-log-for-*>) {

View File

@ -62,14 +62,6 @@ sub activate_i3 {
mkdir $ENV{XDG_RUNTIME_DIR};
}
$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
# 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.
# Also disable logging to SHM since we redirect the logs anyways.
# 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}) {
# 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

View File

@ -125,7 +125,7 @@ sub worker_wait {
package main;
local $@;
do "./$file";
do $file;
$test->ok(undef, "$@") if $@;
# 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') {
say $fh $config;
} 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: $!");
local $/;
say $fh scalar <$conf_fh>;

View File

@ -29,7 +29,7 @@ sub migrate_config {
print $fh $config;
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) ];
}

View File

@ -25,7 +25,7 @@ sub parser_calls {
# TODO: use a timeout, so that we can error out if it doesnt terminate
# 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.
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
EOT
my $output = qx(../i3 -C -c $filename);
my $output = qx(i3 -C -c $filename);
unlike($output, qr/ERROR/, 'no errors in i3 -C');
close($fh);

View File

@ -25,7 +25,7 @@ sub parser_calls {
my ($command) = @_;
my $stdout;
run [ '../test.config_parser', $command ],
run [ 'test.config_parser', $command ],
'>/dev/null',
'2>', \$stdout;
# 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 $stderr;
run [ '../i3-dump-log/i3-dump-log' ],
run [ 'i3-dump-log' ],
'>', \$stdout,
'2>', \$stderr;
@ -49,7 +49,7 @@ cmd 'shmlog on';
my $random_nop = mktemp('nop.XXXXXX');
cmd "nop $random_nop";
run [ '../i3-dump-log/i3-dump-log' ],
run [ 'i3-dump-log' ],
'>', \$stdout,
'2>', \$stderr;
@ -62,7 +62,7 @@ like($stderr, qr#^$#, 'stderr empty');
cmd 'shmlog ' . (23 * 1024 * 1024);
run [ '../i3-dump-log/i3-dump-log' ],
run [ 'i3-dump-log' ],
'>', \$stdout,
'2>', \$stderr;
@ -75,7 +75,7 @@ like($stderr, qr#^$#, 'stderr empty');
cmd 'shmlog off';
run [ '../i3-dump-log/i3-dump-log' ],
run [ 'i3-dump-log' ],
'>', \$stdout,
'2>', \$stderr;

View File

@ -26,7 +26,7 @@ sub check_config {
my ($config) = @_;
my ($fh, $tmpfile) = tempfile(UNLINK => 1);
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 = $?;
$fh->flush;
close($fh);