From: Simon Ruderich Date: Mon, 9 Apr 2012 21:27:31 +0000 (+0200) Subject: Abort with an error if no files are given. X-Git-Tag: 0.01~25 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=c2dd74aada8d92258b14727c057e5d02a4c8c7a4;p=blhc%2Fblhc.git Abort with an error if no files are given. --- diff --git a/bin/blhc b/bin/blhc index 0fbf4c9..835e9e0 100755 --- a/bin/blhc +++ b/bin/blhc @@ -441,7 +441,8 @@ if (not Getopt::Long::GetOptions( 'color' => \$option_color, 'arch=s' => \$option_arch, 'buildd' => \$option_buildd, - )) { + ) + or scalar @ARGV == 0) { require Pod::Usage; Pod::Usage::pod2usage(2); } diff --git a/t/tests.t b/t/tests.t index 7fc4f9e..95a8f40 100644 --- a/t/tests.t +++ b/t/tests.t @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 110; +use Test::More tests => 112; sub is_blhc { @@ -31,7 +31,8 @@ sub is_blhc { $file = "@{$file}"; } - my $output = `./bin/blhc $options ./t/logs/$file 2>&1`; + $file = "./t/logs/$file" if $file; + my $output = `./bin/blhc $options $file 2>&1`; if ($options) { $options = ' '. $options; @@ -43,13 +44,17 @@ sub is_blhc { # Usage. -is_blhc 'empty', '--invalid', 2, - 'Unknown option: invalid -Usage: +my $usage = + 'Usage: blhc [*options*] *..* '; +is_blhc '', '--invalid', 2, + "Unknown option: invalid\n" + . $usage; +is_blhc '', '', 2, + $usage; # No compiler commands found.