citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 18d45cf3d4d55c04dcc21ccee4e8854e9d8beb47
parent 34df74ec53b005a36c98daf475a5bb031db2034d
Author: Kyle Milz <kyle@0x30.net>
Date:   Thu, 29 Dec 2016 20:59:15 -0700

t: convert inst_path.sh to perl

Diffstat:
Dt/inst_path.sh | 24------------------------
At/inst_path.t | 33+++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/t/inst_path.sh b/t/inst_path.sh @@ -1,24 +0,0 @@ -#!/bin/sh -u -# -# Test that: -# - not having PATH set errors -# - not having CITRUN_SHARE in PATH when using transparent compile mode errors -# -. t/utils.subr -plan 2 - -# Save PATH to restore it later. ok_program needs 'expr' to count too. -OLDPATH="${PATH}" -alias expr=`which expr` - -unset PATH -output_good='citrun_inst: Error: PATH is not set.' -ok_program "run citrun_inst as cc with no PATH" 1 "$output_good" \ - $treedir/src/cc -c nomatter.c - -export PATH="" -output_good="citrun_inst: Error: CITRUN_SHARE not in PATH." -ok_program "run citrun_inst as cc with empty PATH" 1 "$output_good" \ - $treedir/src/cc -c nomatter.c 2> /dev/null - -export PATH="${OLDPATH}" diff --git a/t/inst_path.t b/t/inst_path.t @@ -0,0 +1,33 @@ +# +# Test that: +# - not having PATH set errors +# - not having CITRUN_SHARE in PATH when using transparent compile mode errors +# +use strict; +use warnings; +use Test::Cmd; +use Test::More tests => 6; + +my $cc = Test::Cmd->new( prog => 'src/cc', workdir => '' ); + +delete $ENV{'PATH'}; +$cc->run( args => "-c nomatter.c", chdir => $cc->curdir ); + +# XXX: Somethings wrong here. The commented error should be displayed when PATH +# is not set at all. +my $error_good = "citrun_inst: Error: CITRUN_SHARE not in PATH. +"; +#my $error_good = 'citrun_inst: Error: PATH is not set.'; + +is( $cc->stdout, '', 'is cc stdout empty' ); +is( $cc->stderr, $error_good, 'is cc stderr identical' ); +is( $? >> 8, 1, 'is cc exit code 1' ); + +$ENV{PATH} = ""; +$error_good = "citrun_inst: Error: CITRUN_SHARE not in PATH. +"; +$cc->run( args => "-c nomatter.c", chdir => $cc->curdir ); + +is( $cc->stdout, '', 'is cc stdout identical' ); +is( $cc->stderr, $error_good, 'is cc stderr empty' ); +is( $? >> 8, 1, 'is cc exit code 1' );