inst_srcext.t (1537B)
1 # 2 # Check that the advertised source file extensions work. 3 # 4 use Modern::Perl; 5 use Test::Cmd; 6 use Test::Differences; 7 use Test::More tests => 15; 8 9 use lib 't'; 10 require utils; 11 12 13 my @supported_exts = ("c", "cc", "cxx", "cpp"); 14 15 my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' ); 16 17 my $out_good = <<EOF; 18 >> citrun_inst 19 Compilers path = '' 20 Found source file '' 21 Command line is '' 22 Added clangtool argument '' 23 Instrumentation of '' finished: 24 1 Lines of source code 25 1 Function definitions 26 1 Return statement values 27 3 Total statements 28 Modified source written successfully. 29 EOF 30 31 for (@supported_exts) { 32 $inst->write( "main.$_", 'int main(void) { return 0; }' ); 33 $inst->run( args => "-c main.$_", chdir => $inst->curdir ); 34 35 my $out = utils::clean_citrun_log(scalar $inst->stdout); 36 eq_or_diff( $out, $out_good, ".$_ citrun_inst output identical", 37 { context => 3} ); 38 is ( $inst->stderr, '', ".$_ citrun_inst stderr silent" ); 39 is( $? >> 8, 0, ".$_ citrun_inst exit code 0" ); 40 } 41 42 $out_good = <<EOF; 43 >> citrun_inst 44 Compilers path = '' 45 Command line is '' 46 No source files found on command line. 47 Running as citrun_inst, not calling exec() 48 EOF 49 50 $inst->write( "main.z", 'int main(void) { return 0; }' ); 51 $inst->run( args => "-c main.z", chdir => $inst->curdir ); 52 53 my $out = utils::clean_citrun_log(scalar $inst->stdout); 54 eq_or_diff( $out, $out_good, ".z citrun_inst output identical", 55 { context => 3 } ); 56 is ( $inst->stderr, '', ".z citrun_inst stderr silent" ); 57 is( $? >> 8, 0, ".z citrun_inst exit code 1" );