aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-03-06 11:23:47 -0500
committerRuss Cox <rsc@golang.org>2011-03-06 11:23:47 -0500
commit255b538152aa4e28eaaca7bf41ea2a5368d77ac9 (patch)
treeb28468f134589da73e060576b0dcef8863d5abd1
parentff3ef8a9638236b1a8e05ca56832ae4d9480e903 (diff)
downloadgo-255b538152aa4e28eaaca7bf41ea2a5368d77ac9.tar.gz
go-255b538152aa4e28eaaca7bf41ea2a5368d77ac9.zip
http/cgi: skip test if perl or CGI.pm not available
R=bradfitzgo, bradfitzwork CC=golang-dev https://golang.org/cl/4264047
-rw-r--r--src/pkg/http/cgi/cgi_test.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/pkg/http/cgi/cgi_test.go b/src/pkg/http/cgi/cgi_test.go
index d88d787d58..daf9a2cb3e 100644
--- a/src/pkg/http/cgi/cgi_test.go
+++ b/src/pkg/http/cgi/cgi_test.go
@@ -8,15 +8,29 @@ package cgi
import (
"bufio"
+ "exec"
"fmt"
"http"
"http/httptest"
"os"
- "runtime"
"strings"
"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 {
buf := bufio.NewReader(strings.NewReader(httpreq))
req, err := http.ReadRequest(buf)
@@ -59,10 +73,10 @@ readlines:
}
func skipTest(t *testing.T) bool {
- if runtime.GOOS == "windows" {
+ if !cgiScriptWorks {
// 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.")
+ t.Logf("Skipping test: test.cgi failed.")
return true
}
return false