@@ -68,8 +68,8 @@ describe('.dest() with custom times', function() {
68
68
return ;
69
69
}
70
70
71
- // Use the mtime of this file to have proper resolution
72
- var mtime = fs . statSync ( __filename ) . mtime ;
71
+ // Use new mtime
72
+ var mtime = new Date ( Date . now ( ) - 2048 ) ;
73
73
74
74
var futimesSpy = expect . spyOn ( fs , 'futimes' ) . andCallThrough ( ) ;
75
75
@@ -83,10 +83,14 @@ describe('.dest() with custom times', function() {
83
83
} ) ;
84
84
85
85
function assert ( ) {
86
- var stats = fs . lstatSync ( outputPath ) ;
87
-
88
86
expect ( futimesSpy . calls . length ) . toEqual ( 1 ) ;
89
- expect ( stats . mtime . getTime ( ) ) . toEqual ( mtime . getTime ( ) ) ;
87
+
88
+ // Compare args instead of fs.lstats(), since mtime may be drifted in x86 Node.js
89
+ var mtimeSpy = futimesSpy . calls [ 0 ] . arguments [ 2 ] ;
90
+
91
+ expect ( mtimeSpy . getTime ( ) )
92
+ . toEqual ( mtime . getTime ( ) ) ;
93
+
90
94
expect ( file . stat . mtime ) . toEqual ( mtime ) ;
91
95
}
92
96
@@ -136,8 +140,8 @@ describe('.dest() with custom times', function() {
136
140
return ;
137
141
}
138
142
139
- // Use the mtime of this file to have proper resolution
140
- var mtime = fs . lstatSync ( __filename ) . mtime ;
143
+ // Use new mtime
144
+ var mtime = new Date ( Date . now ( ) - 2048 ) ;
141
145
var invalidAtime = new Date ( undefined ) ;
142
146
143
147
var futimesSpy = expect . spyOn ( fs , 'futimes' ) . andCallThrough ( ) ;
@@ -153,10 +157,11 @@ describe('.dest() with custom times', function() {
153
157
} ) ;
154
158
155
159
function assert ( ) {
156
- var stats = fs . lstatSync ( outputPath ) ;
157
-
158
160
expect ( futimesSpy . calls . length ) . toEqual ( 1 ) ;
159
- expect ( stats . mtime . getTime ( ) ) . toEqual ( mtime . getTime ( ) ) ;
161
+
162
+ var mtimeSpy = futimesSpy . calls [ 0 ] . arguments [ 2 ] ;
163
+
164
+ expect ( mtimeSpy . getTime ( ) ) . toEqual ( mtime . getTime ( ) ) ;
160
165
}
161
166
162
167
pipe ( [
@@ -172,9 +177,11 @@ describe('.dest() with custom times', function() {
172
177
return ;
173
178
}
174
179
175
- // Use the atime/mtime of this file to have proper resolution
176
- var atime = fs . lstatSync ( __filename ) . atime ;
177
- var mtime = fs . lstatSync ( __filename ) . mtime ;
180
+ // Use new atime/mtime
181
+ var atime = new Date ( Date . now ( ) - 2048 ) ;
182
+ var mtime = new Date ( Date . now ( ) - 1024 ) ;
183
+
184
+ var futimesSpy = expect . spyOn ( fs , 'futimes' ) . andCallThrough ( ) ;
178
185
179
186
var file = new File ( {
180
187
base : inputBase ,
@@ -187,10 +194,13 @@ describe('.dest() with custom times', function() {
187
194
} ) ;
188
195
189
196
function assert ( ) {
190
- var stats = fs . lstatSync ( outputPath ) ;
197
+ expect ( futimesSpy . calls . length ) . toEqual ( 1 ) ;
198
+
199
+ var atimeSpy = futimesSpy . calls [ 0 ] . arguments [ 1 ] ;
200
+ var mtimeSpy = futimesSpy . calls [ 0 ] . arguments [ 2 ] ;
191
201
192
- expect ( stats . atime . getTime ( ) ) . toEqual ( atime . getTime ( ) ) ;
193
- expect ( stats . mtime . getTime ( ) ) . toEqual ( mtime . getTime ( ) ) ;
202
+ expect ( atimeSpy . getTime ( ) ) . toEqual ( atime . getTime ( ) ) ;
203
+ expect ( mtimeSpy . getTime ( ) ) . toEqual ( mtime . getTime ( ) ) ;
194
204
expect ( file . stat . mtime ) . toEqual ( mtime ) ;
195
205
expect ( file . stat . atime ) . toEqual ( atime ) ;
196
206
} ;
0 commit comments