citrun

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

commit 36d4fa975c850e31c85b922a819ac75fa9ce5198
parent 4fe9d4ae5d525eb7167ea93ce414d292c76195e6
Author: Kyle Milz <kyle@0x30.net>
Date:   Wed, 11 Jan 2017 00:21:54 -0700

t: fold inst_log_eol into inst_log

Diffstat:
Minst_frontend.cc | 4++--
Mt/inst_log.t | 24++++++++++++++++--------
Dt/inst_log_eol.t | 37-------------------------------------
3 files changed, 18 insertions(+), 47 deletions(-)

diff --git a/inst_frontend.cc b/inst_frontend.cc @@ -83,7 +83,7 @@ InstFrontend::InstFrontend(int argc, char *argv[], bool is_citrun_inst) : m_lib_path.append("libcitrun.a"); #endif // _WIN32 - m_log << "CITRUN_COMPILERS = '" << m_compilers_path << "'" << std::endl; + m_log << "Compilers path = '" << m_compilers_path << "'" << std::endl; #ifndef _WIN32 // Sometimes we're not called as citrun_inst so force that here. @@ -126,7 +126,7 @@ InstFrontend::clean_PATH() exit(1); } - m_log << "PATH='" << path << "'" << std::endl; + m_log << "PATH = '" << path << "'" << std::endl; // Filter m_compilers_path out of PATH std::stringstream path_ss(path); diff --git a/t/inst_log.t b/t/inst_log.t @@ -5,7 +5,7 @@ use strict; use warnings; use t::utils; -plan tests => 3; +plan tests => 4; my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' ); @@ -39,8 +39,8 @@ $wrap->run( args => 'jam', chdir => $wrap->curdir ); my $citrun_log_good =<<EOF ; >> citrun_inst -CITRUN_COMPILERS = '' -PATH='' +Compilers path = '' +PATH = '' Found source file '' Modified command line is '' Added clangtool argument '' @@ -58,22 +58,30 @@ Forked compiler '' Rewritten source compile successful Restored '' >> citrun_inst -CITRUN_COMPILERS = '' -PATH='' +Compilers path = '' +PATH = '' Link detected, adding '' to command line. Modified command line is '' No source files found on command line. EOF -if ($^O eq "MSWin32") { +my $citrun_log; +$wrap->read(\$citrun_log, 'citrun.log'); + +# Check line endings. +if ($^O eq 'MSWin32') { # Windows gets an extra message because exec() is emulated by fork(). $citrun_log_good .= <<EOF ; Forked compiler '' EOF + my $rn_count = () = $citrun_log_good =~ /\r\n/g; + is( $rn_count, 25, 'is \r\n count correct' ); +} +else { + my $n_count = () = $citrun_log_good =~ /\n/g; + is( $n_count, 25, 'is \n count correct' ); } -my $citrun_log; -$wrap->read(\$citrun_log, 'citrun.log'); $citrun_log = clean_citrun_log($citrun_log); eq_or_diff( $citrun_log, $citrun_log_good, 'is citrun.log file identical', { context => 3 } ); diff --git a/t/inst_log_eol.t b/t/inst_log_eol.t @@ -1,37 +0,0 @@ -# -# Test that citrun.log has the correct line endings for the platform its on. -# -use strict; -use warnings; -use t::utils; -plan tests => 3; - - -my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' ); - -$wrap->write( 'main.c', <<EOF ); -int -main(void) -{ - return 0; -} -EOF - -$wrap->write( 'Jamfile', 'Main main : main.c ;' ); - -$wrap->run( args => 'jam', chdir => $wrap->curdir ); -print $wrap->stdout; -is( $wrap->stderr, '', 'is citrun_wrap stderr silent' ); -is( $? >> 8, 0, 'is citrun_wrap exit code 0' ); - -my $citrun_log; -$wrap->read(\$citrun_log, 'citrun.log'); - -if ($^O eq 'MSWin32') { - my $rn_count = () = $citrun_log =~ /\n/g; - is( $rn_count, 24, 'is \r\n count correct' ); -} -else { - my $n_count = () = $citrun_log =~ /\n/g; - is( $n_count, 24, 'is \n count correct' ); -}