Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding in compilation tests to ensure all perl modules compile #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ build-test-script:
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_DEPLOYMENT_CONFIG=$$script_dir/../deploy.cfg' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_AUTH_TOKEN=`cat /kb/module/work/token`' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export PERL5LIB=$$script_dir/../$(LIB_DIR):$$PATH:$$PERL5LIB' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export PERL5LIB=$$script_dir/../$(LIB_DIR):$$PERL5LIB' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$PATH contains the paths of various executables, but no paths to perl libraries.

echo 'cd $$script_dir/..' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'echo "running test scripts!"' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'prove -lvrm $(TEST_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'prove -lvm --ext pl $(TEST_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'echo "running perl .t tests"' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'prove -I $(TEST_DIR)/lib -lvrm -j9 $(TEST_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'echo "running .pl tests"' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'prove -I $(TEST_DIR)/lib -lvm --ext pl $(TEST_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
chmod +x $(TEST_DIR)/$(TEST_SCRIPT_NAME)

deploy-mfatoolkit:
Expand Down
24 changes: 12 additions & 12 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
requires 'Config::IniFiles';
requires 'Cpanel::JSON::XS';
requires 'Data::Dumper::Concise';
requires 'Devel::Cover';
requires 'JSON::MaybeXS';
requires 'Path::Tiny';
requires 'Ref::Util';
requires 'Template::Plugin::JSON';
requires 'Template';
requires 'Test::Most';
requires 'Test::Output';
requires 'Try::Tiny';
requires 'Cpanel::JSON::XS', '>= 4.19';
requires 'Data::Dumper::Concise', '>= 2.023';
requires 'JSON::MaybeXS', '>= 1.004000';
requires 'Path::Tiny', '>= 0.112';
requires 'Ref::Util', '>= 0.204';
requires 'Template::Plugin::JSON', '>= 0.08';
requires 'Template', '>= 2.26';
requires 'Term::ANSIColor', '>= 5.00';
requires 'Test::Most', '>= 0.35';
requires 'Test::Output', '>= 1.031';
requires 'Test::Compile', '>= 2.3.1';
requires 'Try::Tiny', '>= 0.30';
35 changes: 0 additions & 35 deletions lib/Bio/KBase/ObjectAPI/KBaseFBA/BooleanGeneExpressionData.pm

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions test/00_test_compile.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use Test::Most;
use Test::Compile;
use KBaseTestContext;

my $base_dir = KBaseTestContext->base_dir();
my $test = Test::Compile->new();

# check all .pm and .pl files compile
$test->all_files_ok( $base_dir );

# check the test files are also OK
my @all_t_files = all_t_files( $test, $base_dir );
for ( @all_t_files ) {
ok $test->pl_file_compiles( $_ ), $_ . ' compiles';
}

$test->done_testing();

sub all_t_files {
my ( $test, @dirs ) = @_;

@dirs = @dirs ? @dirs : ( $base_dir );

my @t_files;
for my $file ( $test->_find_files( @dirs ) ) {
push @t_files, $file if $file =~ /\.t$/;
}
return @t_files;
}
28 changes: 20 additions & 8 deletions test/bio_kbase_templater.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ subtest 'populate_template' => sub {
{ thing => 'world' },
), 'valid output, includes template vars, output to STDOUT';
};
my @content = map { s/(^\s*|\s*$)//g; $_ } grep { /\S/ } split /[\n\r]/, $stdout;

my @content = parse_template_string( $stdout );
cmp_deeply
\@content,
[ "Hello world", "G'day sport!" ],
Expand All @@ -55,8 +56,7 @@ subtest 'populate_template' => sub {
\$string
), 'valid output, no template vars, saved to scalar ref';


@content = map { s/(^\s*|\s*$)//g; $_ } grep { /\S/ } split /[\n\r]/, $string;
@content = parse_template_string( $string );
cmp_deeply
\@content,
[ "Hello", "G'day sport!" ],
Expand All @@ -73,7 +73,7 @@ subtest 'populate_template' => sub {
\$string
), 'valid output, includes template vars, saved to scalar ref';

@content = map { s/(^\s*|\s*$)//g; $_ } grep { /\S/ } split /[\n\r]/, $string;
@content = parse_template_string( $string );
cmp_deeply
\@content,
[ "Hello world", "G'day sport!" ],
Expand All @@ -90,10 +90,7 @@ subtest 'populate_template' => sub {
$temp_file->stringify,
), 'valid output, includes template vars, saved to a file';

@content = map { s/(^\s*|\s*$)//g; $_ }
grep { /\S/ }
split /[\n\r]/, $temp_file->slurp_utf8;

@content = parse_template_string( $temp_file->slurp_utf8 );
cmp_deeply
\@content,
[ "Hello world", "G'day sport!" ],
Expand All @@ -106,4 +103,19 @@ subtest 'populate_template' => sub {

};

sub parse_template_string {
my ( $template_string ) = @_;

return
# remove leading and trailing whitespace
map { my $line = $_;
$line =~ s/(^\s*|\s*$)//g;
$line;
}
# ensure the line has non-whitespace content
grep { /\S/ }
# split on any line break type
split /[\n\r]+/, $template_string;
}

done_testing;
Loading