commit 042e7681721e8742c7688f56d2652a6047e4aa8f
parent 4d6f250ca77ee652c71fa5e80f057c67d87b8f50
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Fri, 13 Jan 2017 01:45:02 -0800
t: break apart eol test from log, again
Diffstat:
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/t/inst_log.t b/t/inst_log.t
@@ -4,8 +4,9 @@
#
use strict;
use warnings;
+
use t::utils;
-plan tests => 4;
+plan tests => 3;
my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
@@ -68,18 +69,11 @@ EOF
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' );
}
$citrun_log = clean_citrun_log($citrun_log);
diff --git a/t/inst_logeol.t b/t/inst_logeol.t
@@ -0,0 +1,33 @@
+#
+# Check that proper platform specific line endings exist in citrun.log.
+#
+use strict;
+use warnings;
+
+use t::utils;
+plan tests => 1;
+
+
+my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
+
+$wrap->write( 'main.c', <<EOF );
+EOF
+
+$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
+
+# Read log file in binary mode so \r\n's don't get converted by the IO layer.
+open( my $fh, '<', File::Spec->catfile( $wrap->workdir, 'citrun.log' ) );
+binmode( $fh );
+read $fh, my $citrun_log, 64 * 1024;
+
+# Check line endings.
+if ($^O eq 'MSWin32') {
+ # Windows has extra lines because exec() is emulated by fork().
+
+ my $rn_count = () = $citrun_log =~ /\r\n/g;
+ is( $rn_count, 16, 'is \r\n count correct' );
+}
+else {
+ my $n_count = () = $citrun_log =~ /\n/g;
+ is( $n_count, 15, 'is \n count correct' );
+}