diff --git a/modules/Bio/EnsEMBL/Hive/Utils/Test.pm b/modules/Bio/EnsEMBL/Hive/Utils/Test.pm index 7d014b347..fbfb772c5 100644 --- a/modules/Bio/EnsEMBL/Hive/Utils/Test.pm +++ b/modules/Bio/EnsEMBL/Hive/Utils/Test.pm @@ -199,20 +199,11 @@ sub init_pipeline { $url = (splice(@$options, $url_flag_index, 2))[1]; } - local @ARGV = @$options; - unshift @ARGV, (-pipeline_url => $url, -hive_force_init => 1); - - lives_ok(sub { - my $orig_unambig_url = Bio::EnsEMBL::Hive::Utils::URL::parse($url)->{'unambig_url'}; - ok($orig_unambig_url, 'Given URL could be parsed'); - my $returned_url = Bio::EnsEMBL::Hive::Scripts::InitPipeline::init_pipeline($file_or_module, $tweaks); - ok($returned_url, 'pipeline initialized on '.$returned_url); - - my $returned_unambig_url = Bio::EnsEMBL::Hive::Utils::URL::parse($returned_url)->{'unambig_url'}; - # Both $url and $returned_url MAY contain the password (if applicable for the driver) but can be missing the port number assuming a default - # Both $orig_unambig_url and $returned_unambig_url SHOULD contain the port number (if applicable for the driver) but WILL NOT contain a password - is($returned_unambig_url, $orig_unambig_url, 'pipeline initialized on '.$url); - }, sprintf('init_pipeline("%s", %s)', $file_or_module, stringify($options))); + my @args = ($file_or_module, -pipeline_url => $url, -hive_force_init => 1); + push @args, @$options; + push @args, map {-tweak => $_} @$tweaks if $tweaks; + + return _test_ehive_script('init_pipeline', undef, \@args); } diff --git a/t/02.api/fetch_and_count_by_multiple_columns.t b/t/02.api/fetch_and_count_by_multiple_columns.t index b4da6290a..18d3bb3e7 100755 --- a/t/02.api/fetch_and_count_by_multiple_columns.t +++ b/t/02.api/fetch_and_count_by_multiple_columns.t @@ -37,7 +37,7 @@ my $ehive_test_pipeline_urls = get_test_urls(); foreach my $pipeline_url (@$ehive_test_pipeline_urls) { subtest 'Test on '.$pipeline_url, sub { - plan tests => 20; + plan tests => 17; init_pipeline('Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMult_conf', $pipeline_url); diff --git a/t/03.scripts/generate_graph.t b/t/03.scripts/generate_graph.t index 3a277fba5..07c7bdf7d 100755 --- a/t/03.scripts/generate_graph.t +++ b/t/03.scripts/generate_graph.t @@ -39,10 +39,14 @@ GetOptions( my $server_url = get_test_url_or_die(-tag => 'server', -no_user_prefix => 1); -# Most of the test scripts test init_pipeline() from Utils::Test but we -# also need to test the main scripts/init_pipeline.pl ! -my @init_pipeline_args = ($ENV{'EHIVE_ROOT_DIR'}.'/scripts/init_pipeline.pl', 'Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMultServer_conf', -pipeline_url => $server_url, -hive_force_init => 1, -tweak => 'pipeline.param[take_time]=0'); -test_command(\@init_pipeline_args); +init_pipeline( + 'Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMultServer_conf', + $server_url, + [], + [ + 'pipeline.param[take_time]=0', + ], +); my $client_url = get_test_url_or_die(-tag => 'client', -no_user_prefix => 1); @@ -59,12 +63,6 @@ push @confs_to_test, 'GC::PipeConfig::GCPct_conf' unless $@; # SKIP it in cas my ($fh, $tmp_filename) = tempfile(UNLINK => 1); close($fh); -sub test_command { - my $cmd_array = shift; - ok(!system(@$cmd_array), 'Can run '.join(' ', @$cmd_array)); -} - - foreach my $conf (@confs_to_test) { subtest $conf, sub { my $module_name = 'Bio::EnsEMBL::Hive::Examples::'.$conf; diff --git a/t/10.pipeconfig/analysis_heir.t b/t/10.pipeconfig/analysis_heir.t index 7e516c024..79ab9c190 100755 --- a/t/10.pipeconfig/analysis_heir.t +++ b/t/10.pipeconfig/analysis_heir.t @@ -32,8 +32,7 @@ $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Fil my $pipeline_url = get_test_url_or_die(); my $init_stderr = capture_stderr { - local @INC = @INC; - push @INC, $ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/'; + local $ENV{'PERL5LIB'} = $ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/::'.$ENV{PERL5LIB}; init_pipeline( 'TestPipeConfig::MissingAnalysis_conf', $pipeline_url, diff --git a/t/10.pipeconfig/gc_dataflow.t b/t/10.pipeconfig/gc_dataflow.t index bf7d5cbb7..5d40e8051 100755 --- a/t/10.pipeconfig/gc_dataflow.t +++ b/t/10.pipeconfig/gc_dataflow.t @@ -30,8 +30,7 @@ $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Fil my $pipeline_url = get_test_url_or_die(); { - local @INC = @INC; - push @INC, $ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/'; + local $ENV{'PERL5LIB'} = $ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/::'.$ENV{PERL5LIB}; init_pipeline('TestPipeConfig::AnyFailureBranch_conf', $pipeline_url, [], ['pipeline.param[take_time]=100']); } my $hive_dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new( -url => $pipeline_url ); diff --git a/t/10.pipeconfig/pipeline_url.t b/t/10.pipeconfig/pipeline_url.t index 46a4d0683..4dc4032af 100755 --- a/t/10.pipeconfig/pipeline_url.t +++ b/t/10.pipeconfig/pipeline_url.t @@ -21,7 +21,7 @@ use warnings; use Test::More; -use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline beekeeper get_test_url_or_die safe_drop_database); +use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline get_test_url_or_die safe_drop_database); use Bio::EnsEMBL::Hive::Utils qw(destringify); # eHive needs this to initialize the pipeline (and run db_cmd.pl) @@ -29,11 +29,10 @@ $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Fil my $pipeline_url = get_test_url_or_die(); -# Utils::Test::init_pipeline runs things internally instead of invoking init_pipeline.pl -# Here we need to run the script to trigger the password sanitization -my @cmd = ('env', 'PERL5LIB='.$ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/::'.$ENV{PERL5LIB}, $ENV{'EHIVE_ROOT_DIR'}.'/scripts/init_pipeline.pl', 'TestPipeConfig::PipelineURL_conf', -pipeline_url => $pipeline_url); -my $rc = system(@cmd); -is($rc, 0, 'init_pipeline.pl successfully ran'); +{ + local $ENV{'PERL5LIB'} = $ENV{'EHIVE_ROOT_DIR'}.'/t/10.pipeconfig/::'.$ENV{PERL5LIB}; + init_pipeline('TestPipeConfig::PipelineURL_conf', $pipeline_url); +} my $hive_dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new( -url => $pipeline_url );