Subject: | not working inside Test::Class |
Greetings,
I've being trying to use stdout_like function without success while inside a subclass of Test::Class. I'm not sure if this a problem with Test::Class or Test::Output, but the fact is that I can use Test::Output stdout_like if I'm outside of Test::Class.
I attached two different tests for you to try to reproduce the following errors:
prove -I ~/Projetos/siebel-monitoring-tools/Siebel-Srvrmgr/lib t/ActionDumperFunctionRef.t
t/ActionDumperFunctionRef.t .. 1/21
# Failed test 'class_methods died (Undefined subroutine &Test::Action::DumperFunctionRef::stdout_like called at t/Test/Action/DumperFunctionRef.pm line 15.)'
# at t/ActionDumperFunctionRef.t line 4.
# (in Test::Action::DumperFunctionRef->class_methods)
# Looks like you failed 1 test of 21.
t/ActionDumperFunctionRef.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/21 subtests
Test Summary Report
-------------------
t/ActionDumperFunctionRef.t (Wstat: 256 Tests: 21 Failed: 1)
Failed test: 11
Non-zero exit status: 1
Files=1, Tests=21, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.50 cusr 0.02 csys = 0.55 CPU)
Result: FAIL
And also using a anonymous block:
prove -I ~/Projetos/siebel-monitoring-tools/Siebel-Srvrmgr/lib t/ActionDumperBlock.t
t/ActionDumperBlock.t .. 1/33
# Failed test 'class_methods died (Can't call method "stdout_like" without a package or object reference at t/Test/Action/DumperBlock.pm line 18.)'
# at t/ActionDumperBlock.t line 4.
# (in Test::Action::DumperBlock->class_methods)
# Looks like you failed 1 test of 33.
t/ActionDumperBlock.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/33 subtests
Test Summary Report
-------------------
t/ActionDumperBlock.t (Wstat: 256 Tests: 33 Failed: 1)
Failed test: 33
Non-zero exit status: 1
Files=1, Tests=33, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.36 cusr 0.01 csys = 0.39 CPU)
Result: FAIL
You will need to fetch the most recent code from the SVN repository of Siebel-Srvrmgr for testing those two cases:
https://code.google.com/p/siebel-monitoring-tools/source/browse/#svn%2Ftrunk%2FSiebel-Srvrmgr
Please copy the *.t and *.pm files in the appropriate directories under the t/ directory of the distribution.
I was able to provide a workaround with the ActionDumper.pm class available in the SVN repository.
Below follows my test environment information:
Summary of my perl5 (revision 5 version 16 subversion 3) configuration:
Platform:
osname=linux, osvers=3.8.0-23-generic, archname=x86_64-linux
uname='linux yggdrasil 3.8.0-23-generic #34-ubuntu smp wed may 29 20:22:58 utc 2013 x86_64 x86_64 x86_64 gnulinux '
config_args='-de -Dprefix=/home/jackal/perl5/perlbrew/perls/perl-5.16.3 -Aeval:scriptdir=/home/jackal/perl5/perlbrew/perls/perl-5.16.3/bin'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.7.3', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.17'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
Built under linux
Compiled at Jun 3 2013 03:03:17
%ENV:
PERL5LIB="/home/jackal/Projetos/siebel-monitoring-tools/lib:/home/jackal/Projetos/siebel-code-analyzer/testing:/usr/lib/cgi-bin"
PERLBREW_MANPATH="/home/jackal/perl5/perlbrew/perls/perl-5.16.3/man"
PERLBREW_PATH="/home/jackal/perl5/perlbrew/bin:/home/jackal/perl5/perlbrew/perls/perl-5.16.3/bin"
PERLBREW_PERL="perl-5.16.3"
PERLBREW_ROOT="/home/jackal/perl5/perlbrew"
PERLBREW_SKIP_INIT="1"
PERLBREW_VERSION="0.63"
@INC:
/home/jackal/Projetos/siebel-monitoring-tools/lib
/home/jackal/Projetos/siebel-code-analyzer/testing
/usr/lib/cgi-bin
/home/jackal/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux
/home/jackal/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3
/home/jackal/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3/x86_64-linux
/home/jackal/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3
.
Please let me know if you need additional information or help with the tests.
Regards,
Alceu
Subject: | ActionDumperBlock.t |
use lib 't';
use Test::Action::DumperBlock;
Test::Class->runtests;
Subject: | ActionDumperFunctionRef.t |
use lib 't';
use Test::Action::DumperFunctionRef;
Test::Class->runtests;
Subject: | DumperBlock.pm |
package Test::Action::DumperBlock;
use Test::Output qw(:stdout);
use base 'Test::Action';
use Test::More;
sub class { 'Siebel::Srvrmgr::Daemon::Action::Dumper' }
sub class_methods : Test(+1) {
my $test = shift;
$test->SUPER::class_methods();
my @data = <DATA>;
close(DATA);
stdout_like { $test->{action}->do( \@data ) }
qr/^\$VAR1\s\=\s\[\n\s+\'\n\'\,\n\s+\'SV_NAME\s+CC_ALIAS/,
'got correct dumped content';
}
1;
__DATA__
SV_NAME CC_ALIAS TK_TASKID TK_PID TK_DISP_RUNSTATE CC_RUNMODE TK_START_TIME TK_END_TIME TK_STATUS CG_ALIAS TK_PARENT_T CC_INCARN_NO TK_LABEL TK_TASKTYPE TK_PING_TIM
------- -------------- --------- ------ ---------------- ----------- ------------------- ------------------- --------------------------------------------------------------------------------------- --------- ----------- ------------ ------------------------ ----------- -----------
SUsrvr ServerMgr 32505858 916 Running Interactive 2012-02-13 08:14:36 2000-00-00 00:00:00 Processing "List Tasks" command System 0 Normal
SUsrvr TaskLogCleanup 31457282 3292 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 TaskUI 0 SADMIN Normal
SUsrvr TxnProc 29360130 3160 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 Cleaning routed .dx files... Remote 0 Normal
SUsrvr TxnRoute 28311554 3104 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 Iteration 1: Sleeping for 60 seconds... Remote 0 Normal
SUsrvr TxnMerge 25165826 2980 Running Background 2012-02-13 08:14:14 2000-00-00 00:00:00 Iteration 0: Sleeping for 40 seconds... Remote 0 Normal
SUsrvr SBRWorkMon 13631490 2776 Running Background 2012-02-13 08:14:13 2000-00-00 00:00:00 Sleeping for 50 seconds... Workflow 0 Normal
SUsrvr SBRWorkActn 9437186 2736 Running Background 2012-02-13 08:14:12 2000-00-00 00:00:00 Sleeping for 50 seconds... Workflow 0 Normal
SUsrvr SvrTblCleanup 8388610 2392 Running Background 2012-02-13 08:14:07 2000-00-00 00:00:00 Invoking method DelCompletedDelExpiredReq for service Message Board Maintenance Service SystemAux 0 SADMIN Normal
SUsrvr SvrTaskPersist 7340034 2448 Running Background 2012-02-13 08:14:07 2000-00-00 00:00:00 Invoking method InsertUpdateTaskHistory for service Message Board Maintenance Service SystemAux 0 SADMIN Normal
SUsrvr SRProc 5242888 2416 Running Interactive 2012-02-13 08:14:10 2000-00-00 00:00:00 SystemAux 0 Normal
SUsrvr SRProc 5242885 2416 Running Interactive 2012-02-13 08:14:09 2000-00-00 00:00:00 SystemAux 0 Forwarding Task Worker
SUsrvr SRBroker 3145755 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145754 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145753 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145752 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145751 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145750 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145749 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145748 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145747 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145746 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145745 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145744 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145743 2312 Running Interactive 2012-02-13 08:14:13 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145742 2312 Running Interactive 2012-02-13 08:14:13 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145740 2312 Running Interactive 2012-02-13 08:14:09 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145739 2312 Running Interactive 2012-02-13 08:14:08 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145738 2312 Running Interactive 2012-02-13 08:14:08 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145736 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Store task Worker
SUsrvr SRBroker 3145735 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Response task Worker
SUsrvr SRBroker 3145734 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Task creation task Worker
SUsrvr SRBroker 3145733 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Information caching task Worker
SUsrvr SCBroker 2097154 2324 Running Background 2012-02-13 08:13:56 2000-00-00 00:00:00 System 0 Normal
33 rows returned.
Subject: | DumperFunctionRef.pm |
package Test::Action::DumperFunctionRef;
#use Test::Output qw(:stdout);
use base 'Test::Action';
use Test::More;
sub class { 'Siebel::Srvrmgr::Daemon::Action::Dumper' }
sub class_methods : Test(+1) {
my $test = shift;
$test->SUPER::class_methods();
stdout_like( \&foobar($test), qr/^\$VAR1\s\=\s\[\n\s+\'\n\'\,\n\s+\'SV_NAME\s+CC_ALIAS/, 'got correct dumped content' );
}
sub foobar {
my $test = shift;
my @data = <DATA>;
close(DATA);
$test->{action}->do( \@data );
}
1;
__DATA__
SV_NAME CC_ALIAS TK_TASKID TK_PID TK_DISP_RUNSTATE CC_RUNMODE TK_START_TIME TK_END_TIME TK_STATUS CG_ALIAS TK_PARENT_T CC_INCARN_NO TK_LABEL TK_TASKTYPE TK_PING_TIM
------- -------------- --------- ------ ---------------- ----------- ------------------- ------------------- --------------------------------------------------------------------------------------- --------- ----------- ------------ ------------------------ ----------- -----------
SUsrvr ServerMgr 32505858 916 Running Interactive 2012-02-13 08:14:36 2000-00-00 00:00:00 Processing "List Tasks" command System 0 Normal
SUsrvr TaskLogCleanup 31457282 3292 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 TaskUI 0 SADMIN Normal
SUsrvr TxnProc 29360130 3160 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 Cleaning routed .dx files... Remote 0 Normal
SUsrvr TxnRoute 28311554 3104 Running Background 2012-02-13 08:14:15 2000-00-00 00:00:00 Iteration 1: Sleeping for 60 seconds... Remote 0 Normal
SUsrvr TxnMerge 25165826 2980 Running Background 2012-02-13 08:14:14 2000-00-00 00:00:00 Iteration 0: Sleeping for 40 seconds... Remote 0 Normal
SUsrvr SBRWorkMon 13631490 2776 Running Background 2012-02-13 08:14:13 2000-00-00 00:00:00 Sleeping for 50 seconds... Workflow 0 Normal
SUsrvr SBRWorkActn 9437186 2736 Running Background 2012-02-13 08:14:12 2000-00-00 00:00:00 Sleeping for 50 seconds... Workflow 0 Normal
SUsrvr SvrTblCleanup 8388610 2392 Running Background 2012-02-13 08:14:07 2000-00-00 00:00:00 Invoking method DelCompletedDelExpiredReq for service Message Board Maintenance Service SystemAux 0 SADMIN Normal
SUsrvr SvrTaskPersist 7340034 2448 Running Background 2012-02-13 08:14:07 2000-00-00 00:00:00 Invoking method InsertUpdateTaskHistory for service Message Board Maintenance Service SystemAux 0 SADMIN Normal
SUsrvr SRProc 5242888 2416 Running Interactive 2012-02-13 08:14:10 2000-00-00 00:00:00 SystemAux 0 Normal
SUsrvr SRProc 5242885 2416 Running Interactive 2012-02-13 08:14:09 2000-00-00 00:00:00 SystemAux 0 Forwarding Task Worker
SUsrvr SRBroker 3145755 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145754 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145753 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145752 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145751 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145750 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145749 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145748 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145747 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145746 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145745 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145744 2312 Running Interactive 2012-02-13 08:14:15 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145743 2312 Running Interactive 2012-02-13 08:14:13 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145742 2312 Running Interactive 2012-02-13 08:14:13 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145740 2312 Running Interactive 2012-02-13 08:14:09 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145739 2312 Running Interactive 2012-02-13 08:14:08 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145738 2312 Running Interactive 2012-02-13 08:14:08 2000-00-00 00:00:00 System 0 Normal
SUsrvr SRBroker 3145736 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Store task Worker
SUsrvr SRBroker 3145735 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Response task Worker
SUsrvr SRBroker 3145734 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Task creation task Worker
SUsrvr SRBroker 3145733 2312 Running Interactive 2012-02-13 08:14:02 2000-00-00 00:00:00 System 0 Information caching task Worker
SUsrvr SCBroker 2097154 2324 Running Background 2012-02-13 08:13:56 2000-00-00 00:00:00 System 0 Normal
33 rows returned.