diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-09 10:49:07 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-09 11:56:05 +0100 |
commit | 3f29eef5b0efc778c38ec0d564af573db345f38f (patch) | |
tree | 9b82534d8c75e20dc456cc611bfab6824205882c | |
parent | effc84d3731b1c7e78d08bc2d039e075c937ff70 (diff) |
Generate unique config per test run.
This allows multiple test suites to run simultaneously (beforehand, a
second run would overwrite the same config file and lose its database
connection).
Clean up the created config file on exit.
-rw-r--r-- | conf/.gitignore | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestAppProve.pm | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/conf/.gitignore b/conf/.gitignore index 6e77101a1..86ecc7e03 100644 --- a/conf/.gitignore +++ b/conf/.gitignore @@ -1,6 +1,6 @@ /general.yml /general.yml.deployed -/general.test-autogenerated.yml +/general.test-autogenerated*.yml /httpd.conf /httpd.conf.deployed /crontab diff --git a/perllib/FixMyStreet/TestAppProve.pm b/perllib/FixMyStreet/TestAppProve.pm index 75e9fe0a4..f2584fc33 100644 --- a/perllib/FixMyStreet/TestAppProve.pm +++ b/perllib/FixMyStreet/TestAppProve.pm @@ -2,6 +2,8 @@ use strict; use warnings; package FixMyStreet::TestAppProve; use App::Prove; +use sigtrap qw(handler signal_handler normal-signals); + use YAML (); use Path::Tiny 'path'; use Test::PostgreSQL; @@ -18,6 +20,19 @@ see bin/run-tests for usage =cut +sub cleanup { + unlink "conf/general.test-autogenerated.$$.yml"; +} + +sub signal_handler { + cleanup(); + exit(0); +} + +END { + cleanup(); +} + sub run { my ($class, @args) = @_; local @ARGV = @args; @@ -71,7 +86,7 @@ sub run { $config->{FMS_DB_PASS} = ''; } - my $config_out = 'general.test-autogenerated'; + my $config_out = "general.test-autogenerated.$$"; path("conf/$config_out.yml")->spew( YAML::Dump($config) ); local $ENV{FMS_OVERRIDE_CONFIG} = $config_out; |