Commit | Line | Data |
35bab742 |
1 | #!/usr/bin/perl |
2 | # vim: set ft=perl: |
3 | # |
4 | |
5 | use strict; |
dd2ef5ae |
6 | |
5dada97b |
7 | use File::Spec::Functions qw(catfile tmpdir); |
8 | use File::Temp qw(tempfile); |
9 | use FindBin qw($Bin); |
10 | use SQL::Translator; |
2d691ec1 |
11 | use Test::More; |
12 | use Test::SQL::Translator qw(maybe_plan); |
5dada97b |
13 | |
fbc0552f |
14 | # This aggravates me; XML::Writer produces tons of warnings. |
15 | local $SIG{__WARN__} = sub { |
16 | CORE::warn(@_) |
17 | unless $_[0] =~ m#XML/Writer#; |
18 | }; |
19 | |
2d691ec1 |
20 | BEGIN { |
21 | maybe_plan(2, |
22 | 'SQL::Translator::Parser::MySQL', |
23 | 'SQL::Translator::Producer::XML::SQLFairy'); |
24 | } |
25 | |
5dada97b |
26 | my @data = qw(data mysql BGEP-RE-create.sql); |
27 | my $test_data = (-d "t") |
28 | ? catfile($Bin, @data) |
29 | : catfile($Bin, "t", @data); |
30 | |
02069e40 |
31 | my $tr = SQL::Translator->new( |
32 | parser => 'MySQL', |
295fe54d |
33 | producer => 'XML-SQLFairy', |
02069e40 |
34 | filename => $test_data |
35 | ); |
5dada97b |
36 | my $data = $tr->translate; |
37 | |
295fe54d |
38 | ok($data, "MySQL->XML-SQLFairy"); |
5dada97b |
39 | |
40 | SKIP: { |
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 | $fh->close; |
55 | |
56 | ok(XML::Parser->new->parsefile($fname), |
57 | "Successfully parsed output"); |
58 | } |