From 9bac0d904de69a5600714bf05d48c12b746f643d Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 30 Oct 2017 14:59:57 +0100 Subject: [PATCH] [tests] fixes passed time measurement in updater test --- updater/testSrc/com/intellij/updater/UtilsTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/updater/testSrc/com/intellij/updater/UtilsTest.java b/updater/testSrc/com/intellij/updater/UtilsTest.java index f45dfa1974b9..0915b7096252 100644 --- a/updater/testSrc/com/intellij/updater/UtilsTest.java +++ b/updater/testSrc/com/intellij/updater/UtilsTest.java @@ -66,20 +66,20 @@ public class UtilsTest { File f = tempDir.newFile("temp_file"); assertTrue(f.exists()); - long millis = 0; + long ts = 0; try (FileWriter fw = new FileWriter(f)) { // This locks the file on Windows, preventing it from being deleted. // Utils.delete() will retry for about 100 ms. fw.write("test"); - millis = System.currentTimeMillis(); + ts = System.nanoTime(); Utils.delete(f); fail("Utils.delete did not fail with the expected IOException on Windows"); } catch (IOException e) { - millis = System.currentTimeMillis() - millis; + ts = (System.nanoTime() - ts) / 1_000_000; assertEquals("Cannot delete: " + f.getAbsolutePath(), e.getMessage()); - assertThat(millis).as("Utils.delete took " + millis + " ms, which is less than expected").isGreaterThanOrEqualTo(100); + assertThat(ts).as("Utils.delete took " + ts + " ms, which is less than expected").isGreaterThanOrEqualTo(100); } }