citrun

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

inst_fail.t (897B)


      1 #
      2 # Check that a program that won't compile natively is handled properly.
      3 #
      4 use Modern::Perl;
      5 use Test::Cmd;
      6 use Test::Differences;
      7 use Test::More tests => 2;
      8 
      9 use lib 't';
     10 require utils;
     11 
     12 my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
     13 
     14 $inst->write( 'bad.c', <<EOF );
     15 int
     16 main(void)
     17 {
     18 	return 0;
     19 EOF
     20 
     21 my $out_good = <<EOF;
     22 >> citrun_inst
     23 Compilers path = ''
     24 Found source file ''
     25 Command line is ''
     26 Added clangtool argument ''
     27 Instrumentation of '' finished:
     28     5 Lines of source code
     29     1 Function definitions
     30     1 Return statement values
     31     3 Total statements
     32 Modified source written successfully.
     33 EOF
     34 
     35 $inst->run( args => '-c bad.c', chdir => $inst->curdir );
     36 
     37 my $out = utils::clean_citrun_log(scalar $inst->stdout);
     38 eq_or_diff( $out, $out_good, 'citrun_inst output identical', { context => 3} );
     39 
     40 print $inst->stderr;
     41 is( $? >> 8,	0,	'citrun_inst exit code 0' );