1#!/usr/bin/perl 2# vim: set ft=perl: 3# 4 5use strict; 6 7use File::Spec::Functions qw(catfile tmpdir); 8use File::Temp qw(tempfile); 9use FindBin qw($Bin); 10use SQL::Translator; 11use Test::More; 12use Test::SQL::Translator qw(maybe_plan); 13 14# This aggravates me; XML::Writer produces tons of warnings. 15local $SIG{__WARN__} = sub { 16 CORE::warn(@_) 17 unless $_[0] =~ m#XML/Writer#; 18}; 19 20BEGIN { 21 maybe_plan(2, 22 'SQL::Translator::Parser::MySQL', 23 'SQL::Translator::Producer::XML::SQLFairy'); 24} 25 26my @data = qw(data mysql BGEP-RE-create.sql); 27my $test_data = (-d "t") 28 ? catfile($Bin, @data) 29 : catfile($Bin, "t", @data); 30 31my $tr = SQL::Translator->new( 32 parser => 'MySQL', 33 producer => 'XML-SQLFairy', 34 filename => $test_data 35); 36my $data = $tr->translate; 37 38ok($data, "MySQL->XML-SQLFairy"); 39 40SKIP: { 41 eval { 42 require XML::Parser; 43 }; 44 if ($@) { 45 skip "Can't load XML::Parser" => 1; 46 } 47 48 # Can't get XML::Parser::parsestring to do Useful Things 49 my ($fh, $fname) = tempfile('sqlfXXXX', 50 UNLINK => 1, 51 SUFFIX => '.xml', 52 DIR => tmpdir); 53 print $fh $data; 54 close $fh; 55 56 ok(XML::Parser->new->parsefile($fname), 57 "Successfully parsed output"); 58} 59