Skip to content

Commit

Permalink
Added t/tabs.t
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Feb 8, 2024
1 parent 008d3eb commit 91dfc4f
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 34 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for CGI-Info
0.81
Use Test::Needs
Added t/version.t
Added t/tabs.t

0.80 Fri Jan 19 08:05:29 EST 2024
Added documentroot() as a synonym to rootdir()
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ t/script.t
t/site.t
t/status.t
t/strict.t
t/tabs.t
t/taint.t
t/tmpdir.t
t/untaint.t
Expand Down
7 changes: 3 additions & 4 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ WriteMakefile(
AUTHOR => q{Nigel Horne <njh@bandsman.co.uk>},
VERSION_FROM => 'lib/CGI/Info.pm',
ABSTRACT_FROM => 'lib/CGI/Info.pm',
((defined($ExtUtils::MakeMaker::VERSION) &&
($ExtUtils::MakeMaker::VERSION >= 6.3002))
? ('LICENSE'=> 'GPL')
: ()),
((defined($ExtUtils::MakeMaker::VERSION) && ($ExtUtils::MakeMaker::VERSION >= 6.3002))
? ('LICENSE'=> 'GPL')
: ()),
'LIBS' => [''], # e.g., '-lm'
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
'INC' => '', # e.g., '-I/usr/include/other'
Expand Down
2 changes: 1 addition & 1 deletion bin/info.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"Cookies:\n";

foreach my $cookie(split (/; /, $ENV{'HTTP_COOKIE'})) {
my ($key, $value) = split(/=/, $cookie);
my ($key, $value) = split(/=/, $cookie);

print "Cookie $key:\n";
my $c = $info->get_cookie(cookie_name => $key);
Expand Down
5 changes: 2 additions & 3 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ sub _find_paths {
}
$self->{script_path} = File::Spec->catfile($ENV{'DOCUMENT_ROOT' }, $script_name);
} elsif($ENV{'SCRIPT_NAME'} && !$ENV{'DOCUMENT_ROOT'}) {
if(File::Spec->file_name_is_absolute($ENV{'SCRIPT_NAME'}) &&
(-r $ENV{'SCRIPT_NAME'})) {
if(File::Spec->file_name_is_absolute($ENV{'SCRIPT_NAME'}) && (-r $ENV{'SCRIPT_NAME'})) {
# Called from a command line with a full path
$self->{script_path} = $ENV{'SCRIPT_NAME'};
} else {
Expand Down Expand Up @@ -1370,7 +1369,7 @@ Is the visitor a real person or a robot?
my $info = CGI::Info->new();
unless($info->is_robot()) {
# update site visitor statistics
# update site visitor statistics
}
=cut
Expand Down
4 changes: 2 additions & 2 deletions t/is_mobile.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN {
}

MOBILE: {
delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_USER_AGENT'};

my $i = new_ok('CGI::Info');
Expand All @@ -22,7 +22,7 @@ MOBILE: {
ok($i->is_mobile() == 1);
ok($i->browser_type eq 'mobile');

delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_X_WAP_PROFILE'};
$ENV{'HTTP_SEC_CH_UA_MOBILE'} = '?0';
$i = new_ok('CGI::Info');
cmp_ok($i->is_mobile(), '==', 0, 'CH_UA_MOBILE = 0 => !mobile');
Expand Down
4 changes: 2 additions & 2 deletions t/is_tablet.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN {
}

PATHS: {
delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_USER_AGENT'};

my $i = new_ok('CGI::Info');
Expand All @@ -20,7 +20,7 @@ PATHS: {
$i = new_ok('CGI::Info');
ok($i->is_tablet() == 0);

delete $ENV{'HTTP_X_WAP_PROFILE'};
delete $ENV{'HTTP_X_WAP_PROFILE'};
$ENV{'HTTP_USER_AGENT'} = 'Mozilla/5.0 (iPhone; U)';
$i = new_ok('CGI::Info');
ok($i->is_tablet() == 0);
Expand Down
4 changes: 2 additions & 2 deletions t/pod-coverage.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ if($ENV{'AUTHOR_TESTING'}) {
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan(skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage")
if $@;
if $@;

# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan(skip_all => "Pod::Coverage $min_pc required for testing POD coverage")
if $@;
if $@;

all_pod_coverage_ok();
} else {
Expand Down
17 changes: 6 additions & 11 deletions t/pod-snippets.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
use strict;
use warnings;
use Test::Most;
use Test::Needs 'Test::Pod::Snippets';

if($ENV{AUTHOR_TESTING}) {
eval 'use Test::Pod::Snippets';
if($ENV{'AUTHOR_TESTING'}) {
my @modules = qw/ CGI::Info /;
Test::Pod::Snippets->import();
Test::Pod::Snippets->new()->runtest(module => $_, testgroup => 1) for @modules;

if($@) {
plan(skip_all => 'Test::Pod::Snippets required for testing POD code snippets');
} else {
my @modules = qw/ CGI::Info /;

Test::Pod::Snippets->new()->runtest(module => $_, testgroup => 1) for @modules;

done_testing();
}
done_testing();
} else {
plan(skip_all => 'Author tests not required for installation');
}
2 changes: 1 addition & 1 deletion t/protocol.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PROTOCOL: {
ok($i->protocol() eq 'https');

$ENV{'SERVER_PORT'} = 443;
delete $ENV{'SCRIPT_URI'};
delete $ENV{'SCRIPT_URI'};
$i = new_ok('CGI::Info');
ok($i->protocol() eq 'https');
ok(CGI::Info->protocol() eq 'https');
Expand Down
10 changes: 5 additions & 5 deletions t/script.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ BEGIN {
}

PATHS: {
delete $ENV{'SCRIPT_NAME'};
delete $ENV{'SCRIPT_NAME'};
delete $ENV{'DOCUMENT_ROOT'};
delete $ENV{'SCRIPT_FILENAME'};
delete $ENV{'SCRIPT_FILENAME'};

my $i = new_ok('CGI::Info');
ok(File::Spec->file_name_is_absolute($i->script_path()));
Expand Down Expand Up @@ -74,7 +74,7 @@ PATHS: {

$ENV{'DOCUMENT_ROOT'} = '/path/to';
$ENV{'SCRIPT_NAME'} = '/cgi-bin/bar.pl';
delete $ENV{'SCRIPT_FILENAME'};
delete $ENV{'SCRIPT_FILENAME'};

$i = new_ok('CGI::Info');
ok($i->script_name() eq 'bar.pl');
Expand All @@ -87,9 +87,9 @@ PATHS: {
ok($i->script_path() eq '/path/to/cgi-bin/bar.pl');
}

delete $ENV{'DOCUMENT_ROOT'};
delete $ENV{'DOCUMENT_ROOT'};
$ENV{'SCRIPT_NAME'} = '/cgi-bin/bar.pl';
delete $ENV{'SCRIPT_FILENAME'};
delete $ENV{'SCRIPT_FILENAME'};

$i = new_ok('CGI::Info');
ok($i->script_name() eq 'bar.pl');
Expand Down
6 changes: 3 additions & 3 deletions t/site.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ BEGIN {
}

HOSTNAMES: {
delete $ENV{'HTTP_HOST'};
delete $ENV{'SERVER_NAME'};
delete $ENV{'HTTP_HOST'};
delete $ENV{'SERVER_NAME'};
$ENV{'SERVER_PORT'} = 80;

my $i = new_ok('CGI::Info' => [ logger => MyLogger->new() ]);
Expand Down Expand Up @@ -53,7 +53,7 @@ HOSTNAMES: {
# Check rereading returns the same value
ok($i->domain_name() eq 'example.com');

delete $ENV{'HTTP_HOST'};
delete $ENV{'HTTP_HOST'};
delete $ENV{'SCRIPT_URI'};
$ENV{'SERVER_NAME'} = 'www.bandsman.co.uk';

Expand Down
16 changes: 16 additions & 0 deletions t/tabs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::Needs 'Test::Tabs';
use Test::Most;

BEGIN {
if($ENV{'AUTHOR_TESTING'}) {
Test::Tabs->import();
all_perl_files_ok();
done_testing();
} else {
plan(skip_all => 'Author tests not required for installation');
}
}

0 comments on commit 91dfc4f

Please sign in to comment.