commit c9c9d395529302f551732d7cc6551ce42a4a6831
parent 9fe28b247d419250c7787237900de785c50b3148
Author: Kyle Milz <kyle@0x30.net>
Date: Tue, 19 Sep 2017 01:09:11 -0600
bin: change citrun_check to pure awk script
- combine 3 existing tests plus 1 new one into report.t
Diffstat:
7 files changed, 70 insertions(+), 84 deletions(-)
diff --git a/bin/Jamfile b/bin/Jamfile
@@ -8,21 +8,18 @@ actions ShellReplace {
#
# citrun_check
+#
+SHELLHEADER = "#!/usr/bin/awk -f" ;
+MakeLocate citrun_check : bin ;
+Shell citrun_check : check.awk ;
+
+#
# citrun_wrap
#
-if $(NT) {
- File citrun_wrap.bat : wrap.bat ;
- Clean clean : citrun_wrap.bat ;
-}
-else {
- MakeLocate citrun_check : bin ;
- Shell citrun_check : check.sh ;
-
- MakeLocate citrun_wrap : bin ;
- Depends all : citrun_wrap ;
- Clean clean : citrun_wrap ;
- ShellReplace citrun_wrap : wrap.sh ;
-}
+MakeLocate citrun_wrap : bin ;
+Depends all : citrun_wrap ;
+Clean clean : citrun_wrap ;
+ShellReplace citrun_wrap : wrap.sh ;
#
# citrun_inst
diff --git a/bin/check.sh b/bin/check.awk
diff --git a/t/check_baddir.t b/t/check_baddir.t
@@ -1,23 +0,0 @@
-#
-# Verify that passing a bad directory to citrun_check errors out.
-#
-use Modern::Perl;
-use Test::Cmd;
-use Test::More;
-
-plan skip_all => 'not impl on win32' if ($^O eq "MSWin32");
-plan tests => 3;
-
-
-my $output_good = "Summary:
- 0 Source files used as input
-";
-my $error_good = "find: _nonexistent_: No such file or directory
-";
-
-my $check = Test::Cmd->new( prog => 'bin/citrun_check', workdir => '' );
-$check->run( args => '_nonexistent_', chdir => $check->curdir );
-
-is( $check->stdout, $output_good, 'is citrun_check stdout identical' );
-is( $check->stderr, $error_good, 'is citrun_check stderr identical' );
-is( $? >> 8, 123, 'is citrun_check exit code 123' );
diff --git a/t/check_empty.t b/t/check_empty.t
@@ -1,21 +0,0 @@
-#
-# Verify the output when 0 citrun.log files are found.
-#
-use Modern::Perl;
-use Test::Cmd;
-use Test::More;
-
-plan skip_all => 'not impl' if ($^O eq "MSWin32");
-plan tests => 3;
-
-
-my $output_good = "Summary:
- 0 Source files used as input
-";
-
-my $check = Test::Cmd->new( prog => 'bin/citrun_check', workdir => '' );
-$check->run( chdir => $check->curdir );
-
-is( $check->stdout, $output_good, 'is citrun_check stdout identical' );
-is( $check->stderr, '', 'is citrun_check stderr empty' );
-is( $? >> 8, 123, 'is citrun_check exit code 123' );
diff --git a/t/check_spaces.t b/t/check_spaces.t
@@ -1,26 +0,0 @@
-#
-# Verify citrun_check can handle paths with spaces when counting log files.
-#
-use Modern::Perl;
-use Test::Cmd;
-use Test::More;
-
-plan skip_all => 'not impl on win32' if ($^O eq "MSWin32");
-plan tests => 3;
-
-
-my $output_good = "Summary:
- 0 Source files used as input
-";
-
-my $check = Test::Cmd->new( prog => 'bin/citrun_check', workdir => '' );
-
-mkdir File::Spec->catdir( $check->workdir, 'dir a' );
-mkdir File::Spec->catdir( $check->workdir, 'dir b' );
-$check->write( [ 'dir a', 'citrun.log' ], '' );
-$check->write( [ 'dir b', 'citrun.log' ], '' );
-
-$check->run( args => '', chdir => $check->curdir );
-is( $check->stdout, $output_good, 'is citrun_check stdout identical' );
-is( $check->stderr, '', 'is citrun_check stderr identical' );
-is( $? >> 8, 123, 'is citrun_check exit code 123' );
diff --git a/t/report.t b/t/report.t
@@ -0,0 +1,58 @@
+#
+# Verify behaviour of citrun_report script. There's a few cases here.
+#
+use Modern::Perl;
+use Test::Cmd;
+use Test::More;
+
+plan skip_all => 'citrun_check missing on win32' if ($^O eq "MSWin32");
+plan tests => 12;
+
+
+my $check = Test::Cmd->new( prog => 'bin/citrun_check', workdir => '' );
+
+#
+# Test when a nonexistent file argument is given.
+#
+my $error_good = "awk: can't open file _nonexistent_";
+$check->run( args => '_nonexistent_', chdir => $check->curdir );
+
+is( $check->stdout, '', 'is nonexistent file stdout silent' );
+like( $check->stderr, qr/$error_good/, 'is nonexistent file stderr identical' );
+is( $? >> 8, 2, 'is nonexistent file exit code nonzero' );
+
+#
+# Verify output when an empty file is processed.
+#
+my $output_good = "No signs of rewrite activity.";
+$check->write( 'empty_file.log', '' );
+$check->run( args => 'empty_file.log', chdir => $check->curdir );
+
+like( $check->stdout, qr/$output_good/, 'is empty file stdout expected' );
+is( $check->stderr, '', 'is empty file stderr silent' );
+is( $? >> 8, 1, 'is empty file exit code nonzero' );
+
+#
+# Test when an existent file only has a header line.
+#
+$output_good = 'Summary:
+ 1 Rewrite tool runs';
+$check->write( 'header_only.log', '>> citrun_inst');
+$check->run( args => 'header_only.log', chdir => $check->curdir );
+
+like( $check->stdout, qr/$output_good/, 'is header only stdout expected' );
+is( $check->stderr, '', 'is header only stderr silent' );
+is( $? >> 8, 0, 'is header only exit code zero' );
+
+#
+# Test a log file path with spaces.
+#
+$output_good = "No signs of rewrite activity.";
+
+mkdir File::Spec->catdir( $check->workdir, 'dir a' );
+$check->write( [ 'dir a', 'citrun.log' ], '' );
+
+$check->run( args => 'dir\ a/citrun.log', chdir => $check->curdir );
+like( $check->stdout, qr/$output_good/, 'is path with spaces stdout identical' );
+is( $check->stderr, '', 'is path with spaces stderr silent' );
+is( $? >> 8, 1, 'is path with spaces exit code nonzero' );
diff --git a/t/wrap_parallel.t b/t/wrap_parallel.t
@@ -36,6 +36,7 @@ is( $? >> 8, 0, 'is citrun_wrap make exit code 0' );
my $check_good = <<EOF;
Summary:
+ 8 Rewrite tool runs
4 Source files used as input
4 Application link commands
4 Successful modified source compiles
@@ -47,7 +48,7 @@ Totals:
12 Total statements
EOF
-$wrap->run( prog => 'bin/citrun_check', chdir => $wrap->curdir );
+$wrap->run( prog => 'bin/citrun_check', args => 'citrun.log', chdir => $wrap->curdir );
my $check_out = $wrap->stdout;
$check_out =~ s/^.*Milliseconds spent rewriting.*\n//gm;
eq_or_diff( $check_out, $check_good, 'is citrun_check stdout identical', { context => 3 } );