Permalink
Browse files

fix up calling conventionsfor easier testing

  • Loading branch information...
1 parent 05ecee1 commit ddf2557b00559c97e8e4a8d5e4b9d21be4e5137d @grantm committed May 27, 2010
Showing with 12 additions and 16 deletions.
  1. +11 −6 bin/bcvi
  2. +1 −10 t/00_syntax.t
View
@@ -56,14 +56,17 @@ my(
%plugin_loaded, @plugins,
);
-App::BCVI->base_init();
+run(@ARGV) unless caller(); # Don't run anything if loaded via 'require'
-App::BCVI->load_plugins();
+sub run {
+ App::BCVI->base_init();
-App::BCVI->base_class()->process_command_line(@ARGV);
+ App::BCVI->load_plugins();
-exit;
+ App::BCVI->base_class()->process_command_line(@_);
+ exit;
+}
sub version { return $App::BCVI::VERSION; }
sub base_class { return $class_map{base}; }
@@ -410,14 +413,14 @@ sub process_command_line {
my $opt = $class->option_defaults();
my @cfg = $class->getopt_config();
- local(@main::ARGV) = @args;
+ local(@ARGV) = @args;
Getopt::Long::GetOptions($opt, @cfg) or $class->die_synopsis();
my $handler = $opt->{listener}
? $class->server_class
: $class->client_class;
- $handler->new(_options => $opt)->dispatch(@main::ARGV);
+ $handler->new(_options => $opt)->dispatch(@ARGV);
}
@@ -1325,6 +1328,8 @@ sub pager {
}
+1;
+
__DATA__
=head1 NAME
View
@@ -11,13 +11,4 @@ my @part = File::Spec->splitdir($FindBin::Bin);
splice(@part, -1, 1, 'bin', 'bcvi');
my $path = File::Spec->catfile(@part);
-my $output = `perl -c $path 2>&1`;
-
-if($? == 0) {
- ok(1, 'syntax chack of bin/bcvi');
-}
-else {
- ok(0, 'syntax chack of bin/bcvi');
- diag($output);
-}
-
+require_ok($path);

0 comments on commit ddf2557

Please sign in to comment.