commit 1b84b74bf51780d28b250a66db796774f1d3a839
parent bc3af8cc602f70bd13ed00b6a88de5aa6e478854
Author: Kyle Milz <kyle@0x30.net>
Date: Sun, 8 Jan 2017 15:57:04 -0700
t: factor out os compiler choosing
Diffstat:
6 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/t/e2e_intent.t b/t/e2e_intent.t
@@ -35,11 +35,7 @@ int main(int argc, char *argv[]) {
}
EOF
-if ($^O eq "MSWin32") {
- $e2e->run( args => 'cl /nologo fib.c', chdir => $e2e->curdir );
-} else {
- $e2e->run( args => 'cc -o fib fib.c', chdir => $e2e->curdir );
-}
+$e2e->run( args => os_compiler() . 'fib fib.c', chdir => $e2e->curdir );
my $log;
$e2e->read( \$log, 'citrun.log' );
diff --git a/t/e2e_link_multiple.t b/t/e2e_link_multiple.t
@@ -33,11 +33,7 @@ void third_func(void) {
}
EOF
-if ($^O eq "MSWin32") {
- $wrap->run( args => 'cl /nologo one.c two.c three.c', chdir => $wrap->curdir );
-} else {
- $wrap->run( args => 'cc -o main one.c two.c three.c', chdir => $wrap->curdir );
-}
+$wrap->run( args => os_compiler() . 'main one.c two.c three.c', chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
diff --git a/t/inst_basic_link.t b/t/inst_basic_link.t
@@ -10,12 +10,7 @@ plan tests => 3;
my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
$wrap->write( 'main.c', 'int main(void) { return 0; }' );
-
-if ($^O eq "MSWin32") {
- $wrap->run( args => 'cl /nologo main.c', chdir => $wrap->curdir );
-} else {
- $wrap->run( args => 'cc main.c', chdir => $wrap->curdir );
-}
+$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
diff --git a/t/inst_two_src.t b/t/inst_two_src.t
@@ -17,11 +17,7 @@ int other(void) {
}
EOF
-if ($^O eq "MSWin32") {
- $wrap->run( args => 'cl /nologo main.c other.c', chdir => $wrap->curdir );
-} else {
- $wrap->run( args => 'cc -o main main.c other.c', chdir => $wrap->curdir );
-}
+$wrap->run( args => os_compiler() . 'main main.c other.c', chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
diff --git a/t/lib_badver.t b/t/lib_badver.t
@@ -4,8 +4,8 @@
#
use strict;
use warnings;
-use Test::Cmd;
-use Test::More tests => 4;
+use t::utils; # os_compiler()
+plan tests => 4;
my $compiler = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
@@ -23,11 +23,7 @@ main(int argc, char *argv[])
}
EOF
-if ($^O eq "MSWin32") {
- $compiler->run( args => 'cl /nologo main.c', chdir => $compiler->curdir );
-} else {
- $compiler->run( args => 'cc -o main main.c', chdir => $compiler->curdir );
-}
+$compiler->run( args => os_compiler() . 'main 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' );
diff --git a/t/utils.pm b/t/utils.pm
@@ -7,6 +7,12 @@ use Test::More;
use autodie;
unified_diff; # For Test::Differences diffs
+sub os_compiler {
+ if ($^O eq 'MSWin32') {
+ return 'cl /nologo /Fe';
+ }
+ return 'cc -o ';
+}
sub clean_citrun_log {
my ($log) = @_;