Commit 12d98a84 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Glob incoming file paths from CLI options.

Otherwise, arguments to long options given with '=' are
not globbed.

Adress issue vecs/fiji#62
parent cbe391c1
......@@ -4,7 +4,23 @@ use warnings;
use Log::Log4perl qw(get_logger);
use Log::Log4perl::Level;
use Cwd 'realpath';
use if $^O eq "MSWin32", "Win32::TieRegistry";
use if $^O eq "MSWin32", 'Win32::TieRegistry';
use if $^O eq "MSWin32", 'File::DosGlob' => qw(glob);
use if $^O ne "MSWin32", 'File::Glob' => qw(:bsd_glob);
use Data::Dumper;
sub glob_path {
my $path = shift;
if ($^O ne "MSWin32") {
$path = bsd_glob($path);
} else {
# Do this for windows
$path = glob($path);
}
# TODO: Validate path here, apply realpath?
return $path;
}
## function increase_verbosity($verbosity_delta)
#
......
......@@ -57,14 +57,20 @@ sub main {
# Validate parameters
if (!defined $cfg->{'settings_name'} || !defined $cfg->{'tests_name'} || !defined $cfg->{'mode'}) {
my $msg;
my $msg = "";
$msg .= "$0: No settings file specified.\n" if (!defined $cfg->{'settings_name'});
$msg .= "$0: No tests file specified.\n" if (!defined $cfg->{'tests_name'});
$msg .= "$0: No test mode specified.\n" if (!defined $cfg->{'tests_name'});
$msg .= "$0: No test mode specified.\n" if (!defined $cfg->{'mode'});
$logger->error($msg);
pod2usage(-exitval=>1,-msg=>$msg,-verbose);
}
# Do our own globbing because the shell does not glob
# when the filename is passed with --long-option=PATH
foreach my $k ('settings_name','tests_name') {
$cfg->{$k} = FIJI::Utils::glob_path($cfg->{$k});
}
if ($cfg->{'mode'} ne 'auto' &&
$cfg->{'mode'} ne 'manual' &&
$cfg->{'mode'} ne 'random') {
......
......@@ -234,7 +234,7 @@ sub main {
### Load settings
if (defined $settings_filename) {
my $filename = $settings_filename;
my $filename = FIJI::Utils::glob_path($settings_filename);
my ($tmp_settings, $warn) = FIJI::Settings->new('download', $filename);
if (defined($warn)) {
my $msg = "Settings file $filename could not be loaded correctly.\n$warn";
......@@ -664,6 +664,7 @@ sub _ctrl_frame {
sub _read_tests_file {
my $logger = get_logger("");
my ($self, $filename) = @_;
$filename = FIJI::Utils::glob_path($filename);
my $tmp_tests;
if (-e $filename) {
# the mode 'GUI' is not defined in any ->phases_opt lists in TESTCONSTMAP and TESTPATMAP, thus all possible parameters have to be present.
......
......@@ -505,9 +505,9 @@ if (defined $break) {
# clean up the passed paths
# @FIXME needed ?
$options->{'fiji_settings_file'} = File::Spec->canonpath($options->{'fiji_settings_file'});
$options->{'netlist_file'} = File::Spec->canonpath($options->{'netlist_file'});
$options->{'output_dir'} = File::Spec->canonpath($options->{'output_dir'}) if defined $options->{'output_dir'};
$options->{'fiji_settings_file'} = File::Spec->canonpath(FIJI::Utils::glob_path($options->{'fiji_settings_file'}));
$options->{'netlist_file'} = File::Spec->canonpath(FIJI::Utils::glob_path($options->{'netlist_file'}));
$options->{'output_dir'} = File::Spec->canonpath(FIJI::Utils::glob_path($options->{'output_dir'})) if defined $options->{'output_dir'};
FIJI::Utils::increase_verbosity($options->{'verbosity_delta'});
......
......@@ -162,7 +162,7 @@ sub main {
# Load settings if specified
#
if (defined $settings_filename) {
my $filename = $settings_filename;
my $filename = FIJI::Utils::glob_path($settings_filename);
my $fr = $mw;
if (-e $filename) {
my $tmp_settings = \%{Clone::clone($self->{'settings'})};
......@@ -202,7 +202,7 @@ sub main {
${$self->{'ini_name'}} = $filename;
}
$self->_load_netlist_file($netlist_filename) if (defined $netlist_filename);
$self->_load_netlist_file(FIJI::Utils::glob_path($netlist_filename)) if (defined $netlist_filename);
MainLoop if !$only_load;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment