commit 0ce53d6a770c471c6861bcec07608b0f1b3a39bd
parent 6e399f04953de6e2243dfd3fabe56c48c8f5066f
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Fri, 6 Jan 2017 21:40:13 -0800
t: convert e2e_ansi.sh to perl
Diffstat:
2 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/t/e2e_ansi.sh b/t/e2e_ansi.sh
@@ -1,29 +0,0 @@
-#!/bin/sh -u
-#
-# Check that instrumentation works when the -ansi flag is passed during
-# compilation.
-#
-. t/utils.subr
-plan 4
-
-empty_main
-
-cat <<EOF > check.good
-Summary:
- 1 Source files used as input
- 1 Application link commands
- 1 Rewrite successes
- 1 Rewritten source compile successes
-
-Totals:
- 6 Lines of source code
- 1 Function definitions
- 1 Return statement values
- 3 Total statements
-EOF
-
-ok "is instrumented compile successful" cc -ansi -o main main.c
-ok "is citrun_check exit 0" citrun_check -o check.out
-
-strip_millis check.out
-ok "is citrun_check output different" diff -u check.good check.out
diff --git a/t/e2e_ansi.t b/t/e2e_ansi.t
@@ -0,0 +1,45 @@
+#
+# Check that instrumentation works when the -ansi flag is passed during
+# compilation.
+#
+use strict;
+use warnings;
+use t::utils;
+plan tests => 3;
+
+
+my $cc = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
+$cc->write( 'main.c', 'int main(void) { return 0; }' );
+
+if ($^O eq 'MSWin32') {
+ $cc->run( args => 'cl /nologo /Za main.c', chdir => $cc->curdir );
+} else {
+ $cc->run( args => 'cc -ansi -o main main.c', chdir => $cc->curdir );
+}
+#is( $cc->stdout, '', 'is citrun_wrap cc stdout silent' );
+is( $cc->stderr, '', 'is citrun_wrap cc stderr silent' );
+is( $? >> 8, 0, 'is citrun_wrap cc exit code 0' );
+
+my $log_good = <<EOF;
+>> citrun_inst
+CITRUN_COMPILERS = ''
+PATH=''
+Found source file ''
+Link detected, adding '' to command line.
+Modified command line is ''
+Added clangtool argument ''
+Instrumentation of '' finished:
+ 1 Lines of source code
+ 1 Function definitions
+ 1 Return statement values
+ 3 Total statements
+Modified source written successfully.
+Rewriting successful.
+Forked compiler ''
+Rewritten source compile successful
+Restored ''
+EOF
+
+my $log_out;
+$cc->read( \$log_out, 'citrun.log' );
+eq_or_diff( clean_citrun_log($log_out), $log_good, 'is citrun.log identical');