use strict; use warnings; use Test::More tests => 2; #'no_plan'; use Test::Exception; use Test::Builder; use Test::Directory; use File::Temp qw( tempfile tempdir ); use File::Basename; use File::Path; my $builder = Test::More->builder->output('results.txt'); # Call the perl script under test note "Check perl script under test loaded OK"; ok( require( '../apg-problem-perl.pl' ), 'loaded file okay' ) or exit; note "\nTest function: get_files_in_watched_directory"; subtest 'get_files_in_watched_directory' => sub { my @got_files; my @expected_files; my $project_name = 'default'; # create a temporary directory my $temp_dir = tempdir( CLEANUP => 1 ); # create some temporary files in the directory my ($temp_file1_handle, $temp_file1) = tempfile(DIR => $temp_dir); my ($temp_file2_handle, $temp_file2) = tempfile(DIR => $temp_dir); # create an array populated with the names of the temporary files that we expectd to see push (@expected_files, basename($temp_file1)); push (@expected_files, basename($temp_file2)); # now pass the temporary directory to the the function # the function should return an array @got_files with the names of the files in the directory @got_files = get_files_in_watched_directory($temp_dir, $project_name); message_log ("\n\nGOT", "high"); foreach my $this_file (sort @got_files) { message_log ("\n $this_file", "high"); } message_log ("\n\nEXPECTED", "high"); foreach my $this_file (sort @expected_files) { message_log ("\n $this_file", "high"); } #compare the two arrays is_deeply(\@got_files, \@expected_files, 'Function should return a list of directory contents that will be processed'); }; done_testing();