Fix tests on freebsd

This commit is contained in:
Alexander Neumann 2015-07-20 21:02:38 +02:00
parent 7e0a9aa565
commit bd3ce5d4a3
4 changed files with 20 additions and 6 deletions

7
Vagrantfile vendored
View File

@ -7,6 +7,13 @@ def packages_freebsd
return <<-EOF return <<-EOF
pkg install -y git pkg install -y git
pkg install -y curl pkg install -y curl
echo 'fuse_load="YES"' >> /boot/loader.conf
echo 'vfs.usermount=1' >> /etc/sysctl.conf
kldload fuse
sysctl vfs.usermount=1
pw groupmod operator -M vagrant
EOF EOF
end end

View File

@ -65,7 +65,10 @@ func (e *dirEntry) equals(other *dirEntry) bool {
return false return false
} }
if runtime.GOOS != "darwin" { switch runtime.GOOS {
case "darwin", "freebsd":
// Skip ModTime check on darwin and freebsd
default:
if e.fi.ModTime() != other.fi.ModTime() { if e.fi.ModTime() != other.fi.ModTime() {
fmt.Fprintf(os.Stderr, "%v: ModTime does not match (%v != %v)\n", e.path, e.fi.ModTime(), other.fi.ModTime()) fmt.Fprintf(os.Stderr, "%v: ModTime does not match (%v != %v)\n", e.path, e.fi.ModTime(), other.fi.ModTime())
return false return false

View File

@ -153,17 +153,21 @@ func TestNodeRestoreAt(t *testing.T) {
func AssertFsTimeEqual(t *testing.T, label string, nodeType string, t1 time.Time, t2 time.Time) { func AssertFsTimeEqual(t *testing.T, label string, nodeType string, t1 time.Time, t2 time.Time) {
var equal bool var equal bool
if runtime.GOOS == "darwin" { // Go currently doesn't support setting timestamps of symbolic links on darwin and freebsd
// Go currently doesn't support setting timestamps of symbolic links on darwin if nodeType == "symlink" {
if nodeType == "symlink" { switch runtime.GOOS {
case "darwin", "freebsd":
return return
} }
}
switch runtime.GOOS {
case "darwin":
// HFS+ timestamps don't support sub-second precision, // HFS+ timestamps don't support sub-second precision,
// see https://en.wikipedia.org/wiki/Comparison_of_file_systems // see https://en.wikipedia.org/wiki/Comparison_of_file_systems
diff := int(t1.Sub(t2).Seconds()) diff := int(t1.Sub(t2).Seconds())
equal = diff == 0 equal = diff == 0
} else { default:
equal = t1.Equal(t2) equal = t1.Equal(t2)
} }

View File

@ -88,7 +88,7 @@ func RandomReader(seed, size int) *bytes.Reader {
// SetupTarTestFixture extracts the tarFile to outputDir. // SetupTarTestFixture extracts the tarFile to outputDir.
func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) { func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {
err := System("sh", "-c", `(cd "$1" && tar xz) < "$2"`, err := System("sh", "-c", `(cd "$1" && tar xzf - ) < "$2"`,
"sh", outputDir, tarFile) "sh", outputDir, tarFile)
OK(t, err) OK(t, err)
} }