From: Darren Chamberlain Date: Fri, 21 Feb 2003 15:19:04 +0000 (+0000) Subject: Added new files to MANIFEST. X-Git-Tag: v0.01~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=44fb27aece97f4478b2df60c377c72f423da499a;p=dbsrgits%2FSQL-Translator.git Added new files to MANIFEST. Started updating tests to use Test::More, rather than the homegrown print stuff I'd started with (bad darren!). The load test uses SQL::Translator::load, to both exercise load() and to perform the actual test (I've intentionally used load instead of Test::More::use_ok). Added more dependencies to Makefile.PL. Sorted the dependencies in PREREQ_PM, and the file list in MANIFEST, because I'm obsessive about those sorts of silly things. --- diff --git a/MANIFEST b/MANIFEST index 04d6002..8fee62d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,22 +1,25 @@ -bin/sql_translator.pl -bin/validator_test.pl BUGS Changes -lib/SQL/Translator/Parser/MySQL.pm +MANIFEST +MANIFEST.SKIP +Makefile.PL +TODO +bin/auto-dia.pl +bin/sql_translator.pl +bin/validator_test.pl +lib/SQL/Translator.pm lib/SQL/Translator/Parser.pm +lib/SQL/Translator/Parser/MySQL.pm +lib/SQL/Translator/Parser/PostGreSQL.pm lib/SQL/Translator/Parser/Sybase.pm lib/SQL/Translator/Parser/xSV.pm -lib/SQL/Translator.pm +lib/SQL/Translator/Producer.pm lib/SQL/Translator/Producer/MySQL.pm lib/SQL/Translator/Producer/Oracle.pm -lib/SQL/Translator/Producer.pm lib/SQL/Translator/Producer/PostgreSQL.pm -lib/SQL/Translator/Producer/XML.pm lib/SQL/Translator/Producer/Raw.pm +lib/SQL/Translator/Producer/XML.pm lib/SQL/Translator/Validator.pm -Makefile.PL -MANIFEST -MANIFEST.SKIP t/01load.t t/02mysql-parser.t t/03mysql-to-oracle.t @@ -26,4 +29,3 @@ t/06xsv.t t/07p_args.t t/data/mysql/Apache-Session-MySQL.sql t/data/mysql/BGEP-RE-create.sql -TODO diff --git a/Makefile.PL b/Makefile.PL index 4daf93d..8e5e8de 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,7 +2,6 @@ package SQL::Translator; use strict; use ExtUtils::MakeMaker; -use Config; WriteMakefile( 'NAME' => __PACKAGE__, @@ -11,10 +10,14 @@ WriteMakefile( 'bin/sql_translator.pl', ], 'PREREQ_PM' => { + 'Class::Base' => 0, + 'File::Basename' => 0, + 'File::Spec' => 0, + 'IO::Dir' => 0, 'Parse::RecDescent' => 0, # Is a particular version needed? - 'XML::Dumper' => 0, 'Pod::Usage' => 0, - 'Class::Base' => 0, + 'Text::ParseWords' => 0, + 'XML::Dumper' => 0, }, clean => { FILES => '$(DISTNAME)-$(VERSION).tar.gz', diff --git a/t/01load.t b/t/01load.t index cc47a99..e6378aa 100644 --- a/t/01load.t +++ b/t/01load.t @@ -6,31 +6,30 @@ # my @perlmods; -my $count = 0; + +use Test::More; +use SQL::Translator; unless (open MANIFH, "MANIFEST") { - print "1..1\n"; - print "not ok 1\n"; + plan skip_all => "Can't open MANIFEST! ($!)"; exit; } + while () { chomp; if (s/\.pm$//) { s,/,::,g; - s/^lib:://; push @perlmods, $_ } } -print "1.." . scalar @perlmods . "\n"; - close MANIFH; +@perlmods = sort { length $a <=> length $b } @perlmods; # aesthetics +plan tests => scalar @perlmods; + for my $mod (@perlmods) { - $count++; - $mod =~ s,/,::,g; - eval "use $mod;"; - print "not " if ($@); - print "ok $count # $mod\n"; + SQL::Translator::load($mod); + ok(!$@, "use $mod"); } diff --git a/t/02mysql-parser.t b/t/02mysql-parser.t index 956508e..ddfd4de 100644 --- a/t/02mysql-parser.t +++ b/t/02mysql-parser.t @@ -8,58 +8,50 @@ # use strict; + +use Test::More tests => 11; use SQL::Translator; use SQL::Translator::Parser::MySQL qw(parse); -$SQL::Translator::DEBUG = 0; - my $tr = SQL::Translator->new; my $data = q|create table sessions ( id char(32) not null primary key, a_session text );|; -BEGIN { print "1..11\n"; } - my $val = parse($tr, $data); # $val holds the processed data structure. # The data structure should have one key: -print "not " if (scalar keys %{$val} != 1); -print "ok 1\n"; +is(scalar keys %{$val}, 1); # The data structure should have a single key, named sessions -print "not " unless (defined $val->{'sessions'}); -print qq(ok 2 # has a key named "sessions"\n); +ok(defined $val->{'sessions'}); # $val->{'sessions'} should have a single index (since we haven't # defined an index, but have defined a primary key) my $indices = $val->{'sessions'}->{'indices'}; -print "not " unless (scalar @{$indices} == 1); -print "ok 3 # correct index number\n"; +is(scalar @{$indices}, 1, "correct index number"); -print "not " unless ($indices->[0]->{'type'} eq 'primary_key'); -print "ok 4 # correct index type\n"; -print "not " unless ($indices->[0]->{'fields'}->[0] eq 'id'); -print "ok 5 # correct index name\n"; +is($indices->[0]->{'type'}, 'primary_key', "correct index type"); +is($indices->[0]->{'fields'}->[0], 'id', "correct index name"); # $val->{'sessions'} should have two fields, id and a_sessionn my $fields = $val->{'sessions'}->{'fields'}; -print "not " unless (scalar keys %{$fields} == 2); -print "ok 6 # correct fields number\n"; +is(scalar keys %{$fields}, 2, "correct fields number"); -print "not " unless ($fields->{'id'}->{'data_type'} eq 'char'); -print "ok 7 # correct field type: id (char)\n"; +is($fields->{'id'}->{'data_type'}, 'char', + "correct field type: id (char)"); -print "not " unless ($fields->{'a_session'}->{'data_type'} eq 'text'); -print "ok 8 # correct field type: a_session (text)\n"; +is ($fields->{'a_session'}->{'data_type'}, 'text', + "correct field type: a_session (text)"); -print "not " unless ($fields->{'id'}->{'is_primary_key'} == 1); -print "ok 9 # correct key identification (id == key)\n"; +is($fields->{'id'}->{'is_primary_key'}, 1, + "correct key identification (id == key)"); -print "not " if (defined $fields->{'a_session'}->{'is_primary_key'}); -print "ok 10 # correct key identification (a_session != key)\n"; +ok(! defined $fields->{'a_session'}->{'is_primary_key'}, + "correct key identification (a_session != key)"); # Test that the order is being maintained by the internal order # data element @@ -67,5 +59,5 @@ my @order = sort { $fields->{$a}->{'order'} <=> $fields->{$b}->{'order'} } keys %{$fields}; -print "not " unless ($order[0] eq 'id' && $order[1] eq 'a_session'); -print "ok 11 # ordering of fields\n"; + +ok($order[0] eq 'id' && $order[1] eq 'a_session', "ordering of fields"); diff --git a/t/07p_args.t b/t/07p_args.t index 0185cdd..76b922e 100644 --- a/t/07p_args.t +++ b/t/07p_args.t @@ -3,12 +3,10 @@ # # -BEGIN { print "1..6\n"; } - use strict; use SQL::Translator; -$SQL::Translator::DEBUG = 0; +use Test::More tests => 6; sub silly_parser { my ($tr, $data) = @_; @@ -31,11 +29,10 @@ $tr->parser_args(delimiter => '\|'); my $pargs = $tr->parser_args; my $parsed = $tr->translate(\$data); -print "not " unless ($pargs->{'delimiter'} eq '\|'); -print "ok 1 # parser_args works when called directly\n"; - -print "not " unless (scalar @{$parsed} == 4); -print "ok 2 # right number of fields\n"; +is($pargs->{'delimiter'}, '\|', + "parser_args works when called directly"); +is(scalar @{$parsed}, 4, + "right number of fields"); # Now, pass parser_args indirectly... $tr->parser(\&silly_parser, { delimiter => "\t" }); @@ -44,11 +41,11 @@ $data =~ s/\|/\t/g; $pargs = $tr->parser_args; $parsed = $tr->translate(\$data); -print "not " unless ($pargs->{'delimiter'} eq "\t"); -print "ok 3 # parser_args works when called indirectly\n"; +is($pargs->{'delimiter'}, "\t", + "parser_args works when called indirectly"); -print "not " unless (scalar @{$parsed} == 4); -print "ok 4 # right number of fields with new delimiter\n"; +is(scalar @{$parsed}, 4, + "right number of fields with new delimiter"); undef $tr; $tr = SQL::Translator->new(parser => \&silly_parser, @@ -57,9 +54,9 @@ $data =~ s/\t/:/g; $pargs = $tr->parser_args; $parsed = $tr->translate(\$data); -print "not " unless ($pargs->{'delimiter'} eq ":"); -print "ok 5 # parser_args works when called as constructor arg\n"; +is($pargs->{'delimiter'}, ":", + "parser_args works when called as constructor arg"); -print "not " unless (scalar @{$parsed} == 4); -print "ok 6 # right number of fields with new delimiter\n"; +is(scalar @{$parsed}, 4, + "right number of fields with new delimiter");