aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-08-09 10:49:07 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-08-09 11:56:05 +0100
commit3f29eef5b0efc778c38ec0d564af573db345f38f (patch)
tree9b82534d8c75e20dc456cc611bfab6824205882c /perllib/FixMyStreet
parenteffc84d3731b1c7e78d08bc2d039e075c937ff70 (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.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/TestAppProve.pm17
1 files changed, 16 insertions, 1 deletions
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;