Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
560105ca
Commit
560105ca
authored
Aug 14, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test failures on OS X.
parent
8f220f0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
22 deletions
+31
-22
fusetesting/stat.go
fusetesting/stat.go
+25
-16
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+6
-6
No files found.
fusetesting/stat.go
View file @
560105ca
...
...
@@ -57,30 +57,39 @@ func mtimeIsWithin(c interface{}, expected time.Time, d time.Duration) error {
return
nil
}
// Match os.FileInfo values that specify a file birth time equal to the given
// time. On platforms where there is no birth time available, match all
// os.FileInfo values.
func
BirthtimeIs
(
expected
time
.
Time
)
oglematchers
.
Matcher
{
// Match os.FileInfo values that specify a file birth time within the supplied
// radius of the given time. On platforms where there is no birth time
// available, match all os.FileInfo values.
func
BirthtimeIsWithin
(
expected
time
.
Time
,
d
time
.
Duration
)
oglematchers
.
Matcher
{
return
oglematchers
.
NewMatcher
(
func
(
c
interface
{})
error
{
return
birthtimeIs
(
c
,
expecte
d
)
},
fmt
.
Sprintf
(
"birthtime is
%v"
,
expected
))
func
(
c
interface
{})
error
{
return
birthtimeIs
Within
(
c
,
expected
,
d
)
},
fmt
.
Sprintf
(
"birthtime is
within %v of %v"
,
d
,
expected
))
}
func
birthtimeIs
(
c
interface
{},
expected
time
.
Time
)
error
{
func
birthtimeIsWithin
(
c
interface
{},
expected
time
.
Time
,
d
time
.
Duration
)
error
{
fi
,
ok
:=
c
.
(
os
.
FileInfo
)
if
!
ok
{
return
fmt
.
Errorf
(
"which is of type %v"
,
reflect
.
TypeOf
(
c
))
}
// Check Sys().
if
sysBirthtime
,
ok
:=
extractBirthtime
(
fi
.
Sys
());
ok
{
if
sysBirthtime
!=
expected
{
d
:=
sysBirthtime
.
Sub
(
expected
)
return
fmt
.
Errorf
(
"which has Sys() birthtime %v, off by %v"
,
sysBirthtime
,
d
)
t
,
ok
:=
extractBirthtime
(
fi
.
Sys
())
if
!
ok
{
return
nil
}
diff
:=
t
.
Sub
(
expected
)
absDiff
:=
diff
if
absDiff
<
0
{
absDiff
=
-
absDiff
}
if
!
(
absDiff
<
d
)
{
return
fmt
.
Errorf
(
"which has birth time %v, off by %v"
,
t
,
diff
)
}
return
nil
...
...
samples/memfs/memfs_test.go
View file @
560105ca
...
...
@@ -131,7 +131,7 @@ func (t *MemFSTest) Mkdir_OneLevel() {
ExpectEq
(
0
,
fi
.
Size
())
ExpectEq
(
os
.
ModeDir
|
applyUmask
(
0754
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
createTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectTrue
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
@@ -187,7 +187,7 @@ func (t *MemFSTest) Mkdir_TwoLevels() {
ExpectEq
(
0
,
fi
.
Size
())
ExpectEq
(
os
.
ModeDir
|
applyUmask
(
0754
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
createTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectTrue
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
@@ -296,7 +296,7 @@ func (t *MemFSTest) CreateNewFile_InRoot() {
ExpectEq
(
len
(
contents
),
fi
.
Size
())
ExpectEq
(
applyUmask
(
0400
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
createTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectFalse
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
@@ -338,7 +338,7 @@ func (t *MemFSTest) CreateNewFile_InSubDir() {
ExpectEq
(
len
(
contents
),
fi
.
Size
())
ExpectEq
(
applyUmask
(
0400
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
createTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectFalse
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
@@ -385,7 +385,7 @@ func (t *MemFSTest) ModifyExistingFile_InRoot() {
ExpectEq
(
len
(
"Hello, world!"
),
fi
.
Size
())
ExpectEq
(
applyUmask
(
0600
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
modifyTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectFalse
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
@@ -437,7 +437,7 @@ func (t *MemFSTest) ModifyExistingFile_InSubDir() {
ExpectEq
(
len
(
"Hello, world!"
),
fi
.
Size
())
ExpectEq
(
applyUmask
(
0600
),
fi
.
Mode
())
ExpectThat
(
fi
,
fusetesting
.
MtimeIsWithin
(
modifyTime
,
timeSlop
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
(
createTime
))
ExpectThat
(
fi
,
fusetesting
.
BirthtimeIs
Within
(
createTime
,
timeSlop
))
ExpectFalse
(
fi
.
IsDir
())
ExpectNe
(
0
,
stat
.
Ino
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment