]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/httpd.t
testcommon: spawn-aware system() and qx[] workalikes
[public-inbox.git] / t / httpd.t
index 2972afb26a33cba68569a37fbd8415703c49b36c..61aec3b4436bd5db64c09d46015488a391091ca8 100644 (file)
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -49,6 +49,11 @@ EOF
        $td = start_script($cmd, undef, { 3 => $sock });
        my $host = $sock->sockhost;
        my $port = $sock->sockport;
+       {
+               my $bad = tcp_connect($sock);
+               print $bad "GETT / HTTP/1.0\r\n\r\n" or die;
+               like(<$bad>, qr!\AHTTP/1\.[01] 405\b!, 'got 405 on bad req');
+       }
        my $conn = tcp_connect($sock);
        ok($conn, 'connected');
        ok($conn->write("GET / HTTP/1.0\r\n\r\n"), 'wrote data to socket');
@@ -59,22 +64,22 @@ EOF
                is($conn->read($buf, 1), 0, "EOF");
        }
 
-       is(system(qw(git clone -q --mirror),
+       is(xsys(qw(git clone -q --mirror),
                        "http://$host:$port/$group", "$tmpdir/clone.git"),
                0, 'smart clone successful');
 
        # ensure dumb cloning works, too:
-       is(system('git', "--git-dir=$maindir",
+       is(xsys('git', "--git-dir=$maindir",
                qw(config http.uploadpack false)),
                0, 'disable http.uploadpack');
-       is(system(qw(git clone -q --mirror),
+       is(xsys(qw(git clone -q --mirror),
                        "http://$host:$port/$group", "$tmpdir/dumb.git"),
                0, 'clone successful');
 
        ok($td->kill, 'killed httpd');
        $td->join;
 
-       is(system('git', "--git-dir=$tmpdir/clone.git",
+       is(xsys('git', "--git-dir=$tmpdir/clone.git",
                  qw(fsck --no-verbose)), 0,
                'fsck on cloned directory successful');
 }