mirror of https://github.com/perkeep/perkeep.git
pkg/test/integration: skip non-UTF-8 test on filesystems requiring UTF-8
Fixes #1025 Change-Id: Ia6212140197958ef6660bf3ced6a9bb427ae5aef
This commit is contained in:
parent
962dfe5b23
commit
01419ae02d
|
@ -22,7 +22,9 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"perkeep.org/pkg/test"
|
||||
|
@ -56,6 +58,11 @@ func TestNonUTF8FileName(t *testing.T) {
|
|||
}
|
||||
|
||||
fd, err := os.Create(filepath.Join(srcDir, string(base)))
|
||||
if isBadFilenameError(err) {
|
||||
// TODO: decide how we want to handle this in the future.
|
||||
// Normalize to UTF-8 with heuristics in camget?
|
||||
t.Skip("skipping non-UTF-8 test on system requiring UTF-8")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("os.Create(): %v", err)
|
||||
}
|
||||
|
@ -90,6 +97,11 @@ func TestNonUTF8SymlinkTarget(t *testing.T) {
|
|||
}
|
||||
|
||||
fd, err := os.Create(filepath.Join(srcDir, string(base)))
|
||||
if isBadFilenameError(err) {
|
||||
// TODO: decide how we want to handle this in the future.
|
||||
// Normalize to UTF-8 with heuristics in camget?
|
||||
t.Skip("skipping non-UTF-8 test on system requiring UTF-8")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("os.Create(): %v", err)
|
||||
}
|
||||
|
@ -119,3 +131,13 @@ func TestNonUTF8SymlinkTarget(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func isBadFilenameError(err error) bool {
|
||||
if runtime.GOOS != "darwin" {
|
||||
return false
|
||||
}
|
||||
if pe, ok := err.(*os.PathError); ok && pe.Op == "open" && pe.Err == syscall.Errno(0x5c) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue