From b08eb5216d86cbe384b9f5e3c476dcb41d771e85 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 13 Nov 2017 17:28:31 +0000 Subject: Rename 'config' to 'env'. "Environment" more accurately reflects its usage, and this opens up "config" for global configuration. * Flags -c -> -e (-config -> -env). --- README | 2 +- t/fixtures/input | 29 ----------------------------- t/fixtures/localhost.conf | 3 --- t/fixtures/sample.env | 3 +++ t/fixtures/sample.input | 29 +++++++++++++++++++++++++++++ t/fixtures/sample.plan | 6 ++++++ t/fixtures/testplan | 6 ------ t/samplerun.t | 12 ++++++------ xmpt | 15 +++++++-------- 9 files changed, 52 insertions(+), 53 deletions(-) delete mode 100644 t/fixtures/input delete mode 100644 t/fixtures/localhost.conf create mode 100644 t/fixtures/sample.env create mode 100644 t/fixtures/sample.input create mode 100644 t/fixtures/sample.plan delete mode 100644 t/fixtures/testplan diff --git a/README b/README index b4646dc..0688a73 100644 --- a/README +++ b/README @@ -108,5 +108,5 @@ corresponding server data is in 'input'. So to run a quick-and-dirty test, execute: #+BEGIN -% xmpt -c t/fixtures/localhost.conf -p t/fixtures/testplan < t/fixtures/input +% xmpt -e t/fixtures/sample.env -p t/fixtures/sample.plan < t/fixtures/sample.input #+END diff --git a/t/fixtures/input b/t/fixtures/input deleted file mode 100644 index 2d508fe..0000000 --- a/t/fixtures/input +++ /dev/null @@ -1,29 +0,0 @@ - - - - SCRAM-SHA-1 - PLAIN - - - - - - - - - - - - test0@localhost/xmpt - - - - diff --git a/t/fixtures/localhost.conf b/t/fixtures/localhost.conf deleted file mode 100644 index bc462d7..0000000 --- a/t/fixtures/localhost.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Domain and bare JID are calculated from full. -full_jid=test0@localhost/xmpt -password=test diff --git a/t/fixtures/sample.env b/t/fixtures/sample.env new file mode 100644 index 0000000..bc462d7 --- /dev/null +++ b/t/fixtures/sample.env @@ -0,0 +1,3 @@ +# Domain and bare JID are calculated from full. +full_jid=test0@localhost/xmpt +password=test diff --git a/t/fixtures/sample.input b/t/fixtures/sample.input new file mode 100644 index 0000000..2d508fe --- /dev/null +++ b/t/fixtures/sample.input @@ -0,0 +1,29 @@ + + + + SCRAM-SHA-1 + PLAIN + + + + + + + + + + + + test0@localhost/xmpt + + + + diff --git a/t/fixtures/sample.plan b/t/fixtures/sample.plan new file mode 100644 index 0000000..ba7fcaa --- /dev/null +++ b/t/fixtures/sample.plan @@ -0,0 +1,6 @@ +signin +auth +bind-reneg +bind +session +signout diff --git a/t/fixtures/testplan b/t/fixtures/testplan deleted file mode 100644 index ba7fcaa..0000000 --- a/t/fixtures/testplan +++ /dev/null @@ -1,6 +0,0 @@ -signin -auth -bind-reneg -bind -session -signout diff --git a/t/samplerun.t b/t/samplerun.t index 4df0d7d..d9dba31 100644 --- a/t/samplerun.t +++ b/t/samplerun.t @@ -7,12 +7,12 @@ use IO::File; use strict; use warnings; -my $config = 't/fixtures/localhost.conf'; -my $testplan = 't/fixtures/testplan'; -my $input = 't/fixtures/input'; +my $env = 't/fixtures/sample.env'; +my $testplan = 't/fixtures/sample.plan'; +my $input = 't/fixtures/sample.input'; do { - my $cmd = "./xmpt -c $config -p $testplan"; + my $cmd = "./xmpt -e $env -p $testplan"; my $xmptfh = new IO::File("|$cmd") or BAIL_OUT "Can't run '$cmd': $!.\n"; my $inputfh = new IO::File($input) or BAIL_OUT "Couldn't open $input for reading: $!.\n"; @@ -25,7 +25,7 @@ do { }; do { - my $cmd = "./xmpt -t 1 -c $config -p $testplan cat 2>/dev/null"; + my $cmd = "./xmpt -t 1 -e $env -p $testplan cat 2>/dev/null"; local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; alarm 5; system $cmd; @@ -33,7 +33,7 @@ do { }; do { - my $cmd = "./xmpt -c $config -p $testplan cat $input 2>/dev/null"; + my $cmd = "./xmpt -e $env -p $testplan cat $input 2>/dev/null"; local $SIG{ALRM} = sub { fail("Timed out running $cmd.") }; alarm 10; ok((system($cmd) >> 8) == 0, 'I/O redirected to cat'); diff --git a/xmpt b/xmpt index c1d0dbe..0b40688 100755 --- a/xmpt +++ b/xmpt @@ -13,7 +13,7 @@ use warnings; our $VERSION = '0'; my $verbose; -my $configpath = 'localhost.conf'; +my $envpath = 'localhost.env'; my $timeout = 5; my $testplanpath = 'testplan'; my $templatepath = 'xml'; @@ -21,7 +21,7 @@ my @libs; my $help; GetOptions('verbose|v' => \$verbose, - 'config|c=s' => \$configpath, + 'env|e=s' => \$envpath, 'timeout|t=i' => \$timeout, 'testplan|p=s' => \$testplanpath, 'templates|d=s' => \$templatepath, @@ -31,7 +31,7 @@ usage(0) if $help; $| = 1; -my %conf = read_conf($configpath); +local %evalpkg::env = read_env($envpath); my @plans = load_plans($testplanpath, $templatepath); # Ignore SIGPIPE at the top level, since it only matters when reading @@ -47,16 +47,16 @@ if (@ARGV) { binmode($inh, ':utf8'); binmode($outh, ':utf8'); -eval_in($inh, $outh, \%conf, @plans); +eval_in($inh, $outh, @plans); waitpid($pid, 0) if $pid; # TODO: swap over to Pod::Usage. sub usage { - print STDERR "Usage: $0 [-hv] [-c config] [-t seconds] [-p testplan] [-d templatedir] [-l libpath] [command]\n"; + print STDERR "Usage: $0 [-hv] [-e envpath] [-t seconds] [-p testplan] [-d templatedir] [-l libpath] [command]\n"; exit shift; } -sub read_conf { +sub read_env { my ($filen) = @_; my $fh = new IO::File("<$filen") || @@ -152,14 +152,13 @@ sub thunk { local $evalpkg::arg = shift; my $rc = eval $b; $@ && - die "Error in $fn:$line: $@\ttestplan: $testplanpath\n\tconfig: $configpath\n"; + die "Error in $fn:$line: $@\ttestplan: $testplanpath\n\tenvpath: $envpath\n"; $rc; }] } sub eval_in { local ($evalpkg::in, $evalpkg::out) = (shift, shift); - local %evalpkg::env = %{shift @_}; my @plans = @_; foreach my $k (keys %evalpkg::env) { -- cgit v1.2.3