From 13af733e3f3f26ce7cee8d1f2154f82c93f4c3c3 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 10 Oct 2015 14:32:29 +0100 Subject: [PATCH] Do not crash in t/tools.t if postgres is not running --- lib/Gruntmaster/App.pm | 5 ++++- t/tools.t | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Gruntmaster/App.pm b/lib/Gruntmaster/App.pm index c867f70..28c80e2 100644 --- a/lib/Gruntmaster/App.pm +++ b/lib/Gruntmaster/App.pm @@ -21,7 +21,10 @@ sub global_opt_spec { sub table { shift->global_options->{table} } -dbinit $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; +sub run { + dbinit $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; + shift->SUPER::run(@_); +} 1; __END__ diff --git a/t/tools.t b/t/tools.t index 59ed755..6a08457 100644 --- a/t/tools.t +++ b/t/tools.t @@ -10,6 +10,8 @@ BEGIN { eval { dbinit 'dbi:Pg:dbname=gmtest'; 1; } or plan skip_all => 'Cannot connect to test database. Create it by running make_test_db.sh before running this test. '. "Error: $@"; + no warnings 'redefine'; + *Gruntmaster::App::dbinit = sub {}; # Prevent reinit in Gruntmaster::App->run plan tests => 30; } -- 2.30.2