citrun

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

commit 777f30057473e15558655029b40640e9ba93defb
parent a603e6195e2a2a20ef4ce16e0db96c00ece8959a
Author: Kyle Milz <kyle@0x30.net>
Date:   Wed, 10 Aug 2016 22:13:35 -0600

test: chdir to tmpdir as soon as possible

Diffstat:
Mtest/package.pm | 17+++++++----------
Mtt/nvi.t | 36+++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/test/package.pm b/test/package.pm @@ -11,23 +11,20 @@ sub new { my $self = {}; bless($self, $class); - my $dir = tempdir( CLEANUP => 1 ); - $self->{dir} = $dir; - $self->{port} = "/usr/ports/$name"; - - $ENV{CITRUN_SOCKET} = $self->{dir} . "/test.socket"; - my $cwd = cwd; + my $dir = tempdir( CLEANUP => 1 ); + $ENV{CITRUN_SOCKET} = "test.socket"; + $ENV{CITRUN_TOOLS} = cwd . "/src"; + chdir $dir; system(<<EOF) == 0 or die "build failed."; set -e -make -C $self->{port} full-build-depends > $self->{dir}/deps -doas pkg_add -zl $self->{dir}/deps +make -C $self->{port} full-build-depends > deps +doas pkg_add -zl deps make -C $self->{port} clean=all -make -C $self->{port} PORTPATH="$cwd/src:\\\${WRKDIR}/bin:\$PATH" +make -C $self->{port} PORTPATH="$ENV{CITRUN_TOOLS}:\\\${WRKDIR}/bin:\$PATH" EOF - return $self; } diff --git a/tt/nvi.t b/tt/nvi.t @@ -2,11 +2,10 @@ use strict; use warnings; use Expect; use Test::More tests => 230 ; -use Test::Package; -use Test::Report; +use test::package; use test::viewer; -my $package = Test::Package->new("editors/nvi"); +my $package = test::package->new("editors/nvi"); my $viewer = test::viewer->new(); my $exp = Expect->spawn("/usr/ports/pobj/nvi-2.1.3/nvi2-2.1.3/build/nvi"); @@ -134,4 +133,35 @@ $viewer->cmp_dynamic_data(); $exp->hard_close(); $viewer->close(); +open( my $fh, ">", "check.good" ); +print $fh <<EOF; +Checking ...done + +Summary: + 2 Log files found + 115 Source files input + 116 Calls to the instrumentation tool + 115 Forked compilers + 115 Instrument successes + 2 Application link commands + 32 Warnings during source parsing + +Totals: + 47830 Lines of source code + 3680 Lines of instrumentation header + 2 Functions called 'main' + 2102 Function definitions + 3399 If statements + 363 For loops + 62 While loops + 14 Do while loops + 171 Switch statements + 1909 Return statement values + 3488 Call expressions + 239351 Total statements + 3277 Errors rewriting source +EOF + +system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/nvi-* > check.out"); +system("diff -u check.good check.out"); $package->clean();