commit bbc73253655830933ac9ee17a77aedcadec1555b
parent f08afc9700070d7a58798c4d03eba793c63e882b
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Tue, 3 Jan 2017 20:24:48 -0800
t: convert inst_fail.sh to perl
Diffstat:
2 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/t/inst_fail.sh b/t/inst_fail.sh
@@ -1,28 +0,0 @@
-#!/bin/sh -u
-#
-# Check that a program that won't compile natively is handled properly.
-#
-. t/utils.subr
-plan 4
-
-
-echo "int main(void) { return 0; " > bad.c
-
-cc -c bad.c 2> /dev/null
-ok "is instrumented compile exit code 1" test $? -eq 1
-
-cat <<EOF > check.good
-Summary:
- 1 Source files used as input
- 1 Rewrite failures
-
-Totals:
- 2 Lines of source code
- 1 Function definitions
- 1 Return statement values
- 3 Total statements
-EOF
-
-ok "running citrun_check" citrun_check -o check.out
-strip_millis check.out
-ok "citrun_check diff" diff -u check.good check.out
diff --git a/t/inst_fail.t b/t/inst_fail.t
@@ -0,0 +1,37 @@
+#
+# Check that a program that won't compile natively is handled properly.
+#
+use strict;
+use warnings;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 2;
+use t::utils;
+unified_diff;
+
+
+my $inst = Test::Cmd->new( prog => 'citrun_inst', workdir => '' );
+
+$inst->write( 'bad.c', <<EOF );
+int
+main(void)
+{
+ return 0;
+EOF
+
+$inst->run( args => '-c bad.c', workdir => $inst->curdir );
+
+my $out_good = <<EOF;
+>> citrun_inst
+CITRUN_COMPILERS = ''
+Found source file ''
+Modified command line is ''
+Added clangtool argument ''
+Rewriting failed.
+EOF
+
+my $out = t::utils::clean_citrun_log(scalar $inst->stdout);
+
+eq_or_diff( $out, $out_good, 'is citrun_inst output identical' );
+print $inst->stderr;
+is( $? >> 8, 1, 'is citrun_inst exit code 1' );