@@ -25,6 +25,7 @@ use warnings;
2525no warnings qw( redefine ) ;
2626
2727use Exporter;
28+ use Capture::Tiny ' tee_stderr' ;
2829use Carp qw{ croak} ;
2930use File::Spec;
3031use File::Temp qw{ tempfile} ;
@@ -168,6 +169,8 @@ sub standaloneJob {
168169 Arg[4] : (optional) Arrayref $tweaks. Tweaks to be applied to the database (as with the -tweak command-line option)
169170 Arg[5] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
170171 key that is understood is "expect_failure" to reverse the expectation of the test.
172+ It is primarily used as a boolean, but can be a regular expression to test the standard
173+ error of the script.
171174 Example : init_pipeline(
172175 'Bio::EnsEMBL::Hive::Examples::LongMult::PipeConfig::LongMultServer_conf',
173176 $server_url,
@@ -218,6 +221,8 @@ sub init_pipeline {
218221 Arg[4] : String $test_name (optional). The name of the test
219222 Arg[5] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
220223 key that is understood is "expect_failure" to reverse the expectation of the test.
224+ It is primarily used as a boolean, but can be a regular expression to test the standard
225+ error of the script.
221226 Description : Generic method that can run any eHive script and check its return status
222227 Returntype : None
223228 Exceptions : TAP-style
@@ -232,10 +237,16 @@ sub _test_ehive_script {
232237 $flags ||= {};
233238 my @ext_args = ( defined ($url ) ? (-url => $url ) : (), @$args );
234239
235- my $rc = system ($ENV {' EHIVE_ROOT_DIR' }.' /scripts/' .$script_name .' .pl' , @ext_args );
240+ my $rc ;
241+ my $stderr = tee_stderr {
242+ $rc = system ($ENV {' EHIVE_ROOT_DIR' }.' /scripts/' .$script_name .' .pl' , @ext_args );
243+ };
236244 if ($flags -> {expect_failure }) {
237245 $test_name ||= $script_name .' fails' .(@ext_args ? ' with the command-line options: ' .join (' ' , @ext_args ) : ' ' );
238246 ok($rc , $test_name );
247+ if (re::is_regexp($flags -> {expect_failure })) {
248+ like($stderr , $flags -> {expect_failure }, ' error message as expected' );
249+ }
239250 } else {
240251 $test_name ||= ' Can run ' .$script_name .(@ext_args ? ' with the command-line options: ' .join (' ' , @ext_args ) : ' ' );
241252 is($rc , 0, $test_name );
@@ -250,6 +261,8 @@ sub _test_ehive_script {
250261 Arg[3] : String $test_name (optional). The name of the test
251262 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
252263 key that is understood is "expect_failure" to reverse the expectation of the test.
264+ It is primarily used as a boolean, but can be a regular expression to test the standard
265+ error of the script.
253266 Example : runWorker($url, [ -can_respecialize => 1 ]);
254267 Description : Run a worker on the given pipeline in the current process.
255268 The worker options have been divided in three groups: the ones affecting its specialization,
@@ -284,6 +297,8 @@ sub runWorker {
284297 Arg[3] : String $test_name (optional). The name of the test
285298 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
286299 key that is understood is "expect_failure" to reverse the expectation of the test.
300+ It is primarily used as a boolean, but can be a regular expression to test the standard
301+ error of the script.
287302 Example : $seed_pipeline($url, [$arg1, $arg2], 'Run seed_pipeline with two arguments');
288303 Description : Very generic function to run seed_pipeline on the given database with the given arguments
289304 Returntype : None
@@ -306,6 +321,8 @@ sub seed_pipeline {
306321 Arg[3] : String $test_name (optional). The name of the test
307322 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
308323 key that is understood is "expect_failure" to reverse the expectation of the test.
324+ It is primarily used as a boolean, but can be a regular expression to test the standard
325+ error of the script.
309326 Example : beekeeper($url, [$arg1, $arg2], 'Run beekeeper with two arguments');
310327 Description : Very generic function to run beekeeper on the given database with the given arguments
311328 Returntype : None
@@ -345,6 +362,8 @@ sub tweak_pipeline {
345362 Arg[3] : String $test_name (optional). The name of the test
346363 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
347364 key that is understood is "expect_failure" to reverse the expectation of the test.
365+ It is primarily used as a boolean, but can be a regular expression to test the standard
366+ error of the script.
348367 Example : generate_graph($url, [-output => 'lm_analyses.png'], 'Generate a PNG A-diagram');
349368 Description : Very generic function to run generate_graph.pl on the given database with the given arguments
350369 Returntype : None
@@ -366,6 +385,8 @@ sub generate_graph {
366385 Arg[3] : String $test_name (optional). The name of the test
367386 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
368387 key that is understood is "expect_failure" to reverse the expectation of the test.
388+ It is primarily used as a boolean, but can be a regular expression to test the standard
389+ error of the script.
369390 Example : visualize_jobs($url, [-output => 'lm_jobs.png', -accu_values], 'Generate a PNG J-diagram with accu values');
370391 Description : Very generic function to run visualize_jobs.pl on the given database with the given arguments
371392 Returntype : None
@@ -405,6 +426,8 @@ sub peekJob {
405426 Arg[3] : String $test_name (optional). The name of the test
406427 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
407428 key that is understood is "expect_failure" to reverse the expectation of the test.
429+ It is primarily used as a boolean, but can be a regular expression to test the standard
430+ error of the script.
408431 Example : db_cmd($url, [-sql => 'DROP DATABASE'], 'Drop the database');
409432 Description : Very generic function to run db_cmd.pl on the given database with the given arguments
410433 Returntype : None
@@ -426,6 +449,8 @@ sub db_cmd {
426449 Arg[3] : String $test_name (optional). The name of the test
427450 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
428451 key that is understood is "expect_failure" to reverse the expectation of the test.
452+ It is primarily used as a boolean, but can be a regular expression to test the standard
453+ error of the script.
429454 Example : run_sql_on_db($url, 'INSERT INTO sweets (name, quantity) VALUES (3, 'Snickers')');
430455 Description : Execute an SQL command on the given database and test its execution. This expects the
431456 command-line client to return a non-zero code in case of a failure.
0 commit comments