citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

report.t (1857B)


      1 #
      2 # Verify behaviour of citrun_report script. There's a few cases here.
      3 #
      4 use Modern::Perl;
      5 use Test::Cmd;
      6 use Test::More tests => 12;
      7 #plan skip_all => 'citrun_report missing on win32' if ($^O eq "MSWin32");
      8 
      9 
     10 my $report = Test::Cmd->new( prog => 'bin/citrun_report', workdir => '' );
     11 
     12 #
     13 # Test when a nonexistent file argument is given.
     14 #
     15 my $e = "awk: can't open file _nonexistent_";
     16 $report->run( args => '_nonexistent_', chdir => $report->curdir );
     17 
     18 is( $report->stdout,	'',	'nonexistent file stdout silent' );
     19 like( $report->stderr,	qr/$e/, 'nonexistent file stderr identical' );
     20 is( $? >> 8,		2,	'nonexistent file exit code nonzero' );
     21 
     22 #
     23 # Verify output when an empty file is processed.
     24 #
     25 my $o = "No signs of rewrite activity.";
     26 $report->write( 'empty_file.log', '' );
     27 $report->run( args => 'empty_file.log', chdir => $report->curdir );
     28 
     29 like( $report->stdout,	qr/$o/,	'empty file stdout expected' );
     30 is( $report->stderr,	'',	'empty file stderr silent' );
     31 is( $? >> 8,		1,	'empty file exit code nonzero' );
     32 
     33 #
     34 # Test when an existent file only has a header line.
     35 #
     36 $o = 'Summary:
     37          1 Rewrite tool runs';
     38 $report->write( 'header_only.log', '>> citrun_inst');
     39 $report->run( args => 'header_only.log', chdir => $report->curdir );
     40 
     41 like( $report->stdout,	qr/$o/, 'header only stdout expected' );
     42 is( $report->stderr,	'',	'header only stderr silent' );
     43 is( $? >> 8,		0,	'header only exit code zero' );
     44 
     45 #
     46 # Test a log file path with spaces.
     47 #
     48 $o = "No signs of rewrite activity.";
     49 
     50 mkdir File::Spec->catdir( $report->workdir, 'dir a' );
     51 $report->write( [ 'dir a', 'citrun.log' ], '' );
     52 
     53 $report->run( args => 'dir\ a/citrun.log', chdir => $report->curdir );
     54 like( $report->stdout,	qr/$o/, 'path with spaces stdout identical' );
     55 is( $report->stderr,	'',	'path with spaces stderr silent' );
     56 is( $? >> 8,		1,	'path with spaces exit code nonzero' );