Commit 99f17aa0 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http/cgi: skip tests on Windows

The tests require Perl, not commonly installed on Windows.

R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4239057
parent e339d27d
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"http" "http"
"http/httptest" "http/httptest"
"os" "os"
"runtime"
"strings" "strings"
"testing" "testing"
) )
...@@ -57,7 +58,21 @@ readlines: ...@@ -57,7 +58,21 @@ readlines:
return rw return rw
} }
func skipTest(t *testing.T) bool {
if runtime.GOOS == "windows" {
// No Perl on Windows, needed by test.cgi
// TODO: make the child process be Go, not Perl.
t.Logf("Skipping test on Windows; no Perl.")
return true
}
return false
}
func TestCGIBasicGet(t *testing.T) { func TestCGIBasicGet(t *testing.T) {
if skipTest(t) {
return
}
h := &Handler{ h := &Handler{
Path: "testdata/test.cgi", Path: "testdata/test.cgi",
Root: "/test.cgi", Root: "/test.cgi",
...@@ -91,6 +106,9 @@ func TestCGIBasicGet(t *testing.T) { ...@@ -91,6 +106,9 @@ func TestCGIBasicGet(t *testing.T) {
} }
func TestCGIBasicGetAbsPath(t *testing.T) { func TestCGIBasicGetAbsPath(t *testing.T) {
if skipTest(t) {
return
}
pwd, err := os.Getwd() pwd, err := os.Getwd()
if err != nil { if err != nil {
t.Fatalf("getwd error: %v", err) t.Fatalf("getwd error: %v", err)
...@@ -108,6 +126,9 @@ func TestCGIBasicGetAbsPath(t *testing.T) { ...@@ -108,6 +126,9 @@ func TestCGIBasicGetAbsPath(t *testing.T) {
} }
func TestPathInfo(t *testing.T) { func TestPathInfo(t *testing.T) {
if skipTest(t) {
return
}
h := &Handler{ h := &Handler{
Path: "testdata/test.cgi", Path: "testdata/test.cgi",
Root: "/test.cgi", Root: "/test.cgi",
...@@ -124,6 +145,9 @@ func TestPathInfo(t *testing.T) { ...@@ -124,6 +145,9 @@ func TestPathInfo(t *testing.T) {
} }
func TestPathInfoDirRoot(t *testing.T) { func TestPathInfoDirRoot(t *testing.T) {
if skipTest(t) {
return
}
h := &Handler{ h := &Handler{
Path: "testdata/test.cgi", Path: "testdata/test.cgi",
Root: "/myscript/", Root: "/myscript/",
...@@ -139,6 +163,9 @@ func TestPathInfoDirRoot(t *testing.T) { ...@@ -139,6 +163,9 @@ func TestPathInfoDirRoot(t *testing.T) {
} }
func TestPathInfoNoRoot(t *testing.T) { func TestPathInfoNoRoot(t *testing.T) {
if skipTest(t) {
return
}
h := &Handler{ h := &Handler{
Path: "testdata/test.cgi", Path: "testdata/test.cgi",
Root: "", Root: "",
...@@ -154,6 +181,9 @@ func TestPathInfoNoRoot(t *testing.T) { ...@@ -154,6 +181,9 @@ func TestPathInfoNoRoot(t *testing.T) {
} }
func TestCGIBasicPost(t *testing.T) { func TestCGIBasicPost(t *testing.T) {
if skipTest(t) {
return
}
postReq := `POST /test.cgi?a=b HTTP/1.0 postReq := `POST /test.cgi?a=b HTTP/1.0
Host: example.com Host: example.com
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
...@@ -180,6 +210,9 @@ func chunk(s string) string { ...@@ -180,6 +210,9 @@ func chunk(s string) string {
// The CGI spec doesn't allow chunked requests. // The CGI spec doesn't allow chunked requests.
func TestCGIPostChunked(t *testing.T) { func TestCGIPostChunked(t *testing.T) {
if skipTest(t) {
return
}
postReq := `POST /test.cgi?a=b HTTP/1.1 postReq := `POST /test.cgi?a=b HTTP/1.1
Host: example.com Host: example.com
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment