commit 3b874c6a270f53a5f417291325fccb9ae873b423
parent 9ea21819be6bb8465c6a55f9d67bd6576d19935e
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Thu, 5 Jan 2017 19:52:51 -0800
t: stop using DosGlob
Diffstat:
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/t/lib_header.t b/t/lib_header.t
@@ -3,19 +3,17 @@
#
use strict;
use warnings;
-use File::DosGlob 'glob';
use t::utils;
-plan tests => 18;
+plan tests => 17;
my $dir = setup_projdir();
$dir->run( prog => $dir->workdir . '/program', args => '1', chdir => $dir->curdir );
is( $? >> 8, 0, "is instrumented program exit code 0" );
-my @procfiles = glob("$ENV{CITRUN_PROCDIR}/program_*");
-is scalar @procfiles, 1, "is one file in procdir";
+my $shm_file_path = get_one_shmfile( $ENV{CITRUN_PROCDIR} );
+my $shm = t::shm->new( $shm_file_path );
-my $shm = t::shm->new($procfiles[0]);
is $shm->{magic}, "ctrn", "is correct file magic";
is $shm->{major}, 0, "is correct major";
is $shm->{minor}, 0, "is correct minor";
diff --git a/t/lib_size.t b/t/lib_size.t
@@ -3,10 +3,9 @@
#
use strict;
use warnings;
-use File::DosGlob 'glob';
use POSIX;
use t::utils;
-plan tests => 5;
+plan tests => 4;
my $dir = setup_projdir();
@@ -14,10 +13,8 @@ my $dir = setup_projdir();
$dir->run( prog => $dir->workdir . "/program", args => '1', chdir => $dir->curdir );
is( $? >> 8, 0, "is instrumented program exit code 0" );
-my @procfiles = glob("$ENV{CITRUN_PROCDIR}/program_*");
-is scalar @procfiles, 1, "is one file in procdir";
-
-my $procfile = t::shm->new($procfiles[0]);
+my $shm_file_path = get_one_shmfile( $ENV{CITRUN_PROCDIR} );
+my $procfile = t::shm->new( $shm_file_path );
my $alloc_size;
if ($^O eq "MSWin32") {
diff --git a/t/utils.pm b/t/utils.pm
@@ -18,6 +18,23 @@ sub clean_citrun_log {
return $log;
}
+sub get_one_shmfile {
+ my ($dir) = @_;
+ opendir( DIR, $dir ) or die $!;
+
+ my @files;
+ for (readdir(DIR)) {
+ next if ($_ eq ".");
+ next if ($_ eq "..");
+ push @files, ($_);
+ }
+
+ closedir(DIR);
+ die "not exactly one procfile found" if (scalar @files != 1);
+
+ return File::Spec->catfile( $dir, $files[0] );
+}
+
sub setup_projdir {
my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' );