Skip to content

Commit e91aa35

Browse files
committed
Skip last modified smoke test on Windows
Windows file system last modified times seem to vary wildly. The variation is sometimes as much as 9 seconds. Rather than set a very large size, skip the last modified test on Windows.
1 parent ca5e316 commit e91aa35

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/test/java/jenkins/plugins/git/GitSCMFileSystemTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.eclipse.jgit.lib.ObjectId;
4848
import org.jenkinsci.plugins.gitclient.Git;
4949
import org.jenkinsci.plugins.gitclient.GitClient;
50+
import org.junit.Assume;
5051
import org.junit.BeforeClass;
5152
import org.junit.ClassRule;
5253
import org.junit.Rule;
@@ -194,20 +195,21 @@ public void slashyBranches() throws Exception {
194195

195196
@Test
196197
public void lastModified_Smokes() throws Exception {
198+
Assume.assumeTrue("Windows file system last modify dates not trustworthy", !isWindows());
197199
sampleRepo.init();
198200
sampleRepo.git("checkout", "-b", "dev");
199201
SCMSource source = new GitSCMSource(null, sampleRepo.toString(), "", "*", "", true);
200202
SCMRevision revision = source.fetch(new GitBranchSCMHead("dev"), null);
201203
sampleRepo.write("file", "modified");
202204
sampleRepo.git("commit", "--all", "--message=dev");
203-
final long fileSystemAllowedOffset = isWindows() ? 4000 : 1500;
205+
final long fileSystemAllowedOffset = 1500;
204206
SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("dev"), revision);
205-
long currentTime = isWindows() ? System.currentTimeMillis() / 1000L * 1000L : System.currentTimeMillis();
207+
long currentTime = System.currentTimeMillis();
206208
long lastModified = fs.lastModified();
207209
assertThat(lastModified, greaterThanOrEqualTo(currentTime - fileSystemAllowedOffset));
208210
assertThat(lastModified, lessThanOrEqualTo(currentTime + fileSystemAllowedOffset));
209211
SCMFile file = fs.getRoot().child("file");
210-
currentTime = isWindows() ? System.currentTimeMillis() / 1000L * 1000L : System.currentTimeMillis();
212+
currentTime = System.currentTimeMillis();
211213
lastModified = file.lastModified();
212214
assertThat(lastModified, greaterThanOrEqualTo(currentTime - fileSystemAllowedOffset));
213215
assertThat(lastModified, lessThanOrEqualTo(currentTime + fileSystemAllowedOffset));

0 commit comments

Comments
 (0)