GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit 29921081 authored by boklm's avatar boklm

Add support for configuration files

parent b819e12b
......@@ -66,6 +66,10 @@ The <tbb-file> can be:
Available options
-----------------
--config=<file>
Select a configuration file. See the section about Configuration
Files below.
--no-gpgcheck
Disable gpg check when downloading a sha256sum.txt file.
......@@ -117,3 +121,17 @@ Available options
When using xvfb, this sets the default resolution. The default
is 1024x768.
Configuration Files
-------------------
In addition to setting options using command line arguments, it is
possible to set options using a configuration file and the --config
option. If the path given to the --config option is relative, it is
expected to be in the config directory.
The configuration file is a perl script which when evaluated should
return a hash containing the configuration. The options set by the
default configuration and command line arguments are available to this
script in the $option hash reference.
......@@ -4,6 +4,9 @@ use warnings;
use strict;
use FindBin;
use Getopt::Long;
use File::Slurp;
use TBBTestSuite::Common qw(exit_error);
use Data::Dump qw(pp);
our (@ISA, @EXPORT_OK);
BEGIN {
......@@ -32,11 +35,19 @@ my %default_options = (
sub get_options {
my @options = qw(mozmill! selenium! starttor! tor-control-port=i
tor-socks-port=i reports-dir=s gpgcheck! keyring=s
virtualenv=s xvfb! name=s download-dir=s);
my %res = %default_options;
Getopt::Long::GetOptionsFromArray(\@_, \%res, @options) || exit 1;
$res{args} = \@_;
return \%res;
virtualenv=s xvfb! name=s download-dir=s config=s);
my (%cli, %config);
Getopt::Long::GetOptionsFromArray(\@_, \%cli, @options) || exit 1;
$cli{args} = \@_ if @_;
if ($cli{config}) {
my $cfile = $cli{config} =~ m/^\// ? $cli{config}
: "$FindBin::Bin/config/$cli{config}";
exit_error "Can't find config file $cfile" unless -f $cfile;
my $o = { %default_options, %cli };
%config = eval('my $options = ' . pp($o) . "\n;" . read_file($cfile));
exit_error "Error reading config file $cfile:\n$@" unless %config;
}
return { %default_options, %config, %cli };
}
our $options = get_options(@ARGV);
......
Markdown is supported
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