citrun

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

commit 27d662cd698cfbe082c2f5777b560e174a87ad62
parent 49108dee586836516f3c5fe4f842c4ddf0c21b29
Author: Kyle Milz <kyle@windows.krwm.net>
Date:   Tue, 10 Jan 2017 20:59:35 -0800

inst: open citrun.log in text mode for correct line endings

Diffstat:
Minst_log.h | 3++-
At/inst_log_eol.t | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/inst_log.h b/inst_log.h @@ -30,7 +30,8 @@ class InstrumentLogger : public std::ostream } std::error_code m_ec; - m_out = new llvm::raw_fd_ostream("citrun.log", m_ec, llvm::sys::fs::F_Append); + m_out = new llvm::raw_fd_ostream("citrun.log", m_ec, + llvm::sys::fs::F_Append | llvm::sys::fs::F_Text); if (m_ec.value()) { m_out = &llvm::errs(); *m_out << "Can't open citrun.log: " << m_ec.message(); diff --git a/t/inst_log_eol.t b/t/inst_log_eol.t @@ -0,0 +1,37 @@ +# +# 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' ); +}