From c2dd74aada8d92258b14727c057e5d02a4c8c7a4 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 9 Apr 2012 23:27:31 +0200 Subject: [PATCH] Abort with an error if no files are given. --- bin/blhc | 3 ++- t/tests.t | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) 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. -- 2.43.2