]> git.sur5r.net Git - i3/i3/blob - testcases/complete-run.pl
tests: mark t/10-dock.t as TODO, dock clients not implemented yet (makes all tests...
[i3/i3] / testcases / complete-run.pl
1 #!/usr/bin/env perl
2 # vim:ts=4:sw=4:expandtab
3
4 use strict;
5 use warnings;
6 use v5.10;
7 use DateTime;
8 use Data::Dumper;
9 use Cwd qw(abs_path getcwd);
10 use Proc::Background;
11 use TAP::Harness;
12 use TAP::Parser::Aggregator;
13 use File::Basename qw(basename);
14
15 my $i3cmd = "export DISPLAY=:0; exec " . abs_path("../i3") . " -V -d all -c " . abs_path("../i3.config");
16
17 # 1: get a list of all testcases
18 my $curdir = getcwd();
19 my @testfiles = @ARGV;
20
21 # if no files were passed on command line, run all tests
22 if (@testfiles == 0) {
23     chdir "t";
24     push @testfiles, "t/$_" while (<*.t>);
25     chdir $curdir;
26 }
27
28 # 2: create an output directory for this test-run
29 my $outdir = "testsuite-";
30 $outdir .= DateTime->now->strftime("%Y-%m-%d-%H-%M-%S-");
31 $outdir .= `git describe --tags`;
32 chomp($outdir);
33 mkdir($outdir) or die "Could not create $outdir";
34 unlink("latest") if -e "latest";
35 symlink("$outdir", "latest") or die "Could not symlink latest to $outdir";
36
37 # 3: run all tests
38 my $harness = TAP::Harness->new({
39     verbosity => 1,
40     lib => [ 't/lib' ]
41 });
42 my $aggregator = TAP::Parser::Aggregator->new();
43 $aggregator->start();
44 for my $t (@testfiles) {
45     my $logpath = "$outdir/i3-log-for-" . basename($t);
46     my $cmd = "$i3cmd >$logpath 2>&1";
47
48     my $process = Proc::Background->new($cmd);
49     say "testing $t with logfile $logpath";
50     $harness->aggregate_tests($aggregator, [ $t ]);
51     kill(9, $process->pid) or die "could not kill i3";
52 }
53 $aggregator->stop();
54
55 # 4: print summary
56 $harness->summary($aggregator);