commit afdce9c4c25896c67ed5ce805da0319dfd2166d8
parent d03edd412b1a66a338914c4e7fde9d65569b0978
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Thu, 5 Jan 2017 19:47:33 -0800
t: convert lib_badver.sh to perl
Diffstat:
2 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/t/lib_badver.sh b/t/lib_badver.sh
@@ -1,26 +0,0 @@
-#!/bin/sh -u
-#
-# Check that linking object files of one citrun version with libcitrun.a of
-# another errors.
-#
-. t/utils.subr
-plan 2
-
-
-cat <<EOF > main.c
-#include <stddef.h>
-
-struct citrun_node;
-void citrun_node_add(unsigned int, unsigned int, struct citrun_node *);
-
-int
-main(int argc, char *argv[])
-{
- citrun_node_add(0, 255, NULL);
-}
-EOF
-
-ok "is compiled" cc -o main main.c
-
-output_good="main: libcitrun 0.0: incompatible version 0.255, try cleaning and rebuilding your project"
-ok_program "running fake node" 1 "$output_good" ./main
diff --git a/t/lib_badver.t b/t/lib_badver.t
@@ -0,0 +1,38 @@
+#
+# Check that linking object files of one citrun version with libcitrun of
+# another errors.
+#
+use strict;
+use warnings;
+use Test::Cmd;
+use Test::More tests => 4;
+
+
+my $compiler = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
+
+$compiler->write( 'main.c', <<EOF );
+#include <stddef.h>
+
+struct citrun_node;
+void citrun_node_add(unsigned int, unsigned int, struct citrun_node *);
+
+int
+main(int argc, char *argv[])
+{
+ citrun_node_add(0, 255, NULL);
+}
+EOF
+
+$compiler->run( args => 'cl /nologo main.c', chdir => $compiler->curdir );
+# is( $compiler->stdout, '', 'is compiler stdout silent' );
+is( $compiler->stderr, '', 'is compiler stderr silent' );
+is( $? >> 8, 0, 'is compiler exit code 0' );
+
+my $err_good = 'libcitrun 0.0: incompatible version 0.255.
+Try cleaning and rebuilding your project.
+';
+
+my $abs_prog_path = File::Spec->catfile( $compiler->workdir, "main" );
+$compiler->run( prog => $abs_prog_path, chdir => $compiler->curdir );
+is( $compiler->stdout, '', 'is incompatible node program stdout silent' );
+is( $compiler->stderr, $err_good, 'is incompatible node program stdout silent' );