@@ -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
@@ -326,6 +343,8 @@ sub beekeeper {
326343 Arg[3] : String $test_name (optional). The name of the test
327344 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
328345 key that is understood is "expect_failure" to reverse the expectation of the test.
346+ It is primarily used as a boolean, but can be a regular expression to test the standard
347+ error of the script.
329348 Example : tweak_pipeline($url, [$arg1, $arg2], 'Run tweak_pipeline with two arguments');
330349 Description : Very generic function to run tweak_pipeline on the given database with the given arguments
331350 Returntype : None
@@ -347,6 +366,8 @@ sub tweak_pipeline {
347366 Arg[3] : String $test_name (optional). The name of the test
348367 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
349368 key that is understood is "expect_failure" to reverse the expectation of the test.
369+ It is primarily used as a boolean, but can be a regular expression to test the standard
370+ error of the script.
350371 Example : generate_graph($url, [-output => 'lm_analyses.png'], 'Generate a PNG A-diagram');
351372 Description : Very generic function to run generate_graph.pl on the given database with the given arguments
352373 Returntype : None
@@ -368,6 +389,8 @@ sub generate_graph {
368389 Arg[3] : String $test_name (optional). The name of the test
369390 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
370391 key that is understood is "expect_failure" to reverse the expectation of the test.
392+ It is primarily used as a boolean, but can be a regular expression to test the standard
393+ error of the script.
371394 Example : visualize_jobs($url, [-output => 'lm_jobs.png', -accu_values], 'Generate a PNG J-diagram with accu values');
372395 Description : Very generic function to run visualize_jobs.pl on the given database with the given arguments
373396 Returntype : None
@@ -388,6 +411,8 @@ sub visualize_jobs {
388411 Arg[3] : String $test_name (optional). The name of the test
389412 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
390413 key that is understood is "expect_failure" to reverse the expectation of the test.
414+ It is primarily used as a boolean, but can be a regular expression to test the standard
415+ error of the script.
391416 Example : peekJob($url, [-job_id => 1], 'Check params for job 1');
392417 Description : Very generic function to run peekJob.pl on the given database with the given arguments
393418 Returntype : None
@@ -409,6 +434,8 @@ sub peekJob {
409434 Arg[3] : String $test_name (optional). The name of the test
410435 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
411436 key that is understood is "expect_failure" to reverse the expectation of the test.
437+ It is primarily used as a boolean, but can be a regular expression to test the standard
438+ error of the script.
412439 Example : db_cmd($url, [-sql => 'DROP DATABASE'], 'Drop the database');
413440 Description : Very generic function to run db_cmd.pl on the given database with the given arguments
414441 Returntype : None
@@ -430,6 +457,8 @@ sub db_cmd {
430457 Arg[3] : String $test_name (optional). The name of the test
431458 Arg[4] : (optional) Hashref $flags. Flags given to the text framework. Currently the only
432459 key that is understood is "expect_failure" to reverse the expectation of the test.
460+ It is primarily used as a boolean, but can be a regular expression to test the standard
461+ error of the script.
433462 Example : run_sql_on_db($url, 'INSERT INTO sweets (name, quantity) VALUES (3, 'Snickers')');
434463 Description : Execute an SQL command on the given database and test its execution. This expects the
435464 command-line client to return a non-zero code in case of a failure.
0 commit comments