commit 3d0936d10224f786523b36c3217ebce3f17e99bf
parent ff93cb6bf624f20b36815841fc732e6ba3bf2000
Author: Kyle Milz <milz@imac.0x30.net>
Date: Thu, 4 Mar 2021 18:44:33 -0800
t: use lib 't' instead of use for libraries
- also update some test descriptions while here
Diffstat:
52 files changed, 602 insertions(+), 405 deletions(-)
diff --git a/Makefile b/Makefile
@@ -28,6 +28,6 @@ SUBDIR += lib
test:
- prove -I.
+ prove
.include <bsd.subdir.mk>
diff --git a/t/e2e_ansi.t b/t/e2e_ansi.t
@@ -3,8 +3,12 @@
# compilation.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+
+use lib 't';
+require utils;
my $cc = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -15,9 +19,9 @@ if ($^O eq 'MSWin32') {
} else {
$cc->run( args => 'cc -ansi -o main main.c', chdir => $cc->curdir );
}
-#is( $cc->stdout, '', 'is citrun_wrap cc stdout silent' );
-is( $cc->stderr, '', 'is citrun_wrap cc stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap cc exit code 0' );
+#is( $cc->stdout, '', 'citrun_wrap cc stdout silent' );
+is( $cc->stderr, '', 'citrun_wrap cc stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap cc exit code 0' );
my $log_good = <<EOF;
>> citrun_inst
@@ -40,4 +44,4 @@ EOF
my $log_out;
$cc->read( \$log_out, 'citrun.log' );
-eq_or_diff( clean_citrun_log($log_out), $log_good, 'is citrun.log identical');
+eq_or_diff( utils::clean_citrun_log($log_out), $log_good, 'is citrun.log identical');
diff --git a/t/e2e_fail.t b/t/e2e_fail.t
@@ -2,8 +2,12 @@
# Check that a program that won't compile natively is handled properly.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -34,12 +38,13 @@ Restored ''
EOF
$inst->run( args => 'cc -c bad.c', chdir => $inst->curdir );
-is( $inst->stdout, '', 'is citrun_wrap stdout silent' );
+is( $inst->stdout, '', 'citrun_wrap stdout silent' );
print $inst->stderr;
-is( $? >> 8, 1, 'is citrun_wrap exit code 1' );
+isnt( $inst->stderr, '', 'citrun_wrap stderr not silent');
+is( $? >> 8, 1, 'citrun_wrap exit code 1' );
my $out;
$inst->read( \$out, 'citrun.log' );
-$out = clean_citrun_log($out);
+$out = utils::clean_citrun_log($out);
-eq_or_diff( $out, $out_good, 'is citrun.log file identical', { context => 3} );
+eq_or_diff( $out, $out_good, 'citrun.log identical', { context => 3} );
diff --git a/t/e2e_intent.t b/t/e2e_intent.t
@@ -3,8 +3,12 @@
# Show this by getting correct results from an instrumented program.
#
use Modern::Perl;
-use t::utils;
-plan tests => 11;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 11;
+
+use lib 't';
+require utils;
my $e2e = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -35,11 +39,11 @@ int main(int argc, char *argv[]) {
}
EOF
-$e2e->run( args => os_compiler() . 'fib fib.c', chdir => $e2e->curdir );
+$e2e->run( args => utils::os_compiler() . 'fib fib.c', chdir => $e2e->curdir );
my $log;
$e2e->read( \$log, 'citrun.log' );
-$log = clean_citrun_log( $log );
+$log = utils::clean_citrun_log( $log );
my $log_good = <<EOF;
>> citrun_inst
@@ -64,23 +68,23 @@ Restored ''
EOF
print $e2e->stdout;
-is( $e2e->stderr, '', 'is citrun_wrap compile stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap compile exit code 0' );
-eq_or_diff( $log, $log_good, 'is citrun_wrap log file identical' );
+is( $e2e->stderr, '', 'citrun_wrap compile stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap compile exit code 0' );
+eq_or_diff( $log, $log_good, 'citrun_wrap log file identical' );
$e2e->run( prog => $e2e->workdir . "/fib", chdir => $e2e->curdir );
-isnt( $e2e->stderr, '', 'is fib stderr not silent' );
-is( $? >> 8, 1, 'is fib with no args exit 1' );
+isnt( $e2e->stderr, '', 'fib stderr not silent' );
+is( $? >> 8, 1, 'fib with no args exit 1' );
unlink "/tmp/citrun.out";
$e2e->run( prog => $e2e->workdir . "/fib", args => '10', chdir => $e2e->curdir );
-is( $e2e->stdout, '55', 'is fib 10 equal to 55' );
-isnt( $e2e->stderr, '', 'is fib 10 stderr not silent' );
-is( $? >> 8, 0, 'is fib 10 exit 0' );
+is( $e2e->stdout, '55', 'fib 10 = 55' );
+isnt( $e2e->stderr, '', 'fib 10 stderr not silent' );
+is( $? >> 8, 0, 'fib 10 exit 0' );
unlink "/tmp/citrun.out";
$e2e->run( prog => $e2e->workdir . "/fib", args => '20', chdir => $e2e->curdir );
-is( $e2e->stdout, '6765', 'is fib 20 equal to 6765' );
-isnt( $e2e->stderr, '', 'is fib 20 stderr not silent' );
-is( $? >> 8, 0, 'is fib 20 exit 0' );
+is( $e2e->stdout, '6765', 'fib 20 = 6765' );
+isnt( $e2e->stderr, '', 'fib 20 stderr not silent' );
+is( $? >> 8, 0, 'fib 20 exit 0' );
unlink "/tmp/citrun.out";
diff --git a/t/e2e_link_multiple.t b/t/e2e_link_multiple.t
@@ -2,8 +2,12 @@
# Check that linking more than one instrumented object file together works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -32,7 +36,8 @@ void third_func(void) {
}
EOF
-$wrap->run( args => os_compiler() . 'main one.c two.c three.c', chdir => $wrap->curdir );
+$wrap->run( args => utils::os_compiler() . 'main one.c two.c three.c',
+ chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
@@ -71,9 +76,9 @@ EOF
my $citrun_log;
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log($citrun_log);
+$citrun_log = utils::clean_citrun_log($citrun_log);
-eq_or_diff( $citrun_log, $log_good, 'is citrun.log identical', { context => 3 } );
+eq_or_diff( $citrun_log, $log_good, 'citrun.log identical', { context => 3 } );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap exit code 0' );
diff --git a/t/e2e_nosrc.t b/t/e2e_nosrc.t
@@ -3,9 +3,12 @@
# handled.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -22,9 +25,9 @@ $inst->run( args => 'cc -c doesnt_exist.c', chdir => $inst->curdir );
my $out;
$inst->read( \$out, 'citrun.log' );
-$out = clean_citrun_log($out);
-eq_or_diff( $out, $out_good, 'is citrun_wrap output identical' );
+$out = utils::clean_citrun_log($out);
+eq_or_diff( $out, $out_good, 'citrun_wrap output identical' );
-is( $inst->stdout, '', 'is citrun_wrap stdout silent' );
-like( $inst->stderr, qr/$err_good/, 'is citrun_wrap stderr silent' );
-is( $? >> 8, 1, 'is citrun_wrap exit code 1' );
+is( $inst->stdout, '', 'citrun_wrap stdout silent' );
+like( $inst->stderr, qr/$err_good/, 'citrun_wrap stderr silent' );
+is( $? >> 8, 1, 'citrun_wrap exit code 1' );
diff --git a/t/e2e_shlib.t b/t/e2e_shlib.t
@@ -3,11 +3,19 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
-plan skip_all => '.so platforms only' if ($^O eq 'MSWin32');
+use lib 't';
+require utils;
+
+if ($^O eq 'MSWin32') {
+ plan skip_all => '.so platforms only';
+}
plan tests => 15;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
$wrap->write( 'main.c', <<EOF );
@@ -37,21 +45,21 @@ libfunc(void)
EOF
$wrap->run( args => 'cc -c -fpic lib.c', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is citrun_wrap cc -c stdout silent' );
-is( $wrap->stderr, '', 'is citrun_wrap cc -c stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap cc -c exit code 0' );
+is( $wrap->stdout, '', 'citrun_wrap cc -c stdout silent' );
+is( $wrap->stderr, '', 'citrun_wrap cc -c stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap cc -c exit code 0' );
$wrap->run( args => 'cc -shared -o liblib.so lib.o', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is citrun_wrap cc -shared stdout silent' );
-is( $wrap->stderr, '', 'is citrun_wrap cc -shared stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap cc -shared exit code 0' );
+is( $wrap->stdout, '', 'citrun_wrap cc -shared stdout silent' );
+is( $wrap->stderr, '', 'citrun_wrap cc -shared stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap cc -shared exit code 0' );
# Don't instrument main to make sure the library can stand on its own.
my ($compiler) = which 'cc';
$wrap->run( prog => $compiler, args => '-L. -o main main.c -llib', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is cc -o main -llib stdout silent' );
-is( $wrap->stderr, '', 'is cc -o main -llib stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap cc -o exit code 0' );
+is( $wrap->stdout, '', 'cc -o main -llib stdout silent' );
+is( $wrap->stderr, '', 'cc -o main -llib stderr silent' );
+is( $? >> 8, 0, 'cc -o main -llib exit code 0' );
my $log_good = <<EOF;
Summary:
@@ -73,15 +81,14 @@ $wrap->run( prog => 'bin/citrun_report', args => 'citrun.log',
my $wrap_stdout = $wrap->stdout;
$wrap_stdout =~ s/.*Milliseconds spent.*\n//;
eq_or_diff( $wrap_stdout, $log_good, 'is citrun_report output identical', { context => 3 } );
-is( $wrap->stderr, '', 'is citrun_report stderr silent' );
-is( $? >> 8, 0, 'is citrun_report exit code 0' );
+is( $wrap->stderr, '', 'citrun_report stderr silent' );
+is( $? >> 8, 0, 'citrun_report exit code 0' );
$ENV{LD_LIBRARY_PATH} = $wrap->workdir;
$wrap->run( prog => $wrap->workdir . '/main', chdir => $wrap->curdir );
-is( $wrap->stdout, 'lib called', 'is instrumented program stdout silent' );
-isnt( $wrap->stderr, '', 'is instrumented program stderr not silent' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
-
+is( $wrap->stdout, 'lib called', 'inst program stdout silent' );
+isnt( $wrap->stderr, '', 'inst program stderr not silent' );
+is( $? >> 8, 0, 'inst program exit code 0' );
unlink "/tmp/citrun.out";
#my $file = get_one_shmfile( $wrap->workdir );
diff --git a/t/gl_basic.t b/t/gl_basic.t
@@ -3,10 +3,11 @@
# an identical output to known good.
#
use Modern::Perl;
+use Test::More skip_all => 'not yet';
-use t::gl_utils;
-use t::utils;
-plan tests => 9;
+use lib 't';
+require gl_utils;
+require utils;
my $dir = setup_projdir();
@@ -21,10 +22,10 @@ is( $? >> 8, 0, 'is instrumented program exit code zero' );
my $output_file = File::Spec->catdir( $dir->workdir, 'test.tga' );
my $output_good = File::Spec->catfile( 't', 'gl', 'basic.tga' );
-my $gltest = Test::Cmd->new( prog => 'bin/citrun_gltest', workdir => '' );
-$gltest->run( args => "$output_file 800 600" );
-isnt( $gltest->stdout, '', 'is citrun_gltest stdout not silent' );
-is( $gltest->stderr, '', 'is citrun_gltest stderr silent' );
-is( $? >> 8, 0, 'is citrun_gltest exit code zero' );
+my $gl = Test::Cmd->new( prog => 'bin/citrun_gl', workdir => '' );
+$gl->run( args => "$output_file 800 600" );
+isnt( $gl->stdout, '', 'is citrun_gl stdout not silent' );
+is( $gl->stderr, '', 'is citrun_gl stderr silent' );
+is( $? >> 8, 0, 'is citrun_gl exit code zero' );
-ok_image( $output_file, $output_good, $gltest->workdir );
+ok_image( $output_file, $output_good, $gl->workdir );
diff --git a/t/gl_nodir.t b/t/gl_nodir.t
@@ -2,21 +2,17 @@
# Check that citrun_gl outputs a good error message when $CITRUN_PROCDIR is bad.
#
use Modern::Perl;
+use Test::More skip_all => 'not yet';
-use t::utils;
-plan tests => 3;
-my $gl = Test::Cmd->new( prog => 'bin/citrun_gltest', workdir => '' );
-
-my $procdir = $gl->workdir . "/procdir/";
-$ENV{CITRUN_PROCDIR} = $procdir;
+my $gl = Test::Cmd->new( prog => 'gl/citrun_gl', workdir => '' );
# Create a file in the exact place the directory is supposed to be.
$gl->write( 'procdir', '' );
$gl->run( args => '/dev/null' );
-my $err_good = "citrun_gltest: opendir '$procdir': Not a directory";
+my $err_good = "citrun_gl: opendir 'procdir': Not a directory";
isnt( $gl->stdout, '', 'is stdout not silent' );
like( $gl->stderr, qr/$err_good/, 'is stderr silent' );
is( $? >> 8, 1, 'is exit code nonzero' );
diff --git a/t/gl_welcome.t b/t/gl_welcome.t
@@ -3,21 +3,22 @@
# message.
#
use Modern::Perl;
+use Test::More skip_all => 'not yet';
-use t::gl_utils;
-use t::utils;
-plan tests => 4;
+use lib 't';
+require gl_utils;
+require utils;
-my $gltest = Test::Cmd->new( prog => 'bin/citrun_gltest', workdir => '' );
-$ENV{CITRUN_PROCDIR} = $gltest->workdir . "/procdir/";
+my $gl = Test::Cmd->new( prog => 'bin/citrun_gl', workdir => '' );
+$ENV{CITRUN_PROCDIR} = $gl->workdir . "/procdir/";
-my $output_file = File::Spec->catdir( $gltest->workdir, 'test.tga' );
+my $output_file = File::Spec->catdir( $gl->workdir, 'test.tga' );
my $output_good = File::Spec->catfile( 't', 'gl', 'welcome.tga' );
-$gltest->run( args => "$output_file 800 600" );
-isnt( $gltest->stdout, '', 'is citrun_gltest stdout not silent' );
-is( $gltest->stderr, '', 'is citrun_gltest stderr silent' );
-is( $? >> 8, 0, 'is citrun_gltest exit code zero' );
+$gl->run( args => "$output_file 800 600" );
+isnt( $gl->stdout, '', 'is citrun_gl stdout not silent' );
+is( $gl->stderr, '', 'is citrun_gl stderr silent' );
+is( $? >> 8, 0, 'is citrun_gl exit code zero' );
-ok_image( $output_file, $output_good, $gltest->workdir );
+ok_image( $output_file, $output_good, $gl->workdir );
diff --git a/t/inst_basic_link.t b/t/inst_basic_link.t
@@ -2,14 +2,19 @@
# Check that the most basic of compile command lines works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
$wrap->write( 'main.c', 'int main(void) { return 0; }' );
-$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
+$wrap->run( args => utils::os_compiler() . 'main main.c',
+ chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
@@ -32,9 +37,9 @@ EOF
my $citrun_log;
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log($citrun_log);
+$citrun_log = utils::clean_citrun_log($citrun_log);
eq_or_diff( $citrun_log, $log_good, 'is citrun.log file identical', { context => 3 } );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap stderr empty' );
-is( $? >> 8, 0, 'is citrun_wrap exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap stderr empty' );
+is( $? >> 8, 0, 'citrun_wrap exit code 0' );
diff --git a/t/inst_binop.t b/t/inst_binop.t
@@ -2,9 +2,13 @@
# Test that binary operators in strange cases work. Includes enums and globals.
#
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
-plan tests => 4;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -74,9 +78,9 @@ my $inst_out;
$inst->read(\$inst_out, 'binop.c');
# Sanitize paths from stdout.
-my $log_out = clean_citrun_log(scalar $inst->stdout);
+my $log_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $log_out, $log_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff($log_out, $log_good, 'citrun_inst output identical', { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_dowhile.t b/t/inst_dowhile.t
@@ -2,8 +2,12 @@
# Make sure that do while loop condition instrumentation works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -50,9 +54,9 @@ my $inst_out;
$inst->read(\$inst_out, 'dowhile.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff($check_out, $check_good, 'citrun_inst output identical', { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_fail.t b/t/inst_fail.t
@@ -2,9 +2,12 @@
# Check that a program that won't compile natively is handled properly.
#
use Modern::Perl;
-use t::utils;
-plan tests => 2;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 2;
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -31,8 +34,8 @@ EOF
$inst->run( args => '-c bad.c', chdir => $inst->curdir );
-my $out = clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $out, $out_good, 'is citrun_inst output identical', { context => 3} );
+my $out = utils::clean_citrun_log(scalar $inst->stdout);
+eq_or_diff( $out, $out_good, 'citrun_inst output identical', { context => 3} );
print $inst->stderr;
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_for.t b/t/inst_for.t
@@ -2,8 +2,12 @@
# Test that for loop condition instrumenting works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -49,9 +53,10 @@ my $inst_out;
$inst->read(\$inst_out, 'for.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 } ;
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff($check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_funcdef.t b/t/inst_funcdef.t
@@ -2,8 +2,12 @@
# Check that really long function declarations are instrumented properly.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -51,9 +55,10 @@ my $inst_out;
$inst->read(\$inst_out, 'funcdef.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff($check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_if.t b/t/inst_if.t
@@ -2,8 +2,12 @@
# Check that if statement conditions are instrumented properly.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -60,9 +64,10 @@ my $inst_out;
$inst->read(\$inst_out, 'if.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_log.t b/t/inst_log.t
@@ -3,8 +3,12 @@
# citrun_report relies on this output, and citrun_report is used quite a bit.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -67,10 +71,11 @@ Forked compiler ''
EOF
}
-$citrun_log = clean_citrun_log($citrun_log);
+$citrun_log = utils::clean_citrun_log($citrun_log);
-eq_or_diff( $citrun_log, $citrun_log_good, 'is citrun.log file identical', { context => 3 } );
+eq_or_diff( $citrun_log, $citrun_log_good, 'is citrun.log file identical',
+ { context => 3 } );
# Deliberately not checking $wrap->stdout here because portability.
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap exit code 0' );
diff --git a/t/inst_logeol.t b/t/inst_logeol.t
@@ -2,8 +2,11 @@
# Check that proper platform specific line endings exist in citrun.log.
#
use Modern::Perl;
-use t::utils;
-plan tests => 1;
+use Test::Cmd;
+use Test::More tests => 1;
+
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -11,7 +14,8 @@ my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
$wrap->write( 'main.c', <<EOF );
EOF
-$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
+$wrap->run( args => utils::os_compiler() . 'main main.c',
+ chdir => $wrap->curdir );
# Read log file in binary mode so \r\n's don't get converted by the IO layer.
open( my $fh, '<', File::Spec->catfile( $wrap->workdir, 'citrun.log' ) );
@@ -23,9 +27,9 @@ if ($^O eq 'MSWin32') {
# Windows has extra lines because exec() is emulated by fork().
my $rn_count = () = $citrun_log =~ /\r\n/g;
- is( $rn_count, 15, 'is \r\n count correct' );
+ is( $rn_count, 15, '\r\n count correct' );
}
else {
my $n_count = () = $citrun_log =~ /\n/g;
- is( $n_count, 14, 'is \n count correct' );
+ is( $n_count, 14, '\n count correct' );
}
diff --git a/t/inst_macro.t b/t/inst_macro.t
@@ -3,8 +3,12 @@
# end of binary operators.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -49,9 +53,10 @@ my $inst_out;
$inst->read(\$inst_out, 'macro.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_millis.t b/t/inst_millis.t
@@ -3,8 +3,8 @@
# Do the opposite here and make sure it's there.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::More tests => 3;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -18,6 +18,7 @@ EOF
$inst->run( args => '-c main.c', chdir => $inst->curdir );
-like( $inst->stdout, qr/Milliseconds spent rewriting/, 'is milliseconds in citrun.log' );
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+my $o = 'Milliseconds spent rewriting';
+like( $inst->stdout, qr/$o/, 'milliseconds is in citrun.log' );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_nosrc.t b/t/inst_nosrc.t
@@ -2,8 +2,12 @@
# Check that giving citrun_inst a non existent file is handled.
#
use Modern::Perl;
-use t::utils;
-plan tests => 2;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 2;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -18,8 +22,7 @@ EOF
$inst->run( args => '-c doesnt_exist.c', chdir => $inst->curdir );
-my $out = clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $out, $out_good, 'is citrun_inst output identical' );
-
+my $out = utils::clean_citrun_log(scalar $inst->stdout);
+eq_or_diff( $out, $out_good, 'citrun_inst output identical' );
print $inst->stderr;
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_path.t b/t/inst_path.t
@@ -4,9 +4,12 @@
# - not having CITRUN_PATH set when using transparent compile mode errors
#
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
-plan tests => 4;
+use lib 't';
+require utils;
my $compiler = 'share/cc';
@@ -31,4 +34,5 @@ PATH = ''
Error: '' not in PATH.
EOF
-eq_or_diff( clean_citrun_log( $log_out ), $log_good, 'is citrun.log identical' );
+eq_or_diff( utils::clean_citrun_log( $log_out ), $log_good,
+ 'is citrun.log identical' );
diff --git a/t/inst_preamble.t b/t/inst_preamble.t
@@ -2,8 +2,9 @@
# Test that the instrumentation preamble is what we think it is.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -84,6 +85,7 @@ my $preamble;
$inst->read( \$preamble, "empty.c.preamble" );
$preamble =~ s/".*"/""/gm;
-eq_or_diff( $preamble, $preamble_good, 'is preamble identical', { context => 3 } );
-is( $inst->stderr, '', 'is citrun_inst stderr empty' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $preamble, $preamble_good, 'is preamble identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr empty' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_preprocess.t b/t/inst_preprocess.t
@@ -2,8 +2,12 @@
# Make sure preprocessor flags -E, -MM cause no instrumentation to be done.
#
use Modern::Perl;
-use t::utils;
-plan tests => 8;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 8;
+
+use lib 't';
+require utils;
my $preproc = 'int main(void) { return 0; }';
@@ -26,12 +30,12 @@ my $inst_out;
$inst->read(\$inst_out, 'prepro.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $preproc, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical';
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $preproc, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical' );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
# Test -MM
$check_good = <<EOF ;
@@ -47,9 +51,10 @@ $inst->run( args => '-MM prepro.c', chdir => $inst->curdir );
$inst->read(\$inst_out, 'prepro.c');
# Sanitize paths from stdout.
-$check_out = clean_citrun_log(scalar $inst->stdout);
+$check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $preproc, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $preproc, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_return.t b/t/inst_return.t
@@ -2,8 +2,12 @@
# Check that return statement values (if any) are instrumented correctly.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -60,9 +64,10 @@ my $inst_out;
$inst->read(\$inst_out, 'return.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 };
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_srcext.t b/t/inst_srcext.t
@@ -2,8 +2,12 @@
# Check that the advertised source file extensions work.
#
use Modern::Perl;
-use t::utils;
-plan tests => 15;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 15;
+
+use lib 't';
+require utils;
my @supported_exts = ("c", "cc", "cxx", "cpp");
@@ -28,10 +32,11 @@ for (@supported_exts) {
$inst->write( "main.$_", 'int main(void) { return 0; }' );
$inst->run( args => "-c main.$_", chdir => $inst->curdir );
- my $out = clean_citrun_log(scalar $inst->stdout);
- eq_or_diff( $out, $out_good, ".$_: is citrun_inst output identical", { context => 3} );
- is ( $inst->stderr, '', ".$_: is citrun_inst stderr silent" );
- is( $? >> 8, 0, ".$_: is citrun_inst exit code 0" );
+ my $out = utils::clean_citrun_log(scalar $inst->stdout);
+ eq_or_diff( $out, $out_good, ".$_ citrun_inst output identical",
+ { context => 3} );
+ is ( $inst->stderr, '', ".$_ citrun_inst stderr silent" );
+ is( $? >> 8, 0, ".$_ citrun_inst exit code 0" );
}
$out_good = <<EOF;
@@ -45,7 +50,8 @@ EOF
$inst->write( "main.z", 'int main(void) { return 0; }' );
$inst->run( args => "-c main.z", chdir => $inst->curdir );
-my $out = clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $out, $out_good, ".z: is citrun_inst output identical", { context => 3 } );
-is ( $inst->stderr, '', ".z: is citrun_inst stderr silent" );
-is( $? >> 8, 0, ".z: is citrun_inst exit code 1" );
+my $out = utils::clean_citrun_log(scalar $inst->stdout);
+eq_or_diff( $out, $out_good, ".z citrun_inst output identical",
+ { context => 3 } );
+is ( $inst->stderr, '', ".z citrun_inst stderr silent" );
+is( $? >> 8, 0, ".z citrun_inst exit code 1" );
diff --git a/t/inst_switch.t b/t/inst_switch.t
@@ -2,8 +2,12 @@
# Make sure that switch statement condition instrumentation works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -63,9 +67,10 @@ my $inst_out;
$inst->read(\$inst_out, 'switch.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 } ;
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/inst_two_src.t b/t/inst_two_src.t
@@ -3,8 +3,12 @@
# instrumented fully.
#
use Modern::Perl;
-use t::utils;
-plan tests => 3;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 3;
+
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -16,7 +20,8 @@ int other(void) {
}
EOF
-$wrap->run( args => os_compiler() . 'main main.c other.c', chdir => $wrap->curdir );
+$wrap->run( args => utils::os_compiler() . 'main main.c other.c',
+ chdir => $wrap->curdir );
my $log_good = <<EOF;
>> citrun_inst
@@ -47,9 +52,9 @@ EOF
my $citrun_log;
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log($citrun_log);
+$citrun_log = utils::clean_citrun_log($citrun_log);
-eq_or_diff( $citrun_log, $log_good, 'is citrun.log identical', { context => 3 } );
+eq_or_diff( $citrun_log, $log_good, 'citrun.log identical', { context => 3 } );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap exit code 0' );
diff --git a/t/inst_while.t b/t/inst_while.t
@@ -2,8 +2,12 @@
# Make sure that while loop condition instrumentation works.
#
use Modern::Perl;
-use t::utils;
-plan tests => 4;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 4;
+
+use lib 't';
+require utils;
my $inst = Test::Cmd->new( prog => 'inst/citrun_inst', workdir => '' );
@@ -52,9 +56,10 @@ my $inst_out;
$inst->read(\$inst_out, 'while.c');
# Sanitize paths from stdout.
-my $check_out = clean_citrun_log(scalar $inst->stdout);
+my $check_out = utils::clean_citrun_log(scalar $inst->stdout);
-eq_or_diff( $inst_out, $inst_good, 'is instrumented file identical', { context => 3 } );
-eq_or_diff $check_out, $check_good, 'is citrun_inst output identical', { context => 3 } ;
-is( $inst->stderr, '', 'is citrun_inst stderr silent' );
-is( $? >> 8, 0, 'is citrun_inst exit code 0' );
+eq_or_diff( $inst_out, $inst_good, 'inst file identical', { context => 3 } );
+eq_or_diff( $check_out, $check_good, 'citrun_inst output identical',
+ { context => 3 } );
+is( $inst->stderr, '', 'citrun_inst stderr silent' );
+is( $? >> 8, 0, 'citrun_inst exit code 0' );
diff --git a/t/lib_badver.t b/t/lib_badver.t
@@ -3,9 +3,11 @@
# another errors.
#
use Modern::Perl;
-use t::utils; # os_compiler()
+use Test::Cmd;
+use Test::More tests => 5;
-plan tests => 5;
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -22,10 +24,11 @@ main(int argc, char *argv[])
}
EOF
-$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
-# is( $wrap->stdout, '', 'is compiler stdout silent' );
-is( $wrap->stderr, '', 'is citrun_wrap stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap exit code 0' );
+$wrap->run( args => utils::os_compiler() . 'main main.c',
+ chdir => $wrap->curdir );
+# is( $wrap->stdout, '', 'compiler stdout silent' );
+is( $wrap->stderr, '', 'citrun_wrap stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap exit code 0' );
my $err_good = 'libcitrun 0.0: incompatible version 0.255.
Try cleaning and rebuilding your project.';
@@ -33,7 +36,7 @@ Try cleaning and rebuilding your project.';
my $abs_prog_path = File::Spec->catfile( $wrap->workdir, "main" );
$wrap->run( prog => $abs_prog_path, chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is node program stdout silent' );
-like( $wrap->stderr, qr/$err_good/, 'is node program stderr identical' );
-isnt( $? >> 8, 0, 'is node program exit code nonzero' );
+is( $wrap->stdout, '', 'node program stdout silent' );
+like( $wrap->stderr, qr/$err_good/, 'node program stderr good' );
+isnt( $? >> 8, 0, 'node program exit code nonzero' );
unlink "/tmp/citrun.out";
diff --git a/t/lib_deadcount.t b/t/lib_deadcount.t
@@ -3,19 +3,24 @@
# counts.
#
use Modern::Perl;
-use t::mem;
-use t::utils;
-plan tests => 8;
+use Test::Cmd;
+use Test::Differences;
+use Test::More tests => 8;
+use lib 't';
+require mem;
+require utils;
-my $dir = setup_projdir();
-$dir->run( prog => $dir->workdir . '/program', args => '10', chdir => $dir->curdir );
+my $dir = utils::setup_projdir();
+
+$dir->run( prog => $dir->workdir . '/program', args => '10',
+ chdir => $dir->curdir );
is( $dir->stdout, '55', 'inst program stdout correct' );
isnt( $dir->stderr, '', 'inst program stderr not silent' );
is( $? >> 8, 0, 'inst program exit code 0' );
-my $shm = t::mem->new();
+my $shm = mem->new();
my %tus = %{ $shm->{trans_units} };
my ($tu1, $tu2, $tu3) = sort keys %tus;
@@ -72,6 +77,7 @@ my @print_good = qw(
0
);
-eq_or_diff( $shm->get_buffers($tu1), \@fib_good, 'is fib count identical', { context => 3 } );
-eq_or_diff( $shm->get_buffers($tu2), \@main_good, 'is main count identical', { context => 3 } );
-eq_or_diff( $shm->get_buffers($tu3), \@print_good, 'is print count identical', { context => 3 } );
+my $ctx = { context => 3 };
+eq_or_diff( $shm->get_buffers($tu1), \@fib_good, 'fib count identical', $ctx );
+eq_or_diff( $shm->get_buffers($tu2), \@main_good, 'main count identical', $ctx );
+eq_or_diff( $shm->get_buffers($tu3), \@print_good, 'print count identical', $ctx );
diff --git a/t/lib_header.t b/t/lib_header.t
@@ -2,42 +2,45 @@
# Test that the shared memory header is what we expect.
#
use Modern::Perl;
-use t::mem;
-use t::utils;
-plan tests => 18;
+use Test::Cmd;
+use Test::More tests => 18;
+use lib 't';
+require mem;
+require utils;
-my $dir = setup_projdir();
+
+my $dir = utils::setup_projdir();
$dir->run( prog => $dir->workdir . '/program', args => '1', chdir => $dir->curdir );
-is( $dir->stdout, '1', 'is instrumented program stdout correct' );
-isnt( $dir->stderr, '', 'is instrumented program stderr not empty' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
+is( $dir->stdout, '1', 'inst program stdout correct' );
+isnt( $dir->stderr, '', 'inst program stderr not empty' );
+is( $? >> 8, 0, 'inst program exit code 0' );
-my $shm = t::mem->new();
+my $shm = mem->new();
-is( $shm->{magic}, 'ctrn', 'is file magic correct' );
-is( $shm->{major}, 0, 'is major 0' );
-is( $shm->{minor}, 0, 'is minor 0' );
-is( $shm->{units}, 3, 'is 3 translation units' );
-is( $shm->{loc}, 42, 'is 42 lines of code' );
+is( $shm->{magic}, 'ctrn', 'file magic correct' );
+is( $shm->{major}, 0, 'major 0' );
+is( $shm->{minor}, 0, 'minor 0' );
+is( $shm->{units}, 3, '3 translation units' );
+is( $shm->{loc}, 42, '42 lines of code' );
my ($pid, $ppid, $pgrp) = @{ $shm->{pids} };
-cmp_ok( $pid, '<', 100 * 1000, 'is pid < max pid' );
-cmp_ok( $pid, '>', 1, 'is pid > min pid' );
+cmp_ok( $pid, '<', 100 * 1000, 'pid < max pid' );
+cmp_ok( $pid, '>', 1, 'pid > min pid' );
SKIP: {
skip 'win32 has no ppid or pgrp', 4 if ($^O eq "MSWin32");
- cmp_ok( $ppid, '<', 100 * 1000, 'is ppid < max pid' );
- cmp_ok( $ppid, '>', 1, 'is ppid > min pid' );
- cmp_ok( $pgrp, '<', 100 * 1000, 'is pgrp < max pid' );
- cmp_ok( $pgrp, '>', 1, 'is pgrp > min pid' );
+ cmp_ok( $ppid, '<', 100 * 1000, 'ppid < max pid' );
+ cmp_ok( $ppid, '>', 1, 'ppid > min pid' );
+ cmp_ok( $pgrp, '<', 100 * 1000, 'pgrp < max pid' );
+ cmp_ok( $pgrp, '>', 1, 'pgrp > min pid' );
}
my $tmp_dir = $dir->workdir;
# Regex doesn't like single '\'s, so replace each with two.
$tmp_dir =~ s/\\/\\\\/g;
-like( $shm->{cwd}, qr/.*$tmp_dir/, 'is working directory believable' );
-like( $shm->{progname}, qr/program/, 'is test program name correct' );
+like( $shm->{cwd}, qr/.*$tmp_dir/, 'working directory believable' );
+like( $shm->{progname}, qr/program/, 'test program name correct' );
diff --git a/t/lib_livecount.t b/t/lib_livecount.t
@@ -3,12 +3,14 @@
#
use Modern::Perl;
use Time::HiRes qw( time usleep );
-use t::mem;
-use t::utils;
-plan tests => 23;
+use Test::More tests => 23;
+use lib 't';
+require mem;
+require utils;
-my $dir = setup_projdir();
+
+my $dir = utils::setup_projdir();
my $child_pid = fork();
if ($child_pid == 0) {
@@ -17,7 +19,7 @@ if ($child_pid == 0) {
}
usleep 500 * 1000;
-my $shm = t::mem->new();
+my $shm = mem->new();
my %trans_units = %{ $shm->{trans_units} };
@@ -31,7 +33,7 @@ for (0..20) {
$total += $_ for (@$execs);
}
- cmp_ok $total, '>', $last_total, "is total line count increasing";
+ cmp_ok( $total, '>', $last_total, "total line count increasing" );
$last_total = $total;
}
diff --git a/t/lib_size.t b/t/lib_size.t
@@ -2,19 +2,21 @@
# Test that the runtime shared file size is what we expect.
#
use Modern::Perl;
-use t::mem;
-use t::utils;
+use Test::More tests => 6;
-plan tests => 6;
+use lib 't';
+require mem;
+require utils;
-my $dir = setup_projdir();
+my $dir = utils::setup_projdir();
-$dir->run( prog => $dir->workdir . "/program", args => '1', chdir => $dir->curdir );
-is( $dir->stdout, '1', 'is instrumented program stdout correct' );
-isnt( $dir->stderr, '', 'is instrumented program stderr not silent' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
+$dir->run( prog => $dir->workdir . "/program", args => '1',
+ chdir => $dir->curdir );
+is( $dir->stdout, '1', 'inst program stdout correct' );
+isnt( $dir->stderr, '', 'inst program stderr not silent' );
+is( $? >> 8, 0, 'inst program exit code 0' );
-my $procfile = t::mem->new();
+my $procfile = mem->new();
-is( $procfile->{size}, $t::mem::os_allocsize * 4, 'is file 4 allocation units' );
+is( $procfile->{size}, $mem::os_allocsize * 4, 'file has correct size' );
diff --git a/t/lib_transunit.t b/t/lib_transunit.t
@@ -2,31 +2,34 @@
# Test that the shared memory translation units are what we expect.
#
use Modern::Perl;
-use t::mem;
-use t::utils;
-plan tests => 14;
+use Test::More tests => 14;
+use lib 't';
+require mem;
+require utils;
-my $dir = setup_projdir();
-$dir->run( prog => $dir->workdir . '/program', args => '1', chdir => $dir->curdir );
-is( $dir->stdout, '1', 'is instrumented program stdout correct' );
-isnt( $dir->stderr, '', 'is instrumented program stderr not silent' );
-is( $? >> 8, 0, "is instrumented program exit code 0" );
+my $dir = utils::setup_projdir();
-my $shm = t::mem->new();
+$dir->run( prog => $dir->workdir . '/program', args => '1',
+ chdir => $dir->curdir );
+is( $dir->stdout, '1', 'inst program stdout correct' );
+isnt( $dir->stderr, '', 'inst program stderr not silent' );
+is( $? >> 8, 0, 'inst program exit code 0' );
+
+my $shm = mem->new();
my %tus = %{ $shm->{trans_units} };
my ($tu1, $tu2, $tu3) = sort keys %tus;
-like( $tu1, qr/.*fib.c/, 'is end of absolute file path fib.c' );
-is( $tus{$tu1}->{size}, 11, "is fib.c the correct length" );
-is( $tus{$tu1}->{comp_file_name}, 'fib.c', 'is compiler file name right' );
+like( $tu1, qr/.*fib.c/, 'end of absolute file path fib.c' );
+is( $tus{$tu1}->{size}, 11, "fib.c the correct length" );
+is( $tus{$tu1}->{comp_file_name}, 'fib.c', 'compiler file name right' );
-like( $tu2, qr/.*main.c/, 'is end of absolute file path main.c' );
-is( $tus{$tu2}->{size}, 22, "is main.c the correct length" );
-is( $tus{$tu2}->{comp_file_name}, 'main.c', 'is compiler file name main.c' );
+like( $tu2, qr/.*main.c/, 'end of absolute file path main.c' );
+is( $tus{$tu2}->{size}, 22, "main.c the correct length" );
+is( $tus{$tu2}->{comp_file_name}, 'main.c', 'compiler file name main.c' );
-like( $tu3, qr/.*print.c/, 'is end of absolute file path print.c' );
-is( $tus{$tu3}->{size}, 9, "is print.c the correct length" );
-is( $tus{$tu3}->{comp_file_name}, 'print.c', 'is compiler file name print.c' );
+like( $tu3, qr/.*print.c/, 'end of absolute file path print.c' );
+is( $tus{$tu3}->{size}, 9, "print.c the correct length" );
+is( $tus{$tu3}->{comp_file_name}, 'print.c', 'compiler file name print.c' );
diff --git a/t/lib_viewer.t b/t/lib_viewer.t
@@ -6,33 +6,37 @@
# 2) citrun_gl on the PATH
#
use Modern::Perl;
-use t::utils; # os_compiler()
+use Test::Cmd;
+use Test::More tests => 8;
-plan tests => 8;
+use lib 't';
+require utils;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
# Write and compile bare minimum source file.
$wrap->write( 'main.c', 'int main(void) { return 0; }' );
-$wrap->run( args => os_compiler() . 'main main.c', chdir => $wrap->curdir );
+$wrap->run( args => utils::os_compiler() . 'main main.c',
+ chdir => $wrap->curdir );
# Don't check stdout.
-is( $wrap->stderr, '', 'is wrapped compile stderr silent' );
-is( $? >> 8, 0, 'is wrapped compile exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap compile stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap compile exit code 0' );
#
# Case 1.
#
-my $inst_prog = Test::Cmd->new( prog => $wrap->workdir . "/main", workdir => '' );
+my $inst_prog = Test::Cmd->new( prog => $wrap->workdir . "/main",
+ workdir => '' );
my $err_good = 'libcitrun: exec citrun_gl: No such file or directory';
$inst_prog->run( chdir => $inst_prog->curdir );
-is( $inst_prog->stdout, '', 'is case 1 stdout silent' );
-like( $inst_prog->stderr, qr/$err_good/, 'is case 1 stderr an error' );
-is( $? >> 8, 0, 'is case 1 exit code 0' );
+is( $inst_prog->stdout, '', 'case 1 stdout silent' );
+like( $inst_prog->stderr, qr/$err_good/, 'case 1 stderr an error' );
+is( $? >> 8, 0, 'case 1 exit code 0' );
unlink "/tmp/citrun.out";
#
@@ -43,13 +47,16 @@ $inst_prog->write( 'citrun_gl', <<EOF );
#!/bin/sh
echo ran citrun_gl
EOF
-
chmod(0775, $inst_prog->workdir . '/citrun_gl') or die $!;
$ENV{PATH} .= ".:";
$inst_prog->run( chdir => $wrap->curdir );
-like( $inst_prog->stdout, qr/ran citrun_gl/, 'is case 2 viewer started' );
-is( $inst_prog->stderr, '', 'is case 2 stderr empty' );
-is( $? >> 8, 0, 'is case 2 exit code zero' );
+
+# citrun_gl gets forked so we must wait for it to finish.
+sleep(1);
+
+like( $inst_prog->stdout, qr/ran citrun_gl/, 'case 2 viewer started' );
+is( $inst_prog->stderr, '', 'case 2 stderr empty' );
+is( $? >> 8, 0, 'case 2 exit code zero' );
unlink "/tmp/citrun.out";
diff --git a/t/mem.pm b/t/mem.pm
@@ -1,10 +1,10 @@
-package t::mem;
+package mem;
-use Inline 'C';
+use Inline C;
use Modern::Perl;
use POSIX;
-use if $^O eq 'MSWin32', 't::mem_win32';
-use if $^O ne 'MSWin32', 't::mem_unix';
+use if $^O eq 'MSWin32', 'mem_win32';
+use if $^O ne 'MSWin32', 'mem_unix';
use autodie;
sub new {
@@ -13,9 +13,11 @@ sub new {
my $self = {};
bless($self, $class);
+ Inline->init();
+
get_mem( $self );
- # These functions proved by C code at the end of this file.
+ # These functions provided by C at the end of this file.
my $header_size = citrun_header_size();
my $node_fixed_size = citrun_node_size();
@@ -56,7 +58,7 @@ sub new {
sub get_aligned_size {
my ($unaligned_size) = @_;
- my $page_mask = $t::mem::os_allocsize - 1;
+ my $page_mask = $mem::os_allocsize - 1;
return ($unaligned_size + $page_mask) & ~$page_mask;
}
@@ -75,10 +77,12 @@ __DATA__
__C__
#include "../include/citrun.h"
-size_t citrun_header_size() {
+size_t
+citrun_header_size() {
return sizeof(struct citrun_header);
}
-size_t citrun_node_size() {
+size_t
+citrun_node_size() {
return sizeof(struct citrun_node);
}
diff --git a/t/mem_unix.pm b/t/mem_unix.pm
@@ -1,4 +1,4 @@
-package t::mem;
+package mem;
use Modern::Perl;
use POSIX;
diff --git a/t/report.t b/t/report.t
@@ -3,10 +3,8 @@
#
use Modern::Perl;
use Test::Cmd;
-use Test::More;
-
-plan skip_all => 'citrun_report missing on win32' if ($^O eq "MSWin32");
-plan tests => 12;
+use Test::More tests => 12;
+#plan skip_all => 'citrun_report missing on win32' if ($^O eq "MSWin32");
my $report = Test::Cmd->new( prog => 'bin/citrun_report', workdir => '' );
@@ -14,45 +12,45 @@ my $report = Test::Cmd->new( prog => 'bin/citrun_report', workdir => '' );
#
# Test when a nonexistent file argument is given.
#
-my $error_good = "awk: can't open file _nonexistent_";
+my $e = "awk: can't open file _nonexistent_";
$report->run( args => '_nonexistent_', chdir => $report->curdir );
-is( $report->stdout, '', 'is nonexistent file stdout silent' );
-like( $report->stderr, qr/$error_good/, 'is nonexistent file stderr identical' );
-is( $? >> 8, 2, 'is nonexistent file exit code nonzero' );
+is( $report->stdout, '', 'nonexistent file stdout silent' );
+like( $report->stderr, qr/$e/, 'nonexistent file stderr identical' );
+is( $? >> 8, 2, 'nonexistent file exit code nonzero' );
#
# Verify output when an empty file is processed.
#
-my $output_good = "No signs of rewrite activity.";
+my $o = "No signs of rewrite activity.";
$report->write( 'empty_file.log', '' );
$report->run( args => 'empty_file.log', chdir => $report->curdir );
-like( $report->stdout, qr/$output_good/, 'is empty file stdout expected' );
-is( $report->stderr, '', 'is empty file stderr silent' );
-is( $? >> 8, 1, 'is empty file exit code nonzero' );
+like( $report->stdout, qr/$o/, 'empty file stdout expected' );
+is( $report->stderr, '', 'empty file stderr silent' );
+is( $? >> 8, 1, 'empty file exit code nonzero' );
#
# Test when an existent file only has a header line.
#
-$output_good = 'Summary:
+$o = 'Summary:
1 Rewrite tool runs';
$report->write( 'header_only.log', '>> citrun_inst');
$report->run( args => 'header_only.log', chdir => $report->curdir );
-like( $report->stdout, qr/$output_good/, 'is header only stdout expected' );
-is( $report->stderr, '', 'is header only stderr silent' );
-is( $? >> 8, 0, 'is header only exit code zero' );
+like( $report->stdout, qr/$o/, 'header only stdout expected' );
+is( $report->stderr, '', 'header only stderr silent' );
+is( $? >> 8, 0, 'header only exit code zero' );
#
# Test a log file path with spaces.
#
-$output_good = "No signs of rewrite activity.";
+$o = "No signs of rewrite activity.";
mkdir File::Spec->catdir( $report->workdir, 'dir a' );
$report->write( [ 'dir a', 'citrun.log' ], '' );
$report->run( args => 'dir\ a/citrun.log', chdir => $report->curdir );
-like( $report->stdout, qr/$output_good/, 'is path with spaces stdout identical' );
-is( $report->stderr, '', 'is path with spaces stderr silent' );
-is( $? >> 8, 1, 'is path with spaces exit code nonzero' );
+like( $report->stdout, qr/$o/, 'path with spaces stdout identical' );
+is( $report->stderr, '', 'path with spaces stderr silent' );
+is( $? >> 8, 1, 'path with spaces exit code nonzero' );
diff --git a/t/src_trailingspace.t b/t/src_trailingspace.t
@@ -2,10 +2,17 @@
# Test that source files have no trailing whitespace.
#
use Modern::Perl;
-use Test::More tests => 1;
-use Test::TrailingSpace;
+use Test::More;
+# Test is optional.
+eval "use Test::TrailingSpace";
+if ($@) {
+ plan skip_all => "Test::TrailingSpace not found.";
+} else {
+ plan tests => 1;
+}
+
my $finder = Test::TrailingSpace->new(
{
root => '.',
@@ -13,5 +20,4 @@ my $finder = Test::TrailingSpace->new(
},
);
-# Run test.
-$finder->no_trailing_space("is no trailing spaces in source");
+$finder->no_trailing_space("no trailing spaces in source");
diff --git a/t/utils.pm b/t/utils.pm
@@ -1,14 +1,11 @@
-use Modern::Perl;
+package utils;
+
use Test::Cmd;
-use Test::Differences;
use Test::More;
-
use autodie;
-unified_diff; # For Test::Differences diffs
-
# Common message seen while testing lib.
-our $err_gl = 'libcitrun: exec citrun_gl: No such file or directory';
+our $err_gl = "libcitrun: exec citrun_gl: No such file or directory\n";
sub os_compiler {
if ($^O eq 'MSWin32') {
@@ -90,8 +87,8 @@ EOF
$wrap->run( args => 'make', chdir => $wrap->curdir );
print $wrap->stdout;
- is( $wrap->stderr, '', 'is citrun_wrap make stderr empty' );
- is( $? >> 8, 0, 'is citrun_wrap make exit code 0' );
+ is( $wrap->stderr, '', 'setup_projdir() make stderr empty' );
+ is( $? >> 8, 0, 'setup_projdir() make exit code 0' );
return $wrap;
}
diff --git a/t/wrap_badarg.t b/t/wrap_badarg.t
@@ -7,15 +7,15 @@ use Test::More tests => 3;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
-$wrap->run( args => '-ASD', chdir => $wrap->curdir );
-my $err_good;
+my $e;
if ($^O eq "MSWin32") {
- $err_good = "'-ASD' is not recognized as an internal or external command";
+ $e = "'-ASD' is not recognized as an internal or external command";
} else {
- $err_good = '-ASD: not found';
+ $e = '-ASD: not found';
}
-is( $wrap->stdout, '', 'is citrun_wrap stdout silent' );
-like( $wrap->stderr, qr/$err_good/, 'is citrun_wrap stderr looking good' );
-isnt( $? >> 8, 0, 'is citrun_wrap exit code nonzero' );
+$wrap->run( args => '-ASD', chdir => $wrap->curdir );
+is( $wrap->stdout, '', 'citrun_wrap stdout silent' );
+like( $wrap->stderr, qr/$e/, 'citrun_wrap stderr an error' );
+isnt( $? >> 8, 0, 'citrun_wrap exit code nonzero' );
diff --git a/t/wrap_cmake.t b/t/wrap_cmake.t
@@ -3,11 +3,16 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
plan skip_all => 'cmake not found' unless (which 'cmake');
plan tests => 8;
+use lib 't';
+require utils;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -54,8 +59,8 @@ EOF
$wrap->run( args => 'cmake .', chdir => $wrap->curdir );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap cmake stderr empty');
-is( $? >> 8, 0, 'is citrun_wrap cmake exit code 0');
+is( $wrap->stderr, '', 'citrun_wrap cmake stderr empty');
+is( $? >> 8, 0, 'citrun_wrap cmake exit code 0');
# Now run whatever platform specific-ish files CMake decided to give us.
if ($^O eq "MSWin32") {
@@ -67,18 +72,18 @@ if ($^O eq "MSWin32") {
my $log_out;
$wrap->read( \$log_out, 'citrun.log' );
-$log_out = clean_citrun_log($log_out);
+$log_out = utils::clean_citrun_log($log_out);
-eq_or_diff( $log_out, $log_good, 'is citrun.log identical', { context => 3 } );
+eq_or_diff( $log_out, $log_good, 'citrun.log identical', { context => 3 } );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap make stderr empty');
-is( $? >> 8, 0, 'is citrun_wrap make exit code 0');
+is( $wrap->stderr, '', 'citrun_wrap make stderr empty');
+is( $? >> 8, 0, 'citrun_wrap make exit code 0');
# Check the instrumented program runs.
$wrap->run( prog => $wrap->workdir . "/program", chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is instrumented program stdout empty');
-isnt( $wrap->stderr, '', 'is instrumented program stderr not empty');
-is( $? >> 8, 0, 'is instrumented program exit code 0');
+is( $wrap->stdout, '', 'instrumented program stdout empty');
+isnt( $wrap->stderr, '', 'instrumented program stderr not empty');
+is( $? >> 8, 0, 'instrumented program exit code 0');
unlink "/tmp/citrun.out";
#ok "is runtime shared memory file created" test -f procdir/program_*
diff --git a/t/wrap_devenv.t b/t/wrap_devenv.t
@@ -3,7 +3,8 @@
# TODO: devenv uses response files (not supported right now).
#
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::More;
if ($^O eq "MSWin32") {
plan tests => 3;
@@ -11,6 +12,10 @@ if ($^O eq "MSWin32") {
plan skip_all => 'win32 only';
}
+use lib 't';
+require utils;
+
+
my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );
$wrap->write( 'main.vcxproj', <<'EOF' );
diff --git a/t/wrap_exitcode.t b/t/wrap_exitcode.t
@@ -8,16 +8,16 @@ use Test::More tests => 3;
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
-my $err_good;
+my $e;
if ($^O eq "MSWin32") {
$wrap->run( args => 'more.com asdf' );
- $err_good = 'Cannot access file .*asdf';
+ $e = 'Cannot access file .*asdf';
}
else {
$wrap->run( args => 'ls asdf' );
- $err_good = "ls: asdf: No such file or directory";
+ $e = "ls: asdf: No such file or directory";
}
-is( $wrap->stdout, '', 'is citrun_wrap stdout empty');
-like( $wrap->stderr, qr/$err_good/, 'is citrun_wrap stderr identical');
-is( $? >> 8, 1, 'is citrun_wrap exit code 1');
+is( $wrap->stdout, '', 'citrun_wrap stdout empty');
+like( $wrap->stderr, qr/$e/, 'citrun_wrap stderr identical');
+is( $? >> 8, 1, 'citrun_wrap exit code 1');
diff --git a/t/wrap_jam.t b/t/wrap_jam.t
@@ -3,11 +3,16 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
plan skip_all => 'jam not found' unless (which 'jam');
plan tests => 6;
+use lib 't';
+require utils;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -18,8 +23,8 @@ EOF
$wrap->run( args => 'jam', chdir => $wrap->curdir );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap jam stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap jam exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap jam stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap jam exit code 0' );
my $citrun_log;
my $log_good = <<EOF;
@@ -55,12 +60,13 @@ EOF
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log( $citrun_log );
+$citrun_log = utils::clean_citrun_log( $citrun_log );
-eq_or_diff( $citrun_log, $log_good, 'is citrun_wrap log file identical', { context => 3 } );
+eq_or_diff( $citrun_log, $log_good, 'citrun_wrap log file identical',
+ { context => 3 } );
$wrap->run( prog => $wrap->workdir . '/program', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is instrumented program stdout silent' );
-is( $wrap->stderr, '', 'is instrumented program stderr silent' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
+is( $wrap->stdout, '', 'inst program stdout silent' );
+isnt( $wrap->stderr, '', 'inst program stderr silent' );
+is( $? >> 8, 0, 'inst program exit code 0' );
unlink "/tmp/citrun.out";
diff --git a/t/wrap_make.t b/t/wrap_make.t
@@ -3,11 +3,16 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
plan skip_all => 'make not found' unless (which 'make');
plan tests => 6;
+use lib 't';
+require utils;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -19,8 +24,8 @@ EOF
$wrap->run( args => 'make', chdir => $wrap->curdir );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap make stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap make exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap make stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap make exit code 0' );
my $citrun_log;
my $log_good = <<EOF;
@@ -48,12 +53,13 @@ No source files found on command line.
EOF
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log( $citrun_log );
+$citrun_log = utils::clean_citrun_log( $citrun_log );
-eq_or_diff( $citrun_log, $log_good, 'is citrun_wrap log file identical', { context => 3 } );
+eq_or_diff( $citrun_log, $log_good, 'citrun_wrap log file identical',
+ { context => 3 } );
$wrap->run( prog => $wrap->workdir . '/program', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is instrumented program stdout silent' );
-isnt( $wrap->stderr, '', 'is instrumented program stderr not silent' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
+is( $wrap->stdout, '', 'instr program stdout silent' );
+isnt( $wrap->stderr, '', 'instr program stderr not silent' );
+is( $? >> 8, 0, 'instr program exit code 0' );
unlink "/tmp/citrun.out";
diff --git a/t/wrap_ninja.t b/t/wrap_ninja.t
@@ -3,11 +3,16 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
plan skip_all => 'ninja not found' unless (which 'ninja');
plan tests => 6;
+use lib 't';
+require utils;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
@@ -54,12 +59,13 @@ No source files found on command line.
EOF
$wrap->read( \$citrun_log, 'citrun.log' );
-$citrun_log = clean_citrun_log( $citrun_log );
+$citrun_log = utils::clean_citrun_log( $citrun_log );
-eq_or_diff( $citrun_log, $log_good, 'is citrun_wrap log file identical', { context => 3 } );
+eq_or_diff( $citrun_log, $log_good, 'citrun_wrap log file identical',
+ { context => 3 } );
$wrap->run( prog => $wrap->workdir . '/program', chdir => $wrap->curdir );
-is( $wrap->stdout, '', 'is instrumented program stdout silent' );
-isnt( $wrap->stderr, '', 'is instrumented program stderr not silent' );
-is( $? >> 8, 0, 'is instrumented program exit code 0' );
+is( $wrap->stdout, '', 'instr program stdout silent' );
+isnt( $wrap->stderr, '', 'instr program stderr not silent' );
+is( $? >> 8, 0, 'instr program exit code 0' );
unlink "/tmp/citrun.out";
diff --git a/t/wrap_nmake.t b/t/wrap_nmake.t
@@ -1,9 +1,13 @@
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::More;
plan skip_all => 'win32 only' if ($^O ne "MSWin32");
plan tests => 6;
+use lib 't';
+require utils;
+
my $wrap = Test::Cmd->new( prog => 'bin/citrun_wrap', workdir => '' );
diff --git a/t/wrap_parallel.t b/t/wrap_parallel.t
@@ -4,7 +4,9 @@
#
use File::Which;
use Modern::Perl;
-use t::utils;
+use Test::Cmd;
+use Test::Differences;
+use Test::More;
plan skip_all => 'make not found' unless (which 'make');
plan tests => 15;
@@ -31,8 +33,8 @@ EOF
$wrap->run( args => 'make -j4', chdir => $wrap->curdir );
print $wrap->stdout;
-is( $wrap->stderr, '', 'is citrun_wrap make stderr silent' );
-is( $? >> 8, 0, 'is citrun_wrap make exit code 0' );
+is( $wrap->stderr, '', 'citrun_wrap make stderr silent' );
+is( $? >> 8, 0, 'citrun_wrap make exit code 0' );
my $report_good = <<EOF;
Summary:
@@ -52,12 +54,14 @@ $wrap->run( prog => 'bin/citrun_report', args => 'citrun.log',
chdir => $wrap->curdir );
my $report_out = $wrap->stdout;
$report_out =~ s/^.*Milliseconds spent rewriting.*\n//gm;
-eq_or_diff( $report_out, $report_good, 'is citrun_report stdout identical', { context => 3 } );
+eq_or_diff( $report_out, $report_good, 'citrun_report stdout identical',
+ { context => 3 } );
for (1..4) {
- $wrap->run( prog => $wrap->workdir . "/program$_", chdir => $wrap->curdir );
- is( $wrap->stdout, '', "is instrumented program$_ stdout silent" );
- isnt( $wrap->stderr, '', "is instrumented program$_ stderr not silent" );
- is( $? >> 8, 0, "is instrumented program$_ exit code 0" );
+ $wrap->run( prog => $wrap->workdir . "/program$_",
+ chdir => $wrap->curdir );
+ is( $wrap->stdout, '', "inst program$_ stdout silent" );
+ isnt( $wrap->stderr, '', "inst program$_ stderr not silent" );
+ is( $? >> 8, 0, "inst program$_ exit code 0" );
unlink "/tmp/citrun.out";
}
diff --git a/t/www.t b/t/www.t
@@ -1,15 +1,33 @@
#
# Test live website has correct html and no broken links.
#
+use Lingua::EN::Fathom;
use Modern::Perl;
-use Test::More skip_all => 'utf8 index false positive';
+use Test::More skip_all => 'website is down';
use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new;
-$mech->get_ok("http://cit.run");
-# $mech->base_is("http://cit.run");
+$mech->get_ok("http://cit.run", [ charset => 'utf-8' ]);
+
+$mech->base_is("http://cit.run");
$mech->title_is("C It Run", "title is 'C It Run'");
-$mech->html_lint_ok("is html correct");
+$mech->text_like(qr/C It Run lets you watch code execute/);
+#$mech->html_lint_ok("is html correct");
$mech->page_links_ok("is no broken links");
+
+my $www_content = $mech->content( format => 'text' );
+
+# Check readability of text.
+my $www_text = Lingua::EN::Fathom->new();
+$www_text->analyse_block($www_content, 0);
+print STDERR $www_text->report;
+
+# Check aliases.
+$mech->get_ok("http://citrun.com", [ charset => 'utf-8' ]);
+$mech->base_is("http://citrun.com");
+$mech->title_is("C It Run", "title is 'C It Run'");
+$mech->text_like(qr/C It Run lets you watch code execute/);
+
+$mech->get_ok("http://www.cit.run", [ charset => 'utf-8' ]);