pkg/test/integration: skip non-UTF-8 test on filesystems requiring UTF-8

Fixes #1025

Change-Id: Ia6212140197958ef6660bf3ced6a9bb427ae5aef
This commit is contained in:
Brad Fitzpatrick 2018-01-08 06:44:40 -08:00
parent 962dfe5b23
commit 01419ae02d
1 changed files with 22 additions and 0 deletions

View File

@ -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
}