Testcases: new-test prints usage without input
Prevent the accidental creation of new tests with empty names by printing usage information for new-test when the test name would be empty.
This commit is contained in:
parent
cf3da1c433
commit
9adff26dcf
|
@ -15,6 +15,16 @@ use File::Basename qw(basename);
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use v5.10;
|
use v5.10;
|
||||||
|
|
||||||
|
my $usage = <<'EOF';
|
||||||
|
Script to create a new testcase from a template.
|
||||||
|
|
||||||
|
# Create (and edit) a new test for moving floating windows
|
||||||
|
./new-test floating move
|
||||||
|
|
||||||
|
# Create (and edit) a multi-monitor test for moving workspaces
|
||||||
|
./new-test -m move workspaces
|
||||||
|
EOF
|
||||||
|
|
||||||
my $multi_monitor;
|
my $multi_monitor;
|
||||||
|
|
||||||
my $result = GetOptions(
|
my $result = GetOptions(
|
||||||
|
@ -24,6 +34,11 @@ my $result = GetOptions(
|
||||||
my $testname = join(' ', @ARGV);
|
my $testname = join(' ', @ARGV);
|
||||||
$testname =~ s/ /-/g;
|
$testname =~ s/ /-/g;
|
||||||
|
|
||||||
|
unless (length $testname) {
|
||||||
|
say $usage;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
my $header = <<'EOF';
|
my $header = <<'EOF';
|
||||||
#!perl
|
#!perl
|
||||||
# vim:ts=4:sw=4:expandtab
|
# vim:ts=4:sw=4:expandtab
|
||||||
|
|
Loading…
Reference in New Issue