2 # vim:ts=4:sw=4:expandtab
3 # © 2012 Michael Stapelberg and contributors
4 # Script to create a new testcase from a template.
6 # # Create (and edit) a new test for moving floating windows
7 # ./new-test floating move
9 # # Create (and edit) a multi-monitor test for moving workspaces
10 # ./new-test -m move workspaces
14 use File::Basename qw(basename);
19 Script to create a new testcase from a template.
21 # Create (and edit) a new test for moving floating windows
22 ./new-test floating move
24 # Create (and edit) a multi-monitor test for moving workspaces
25 ./new-test -m move workspaces
30 my $result = GetOptions(
31 'multi-monitor|mm' => \$multi_monitor
34 my $testname = join(' ', @ARGV);
37 unless (length $testname) {
44 # vim:ts=4:sw=4:expandtab
46 # Please read the following documents before working on tests:
47 # • https://build.i3wm.org/docs/testsuite.html
50 # • https://build.i3wm.org/docs/lib-i3test.html
51 # (alternatively: perldoc ./testcases/lib/i3test.pm)
53 # • https://build.i3wm.org/docs/ipc.html
56 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
57 # (unless you are already familiar with Perl)
59 # TODO: Description of this file.
61 # Bug still in: #GITREV#
64 # Figure out the next test filename.
67 @files = grep { basename($_) =~ /^5/ } <t/*.t>;
69 @files = grep { basename($_) !~ /^5/ } <t/*.t>;
71 my ($latest) = sort { $b cmp $a } @files;
72 my ($num) = (basename($latest) =~ /^([0-9]+)/);
73 my $filename = "t/" . ($num+1) . "-" . lc($testname) . ".t";
75 # Get the current git revision.
76 chomp(my $gitrev = qx(git describe --tags));
77 $header =~ s/#GITREV#/$gitrev/g;
79 # Create the file based on our template.
80 open(my $fh, '>', $filename);
84 use i3test i3_autostart => 0;
88 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
90 fake-outputs 1024x768+0+0,1024x768+1024+0
93 my $pid = launch_with_config($config);
96 exit_gracefully($pid);
110 my $editor = $ENV{EDITOR};
112 exec $editor, $filename;