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

Individual test directories for programs #166

Merged
merged 21 commits into from Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
397 changes: 382 additions & 15 deletions MANIFEST

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bin/ar
Expand Up @@ -7,6 +7,8 @@ Description: create and maintain library archives
Author: dkulp
License: perl

=end metadata

=cut

use POSIX qw(strftime);
Expand All @@ -18,9 +20,6 @@ if ($ARGV[0] !~ /^\-/) { $ARGV[0] = '-' . $ARGV[0]; }

require "getopts.pl";
Getopts("dmpqrtxabciouv");
=end metadata

=cut

# take only one of the following major opts
if (($opt_d + $opt_m + $opt_p + $opt_q + $opt_r + $opt_t + $opt_x) != 1) {
Expand Down
2 changes: 1 addition & 1 deletion bin/awk
Expand Up @@ -17,7 +17,7 @@ License: perl

use strict;

BEGIN {
SANITY: {
my $external_module = 'App::a2p';
my $rc = eval "require $external_module; $external_module->import; 1";
die "This program needs the $external_module module.\n" unless $rc;
Expand Down
2 changes: 1 addition & 1 deletion bin/date
Expand Up @@ -346,7 +346,7 @@ please open an issue: L<https://github.com/briandfoy/PerlPowerTools/issues>.
If you look in the C<date> file, you'll see a simple text list at the end
that we use for Windows.

=se back
=back

=cut

Expand Down
4 changes: 2 additions & 2 deletions bin/mimedecode
Expand Up @@ -14,14 +14,14 @@ License:
use v5.12.0;
use Getopt::Std;

BEGIN {
SANITY: {
my $external_module = 'MIME::Parser';
my $rc = eval "require $external_module; $external_module->import; 1";
die "This program needs the $external_module module.\n" unless $rc;
}

{package PerlPowerTools::MIME::Parser;
use base 'MIME::Parser';
push @INC, 'MIME::Parser'; # this is old school so -c doesn't complain

sub new_body_for
{
Expand Down
11 changes: 11 additions & 0 deletions bin/perlpowertools
Expand Up @@ -2,6 +2,17 @@
#
# perlpowertools - helper script for PerlPowerTools

=begin metadata

Name: perlpowertools
Description: a program launcher for Perl Power Tools
Author: kal247, https://github.com/kal247
License: artistic2

=end metadata

=cut

use strict;
use warnings;
use utf8;
Expand Down
29 changes: 29 additions & 0 deletions t/000.basic.t
@@ -0,0 +1,29 @@
use Test::More 1;

use File::Basename;
use File::Spec::Functions;

my @programs =
map { basename($_) }
grep { ! /\.bat\z/ }
glob( 'blib/script/*' );

my @expected_test_files =
map { basename($_) }
glob( catfile( qw(util test_templates *.t) ) );

foreach my $program ( @programs ) {
test_dir($program);
}

done_testing();

sub test_dir {
my( $program ) = @_;
ok -d catfile( 't', $program ), "t/$program is a directory";

foreach my $t_file ( @expected_test_files ) {
ok -e catfile( 't', $program, $t_file ), "Found test file $t_file";
}
}

10 changes: 10 additions & 0 deletions t/addbib/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/addbib/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/addbib/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();
10 changes: 10 additions & 0 deletions t/apply/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/apply/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/apply/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();
10 changes: 10 additions & 0 deletions t/ar/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/ar/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/ar/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();
10 changes: 10 additions & 0 deletions t/arch/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/arch/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/arch/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();
10 changes: 10 additions & 0 deletions t/arithmetic/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/arithmetic/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/arithmetic/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();
10 changes: 10 additions & 0 deletions t/asa/000.basic.t
@@ -0,0 +1,10 @@
use strict;
use warnings;

use Test::More;

require './t/lib/common.pl';

sanity_test();

done_testing();
25 changes: 25 additions & 0 deletions t/asa/910.meta.t
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;

use JSON qw(decode_json);
use Test::More;

require './t/lib/common.pl';

my $program = program_name();
ok -e $program, "$program exists";

my $output = `"$^X" util/extract_metadata $program`;
my $json = decode_json( $output );

subtest "required keys" => sub {
my $this = $json->{$program};
my @keys = qw(Name Description Author License);

ok( exists $this->{$_}, "has $_ key" ) for @keys;
};

done_testing();

__END__
10 changes: 10 additions & 0 deletions t/asa/990.pod.t
@@ -0,0 +1,10 @@
#!/usr/bin/perl

use Test::Pod;

require './t/lib/common.pl';
my $program = program_name(__FILE__);

pod_file_ok( $program, "Valid POD in <$program>" );

done_testing();