citrun

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

inst_logeol.t (864B)


      1 #
      2 # Check that proper platform specific line endings exist in citrun.log.
      3 #
      4 use Modern::Perl;
      5 use Test::Cmd;
      6 use Test::More tests => 1;
      7 
      8 use lib 't';
      9 require utils;
     10 
     11 
     12 my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
     13 
     14 $wrap->write( 'main.c', <<EOF );
     15 EOF
     16 
     17 $wrap->run( args => utils::os_compiler() . 'main main.c',
     18 	chdir => $wrap->curdir );
     19 
     20 # Read log file in binary mode so \r\n's don't get converted by the IO layer.
     21 open( my $fh, '<', File::Spec->catfile( $wrap->workdir, 'citrun.log' ) );
     22 binmode( $fh );
     23 read $fh, my $citrun_log, 64 * 1024;
     24 
     25 # Check line endings.
     26 if ($^O eq 'MSWin32') {
     27 	# Windows has extra lines because exec() is emulated by fork().
     28 
     29 	my $rn_count = () = $citrun_log =~ /\r\n/g;
     30 	is( $rn_count,	15,	'\r\n count correct' );
     31 }
     32 else {
     33 	my $n_count = () = $citrun_log =~ /\n/g;
     34 	is( $n_count,	14,	'\n count correct' );
     35 }