From: Dagfinn Ilmari Mannsåker Date: Wed, 13 Aug 2014 00:12:13 +0000 (+0100) Subject: Propagate switches when running perl in tests X-Git-Tag: v0.11019~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb9bbc68fe26aa563d28d590221f6a0235b4062e;hp=60650d2726662682755827acde6dc0f598f83b93;p=dbsrgits%2FSQL-Translator.git Propagate switches when running perl in tests --- diff --git a/Makefile.PL b/Makefile.PL index 2f7e993..89692e5 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -37,6 +37,7 @@ my $deps = { 'Test::More' => '0.88', 'Test::Differences' => '0', 'Test::Exception' => '0.31', + 'Text::ParseWords' => '0', }, }; diff --git a/t/09sqlt-diagram.t b/t/09sqlt-diagram.t index a08b020..53de678 100644 --- a/t/09sqlt-diagram.t +++ b/t/09sqlt-diagram.t @@ -6,6 +6,7 @@ use File::Temp qw(mktemp); use FindBin qw($Bin); use Test::More; use Test::SQL::Translator qw(maybe_plan); +use Text::ParseWords qw(shellwords); BEGIN { maybe_plan( @@ -25,7 +26,7 @@ my $test_data = catfile($Bin, @data); my $tmp = mktemp('sqlXXXXX'); ok(-e $sqlt_diagram); -my @cmd = ($^X, $sqlt_diagram, "-d", "MySQL", "-o", $tmp, $test_data); +my @cmd = ($^X, shellwords($ENV{HARNESS_PERL_SWITCHES}), $sqlt_diagram, "-d", "MySQL", "-o", $tmp, $test_data); eval { system(@cmd); }; ok(!$@ && ($? == 0)); ok(-e $tmp); diff --git a/t/31dumper.t b/t/31dumper.t index 17004a6..96401ca 100644 --- a/t/31dumper.t +++ b/t/31dumper.t @@ -10,6 +10,7 @@ use SQL::Translator; use Test::More; use Test::SQL::Translator qw(maybe_plan); use Symbol qw(gensym); +use Text::ParseWords qw(shellwords); BEGIN { maybe_plan( @@ -51,7 +52,7 @@ print $fh $output; close $fh or die "Can't close file '$filename': $!"; my $out; -my $pid = open3( undef, $out, undef, $^X, '-cw', $filename ); +my $pid = open3( undef, $out, undef, $^X, shellwords($ENV{HARNESS_PERL_SWITCHES}), '-cw', $filename ); my $res = do { local $/; <$out> }; waitpid($pid, 0); diff --git a/t/70sqlt-diff_script.t b/t/70sqlt-diff_script.t index 77c231e..13ee198 100644 --- a/t/70sqlt-diff_script.t +++ b/t/70sqlt-diff_script.t @@ -8,6 +8,7 @@ use FindBin qw($Bin); use IPC::Open3; use Test::More; use Test::SQL::Translator qw(maybe_plan); +use Text::ParseWords qw(shellwords); my @script = qw(script sqlt-diff); my @create1 = qw(data sqlite create.sql); @@ -35,7 +36,7 @@ my $mysql_create2 = (-d "t") : catfile($Bin, "t", @mysql_create2); # Test for differences -my $out = _run_cmd ($^X, $sqlt_diff, "$mysql_create1=MySQL", "$mysql_create2=MySQL"); +my $out = _run_cmd ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create2=MySQL"); like($out, qr/CHANGE COLUMN person_id/, "Detected altered 'person_id' field"); like($out, qr/CHANGE COLUMN iq/, "Detected altered 'iq' field"); @@ -54,7 +55,7 @@ like($out, qr/ADD CONSTRAINT FK5302D47D93FE702E_diff/, unlike($out, qr/ADD PRIMARY KEY/, "Primary key looks different when it shouldn't"); # Test for quoted output -$out = _run_cmd ($^X, $sqlt_diff, '--quote=`', "$mysql_create1=MySQL", "$mysql_create2=MySQL"); +$out = _run_cmd ($sqlt_diff, '--quote=`', "$mysql_create1=MySQL", "$mysql_create2=MySQL"); like($out, qr/ALTER TABLE `person`/, "Quoted table name"); like($out, qr/CHANGE COLUMN `person_id`/, "Quoted 'person_id' field"); @@ -63,13 +64,13 @@ like($out, qr/CHANGE COLUMN `name`/, "Quoted 'name' field"); like($out, qr/CHANGE COLUMN `age`/, "Quoted 'age' field"); # Test for sameness -$out = _run_cmd ($^X, $sqlt_diff, "$mysql_create1=MySQL", "$mysql_create1=MySQL"); +$out = _run_cmd ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create1=MySQL"); like($out, qr/No differences found/, "Properly detected no differences"); sub _run_cmd { my $out; - my $pid = open3( undef, $out, undef, @_ ); + my $pid = open3( undef, $out, undef, $^X, shellwords($ENV{HARNESS_PERL_SWITCHES}), @_ ); my $res = do { local $/; <$out> }; waitpid($pid, 0); $res; diff --git a/t/70sqlt-diff_script_old.t b/t/70sqlt-diff_script_old.t index 9f144f8..1ebd2f0 100644 --- a/t/70sqlt-diff_script_old.t +++ b/t/70sqlt-diff_script_old.t @@ -8,6 +8,7 @@ use FindBin qw($Bin); use Test::More; use IPC::Open3; use Test::SQL::Translator qw(maybe_plan); +use Text::ParseWords qw(shellwords); my @script = qw(script sqlt-diff-old); my @create1 = qw(data sqlite create.sql); @@ -26,14 +27,14 @@ BEGIN { } ok(-e $sqlt_diff, 'Found sqlt-diff script'); -my $out = _run_cmd ($^X, $sqlt_diff, "$create1=SQLite", "$create2=SQLite"); +my $out = _run_cmd ($sqlt_diff, "$create1=SQLite", "$create2=SQLite"); like($out, qr/-- Target database SQLite is untested/, "Detected 'untested' comment"); like($out, qr/ALTER TABLE person CHANGE iq/, "Detected altered 'iq' field"); like($out, qr/ALTER TABLE person ADD is_rock_star/, "Detected missing rock star field"); -$out = _run_cmd ($^X, $sqlt_diff, "$create1=SQLite", "$create1=SQLite"); +$out = _run_cmd ($sqlt_diff, "$create1=SQLite", "$create1=SQLite"); like($out, qr/There were no differences/, "Properly detected no differences"); @@ -49,7 +50,7 @@ my $mysql_create2 = (-d "t") : catfile($Bin, "t", @mysql_create2); # Test for differences -$out = _run_cmd ($^X, $sqlt_diff, "$mysql_create1=MySQL", "$mysql_create2=MySQL"); +$out = _run_cmd ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create2=MySQL"); unlike($out, qr/-- Target database MySQL is untested/, "Did not detect 'untested' comment"); like($out, qr/ALTER TABLE person CHANGE person_id/, "Detected altered 'person_id' field"); @@ -71,7 +72,7 @@ like($out, qr/ALTER TABLE employee ADD CONSTRAINT FK5302D47D93FE702E_diff/, unlike($out, qr/ALTER TABLE employee ADD PRIMARY KEY/, "Primary key looks different when it shouldn't"); # Test for sameness -$out = _run_cmd ($^X, $sqlt_diff, "$mysql_create1=MySQL", "$mysql_create1=MySQL"); +$out = _run_cmd ($sqlt_diff, "$mysql_create1=MySQL", "$mysql_create1=MySQL"); like($out, qr/There were no differences/, "Properly detected no differences"); @@ -86,7 +87,7 @@ my $oracle_create2 = (-d "t") ? catfile($Bin, @oracle_create2) : catfile($Bin, "t", @oracle_create2); -$out = _run_cmd ($^X, $sqlt_diff, "$oracle_create1=Oracle", "$oracle_create2=Oracle"); +$out = _run_cmd ($sqlt_diff, "$oracle_create1=Oracle", "$oracle_create2=Oracle"); unlike($out, qr/-- Target database Oracle is untested/, "Did not detect 'untested' comment"); like($out, qr/ALTER TABLE TABLE1 DROP FOREIGN KEY/, @@ -96,7 +97,7 @@ like($out, qr/ALTER TABLE TABLE1 ADD CONSTRAINT/, sub _run_cmd { my $out; - my $pid = open3( undef, $out, undef, @_ ); + my $pid = open3( undef, $out, undef, $^X, shellwords($ENV{HARNESS_PERL_SWITCHES}), @_ ); my $res = do { local $/; <$out> }; waitpid($pid, 0); $res;