about summary refs log tree commit homepage
path: root/t/httpd.t
diff options
context:
space:
mode:
Diffstat (limited to 't/httpd.t')
-rw-r--r--t/httpd.t42
1 files changed, 32 insertions, 10 deletions
diff --git a/t/httpd.t b/t/httpd.t
index 7746837..9a0fae6 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -11,8 +11,10 @@ my $f1 = "$mwrap_tmp/f1";
 my $f2 = "$mwrap_tmp/f2";
 mkfifo($f1, 0600) // plan(skip_all => "mkfifo: $!");
 mkfifo($f2, 0600) // plan(skip_all => "mkfifo: $!");
-my $pid = mwrap_run('httpd test', $env, '-e',
-        "open my \$f1, '>', '$f1'; close \$f1; open my \$f2, '<', '$f2'");
+my $src = $mwrap_src ? # $mwrap_src is Perl-only, Ruby otherwise
+        "open my \$f1, '>', '$f1'; close \$f1; open my \$f2, '<', '$f2'" :
+        "File.open('$f1', 'w').close; File.open('$f2', 'r').close";
+my $pid = mwrap_run('httpd test', $env, '-e', $src);
 my $spid;
 my $mw_exit;
 my $cleanup = sub {
@@ -85,9 +87,21 @@ SKIP: {
 }
 
 SKIP: {
+        my (@rproxy, @missing);
+        if (-e 'script/mwrap-rproxy') { # Perl version
+                @rproxy = ($^X, '-w', './blib/script/mwrap-rproxy');
+        } else {
+                my $exe = `which mwrap-rproxy`;
+                if ($? == 0 && defined($exe)) {
+                        chomp($rproxy[0] = $exe);
+                } else {
+                        push @missing, 'mwrap-rproxy';
+                }
+        }
         for my $m (qw(Plack::Util HTTP::Tiny)) {
-                eval "require $m" or skip "$m missing", 1;
+                eval "require $m" or push(@missing, $m);
         }
+        skip join(', ', @missing).' missing', 1 if @missing;
         my $srv = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
                                 ReuseAddr => 1, Proto => 'tcp',
                                 Type => SOCK_STREAM,
@@ -103,8 +117,7 @@ SKIP: {
                 }
                 local $ENV{PLACK_ENV} = 'deployment' if !$ENV{V};
                 no warnings 'exec';
-                exec $^X, '-w', './blib/script/mwrap-rproxy',
-                        "--socket-dir=$mwrap_tmp";
+                exec @rproxy, "--socket-dir=$mwrap_tmp";
                 _exit(1);
         }
         my $http = HTTP::Tiny->new;
@@ -135,19 +148,28 @@ SKIP: {
 
 SKIP: {
         skip 'no reset w/o curl --unix-socket', 1 if !$curl_unix;
-
+        my ($sqlite_v) = (`sqlite3 --version` =~ /([\d+\.]+)/);
+        if ($?) {
+                diag 'sqlite3 missing or broken';
+                $sqlite_v = 0;
+        } else {
+                my @v = split(/\./, $sqlite_v);
+                $sqlite_v = ($v[0] << 16) | ($v[1] << 8) | $v[2];
+                diag 'sqlite_v='.sprintf('0x%x', $sqlite_v);
+        }
         $rc = system(@curl, "http://0/$pid/each/100.csv");
         is($rc, 0, '.csv retrieved') or skip 'CSV failed', 1;
         my $db = "$mwrap_tmp/t.sqlite3";
-        $rc = system(qw(sqlite3), $db, ".import --csv $cout mwrap_each");
-        if ($rc == -1) {
-                diag 'sqlite3 missing';
-        } else {
+
+        if ($sqlite_v >= 0x32000) {
+                $rc = system(qw(sqlite3), $db,".import --csv $cout mwrap_each");
                 is($rc, 0, 'sqlite3 import');
                 my $n = `sqlite3 $db 'SELECT COUNT(*) FROM mwrap_each'`;
                 is($?, 0, 'sqlite3 count');
                 my $exp = split(/\n/, slurp($cout));
                 is($n + 1, $exp, 'imported all rows into sqlite');
+        } else {
+                diag "sqlite 3.32.0+ needed for `.import --csv'";
         }
 
         $rc = system(@curl, qw(-d x=y), "http://0/$pid/reset");