From 7bb6a1ddab10e9f61b4ad80955b4400c137aecf1 Mon Sep 17 00:00:00 2001 From: jaywhy Date: Thu, 28 Sep 2006 01:58:34 +0000 Subject: [PATCH] Adding a few tests. git-svn-id: svn://192.168.202.10@311 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/branches/agc_30/t/00-load.t | 7 ++ agc_2-X/branches/agc_30/t/01-dependencies.t | 73 +++++++++++++++++++++ agc_2-X/branches/agc_30/t/02-database.t | 8 +++ agc_2-X/branches/agc_30/t/03-config.t | 9 +++ 4 files changed, 97 insertions(+) create mode 100644 agc_2-X/branches/agc_30/t/00-load.t create mode 100644 agc_2-X/branches/agc_30/t/01-dependencies.t create mode 100644 agc_2-X/branches/agc_30/t/02-database.t create mode 100644 agc_2-X/branches/agc_30/t/03-config.t diff --git a/agc_2-X/branches/agc_30/t/00-load.t b/agc_2-X/branches/agc_30/t/00-load.t new file mode 100644 index 00000000..c90b2409 --- /dev/null +++ b/agc_2-X/branches/agc_30/t/00-load.t @@ -0,0 +1,7 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More tests => 2; + +use_ok("Astguiclient"); +use_ok("Astguiclient::Daemon::AGI"); diff --git a/agc_2-X/branches/agc_30/t/01-dependencies.t b/agc_2-X/branches/agc_30/t/01-dependencies.t new file mode 100644 index 00000000..d4c239e3 --- /dev/null +++ b/agc_2-X/branches/agc_30/t/01-dependencies.t @@ -0,0 +1,73 @@ +#!/usr/bin/env perl + +use warnings; +use strict; + +=head1 DESCRIPTION + +Makes sure that all of the modules that are 'use'd are listed in the +Makefile.PL as dependencies. + +=cut + +use Test::More qw(no_plan); +use File::Find; +use Module::CoreList; + +my %used; +find( \&wanted, qw/ lib bin t /); + +sub wanted { + return unless -f $_; + return if $File::Find::dir =~ m!/.svn($|/)!; + return if $File::Find::name =~ /~$/; + return if $File::Find::name =~ /\.pod$/; + + # read in the file from disk + my $filename = $_; + local $/; + open(FILE, $filename) or return; + my $data = ; + close(FILE); + + # strip pod, in a really idiotic way. Good enough though + $data =~ s/^=head.+?(^=cut|\Z)//gms; + + # look for use and use base statements + $used{$1}{$filename}++ while $data =~ /^\s*use\s+([\w:]+)/gm; + while ($data =~ m|^\s*use base qw.([\w\s:]+)|gm) { + $used{$_}{$filename}++ for split ' ', $1; + } +} + +my %required; +{ + local $/; + ok(open(MAKEFILE,"Makefile.PL"), "Opened Makefile"); + my $data = ; + close(FILE); + while ($data =~ /^\s*?(?:requires|recommends)\('([\w:]+)'(?:\s*=>\s*['"]?([\d\.]+)['"]?)?.*?(?:#(.*))?$/gm) { + $required{$1} = $2; + if (defined $3 and length $3) { + $required{$_} = undef for split ' ', $3; + } + } +} + +for (sort keys %used) { + my $first_in = Module::CoreList->first_release($_); + next if defined $first_in and $first_in <= 5.00803; + next if /^(Jifty|Jifty::DBI|inc|t|TestApp|Application)(::|$)/; + ok(exists $required{$_}, "$_ in Makefile.PL") + or diag("used in ", join ", ", sort keys %{ $used{$_ } }); + delete $used{$_}; + delete $required{$_}; +} + +for (sort keys %required) { + my $first_in = Module::CoreList->first_release($_, $required{$_}); + fail("Required module $_ is already in core") if defined $first_in and $first_in <= 5.00803; +} + +1; + diff --git a/agc_2-X/branches/agc_30/t/02-database.t b/agc_2-X/branches/agc_30/t/02-database.t new file mode 100644 index 00000000..e858aa9b --- /dev/null +++ b/agc_2-X/branches/agc_30/t/02-database.t @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More test => 2; + +use_ok('Astguiclient'); +my $a = Astguiclient->new(); +ok($a->dbi->ping); diff --git a/agc_2-X/branches/agc_30/t/03-config.t b/agc_2-X/branches/agc_30/t/03-config.t new file mode 100644 index 00000000..b81b993d --- /dev/null +++ b/agc_2-X/branches/agc_30/t/03-config.t @@ -0,0 +1,9 @@ +#!/usr/bin/perl -w + +use strict; +use Test::More tests => 3; + +use_ok('Astguiclient'); +my $a = Astguiclient->new(); +ok($a->config->file) +ok($a->config->server);