mirror of
https://github.com/golang/go
synced 2024-11-21 22:14:41 -07:00
http/cgi: skip test if perl or CGI.pm not available
R=bradfitzgo, bradfitzwork CC=golang-dev https://golang.org/cl/4264047
This commit is contained in:
parent
ff3ef8a963
commit
255b538152
@ -8,15 +8,29 @@ package cgi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"exec"
|
||||||
"fmt"
|
"fmt"
|
||||||
"http"
|
"http"
|
||||||
"http/httptest"
|
"http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cgiScriptWorks = canRun("./testdata/test.cgi")
|
||||||
|
|
||||||
|
func canRun(s string) bool {
|
||||||
|
c, err := exec.Run(s, []string{s}, nil, ".", exec.DevNull, exec.DevNull, exec.DevNull)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
w, err := c.Wait(0)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return w.Exited() && w.ExitStatus() == 0
|
||||||
|
}
|
||||||
|
|
||||||
func newRequest(httpreq string) *http.Request {
|
func newRequest(httpreq string) *http.Request {
|
||||||
buf := bufio.NewReader(strings.NewReader(httpreq))
|
buf := bufio.NewReader(strings.NewReader(httpreq))
|
||||||
req, err := http.ReadRequest(buf)
|
req, err := http.ReadRequest(buf)
|
||||||
@ -59,10 +73,10 @@ readlines:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func skipTest(t *testing.T) bool {
|
func skipTest(t *testing.T) bool {
|
||||||
if runtime.GOOS == "windows" {
|
if !cgiScriptWorks {
|
||||||
// No Perl on Windows, needed by test.cgi
|
// No Perl on Windows, needed by test.cgi
|
||||||
// TODO: make the child process be Go, not Perl.
|
// TODO: make the child process be Go, not Perl.
|
||||||
t.Logf("Skipping test on Windows; no Perl.")
|
t.Logf("Skipping test: test.cgi failed.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user