"http"
"http/httptest"
"os"
+ "runtime"
"strings"
"testing"
)
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) {
+ if skipTest(t) {
+ return
+ }
h := &Handler{
Path: "testdata/test.cgi",
Root: "/test.cgi",
}
func TestCGIBasicGetAbsPath(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
pwd, err := os.Getwd()
if err != nil {
t.Fatalf("getwd error: %v", err)
}
func TestPathInfo(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
h := &Handler{
Path: "testdata/test.cgi",
Root: "/test.cgi",
}
func TestPathInfoDirRoot(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
h := &Handler{
Path: "testdata/test.cgi",
Root: "/myscript/",
}
func TestPathInfoNoRoot(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
h := &Handler{
Path: "testdata/test.cgi",
Root: "",
}
func TestCGIBasicPost(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
postReq := `POST /test.cgi?a=b HTTP/1.0
Host: example.com
Content-Type: application/x-www-form-urlencoded
// The CGI spec doesn't allow chunked requests.
func TestCGIPostChunked(t *testing.T) {
+ if skipTest(t) {
+ return
+ }
postReq := `POST /test.cgi?a=b HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded