Skip to content

Commit 5273a78

Browse files
committed
webdav: skip XML-related tests on Go 1.4.
Package webdav requires the Go standard library's encoding/xml package version 1.5 or greater. Fixes #10904 Change-Id: Idf2915e581f4efa6f00e7701785ea258f9e1a8f4 Reviewed-on: https://go-review.googlesource.com/10243 Reviewed-by: Robert Stepanek <robert.stepanek@gmail.com> Reviewed-by: Nigel Tao <nigeltao@golang.org>
1 parent bb64f4d commit 5273a78

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

webdav/webdav.go

+22
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,34 @@ import (
1212
"errors"
1313
"fmt"
1414
"io"
15+
"log"
1516
"net/http"
1617
"net/url"
1718
"os"
19+
"runtime"
20+
"strings"
1821
"time"
1922
)
2023

24+
// Package webdav's XML output requires the standard library's encoding/xml
25+
// package version 1.5 or greater. Otherwise, it will produce malformed XML.
26+
//
27+
// As of May 2015, the Go stable release is version 1.4, so we print a message
28+
// to let users know that this golang.org/x/etc package won't work yet.
29+
//
30+
// This package also won't work with Go 1.3 and earlier, but making this
31+
// runtime version check catch all the earlier versions too, and not just
32+
// "1.4.x", isn't worth the complexity.
33+
//
34+
// TODO: delete this check at some point after Go 1.5 is released.
35+
var go1Dot4 = strings.HasPrefix(runtime.Version(), "go1.4.")
36+
37+
func init() {
38+
if go1Dot4 {
39+
log.Println("package webdav requires Go version 1.5 or greater")
40+
}
41+
}
42+
2143
type Handler struct {
2244
// FileSystem is the virtual file system.
2345
FileSystem FileSystem

webdav/xml_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ func TestReadPropfind(t *testing.T) {
345345
}
346346

347347
func TestMultistatusWriter(t *testing.T) {
348+
if go1Dot4 {
349+
t.Skip("TestMultistatusWriter requires Go version 1.5 or greater")
350+
}
351+
348352
///The "section x.y.z" test cases come from section x.y.z of the spec at
349353
// http://www.webdav.org/specs/rfc4918.html
350354
testCases := []struct {

0 commit comments

Comments
 (0)