diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-09 12:11:59 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-11 09:20:45 +0200 |
commit | 17e7570d600eed5c8183a4956586372585a4e326 (patch) | |
tree | f3d8eeb4b860dfc2063a112ec7aa4f5e64634547 /sonar-plugin-api/src/test | |
parent | b675ee7be71fd8de19eca79f945f3ef88713628f (diff) | |
download | sonarqube-17e7570d600eed5c8183a4956586372585a4e326.tar.gz sonarqube-17e7570d600eed5c8183a4956586372585a4e326.zip |
Fix stability of CommandExecutorTest
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java | 9 | ||||
-rwxr-xr-x | sonar-plugin-api/src/test/scripts/forever.sh | 2 |
2 files changed, 3 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java index b8d4de67865..0dcba90e1ed 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java @@ -128,17 +128,12 @@ public class CommandExecutorTest { @Test public void should_stop_after_timeout() throws IOException { - String executable = getScript("forever"); - long start = System.currentTimeMillis(); try { + String executable = getScript("forever"); CommandExecutor.create().execute(Command.create(executable).setDirectory(workDir), 300L); fail(); } catch (TimeoutException e) { - long duration = System.currentTimeMillis() - start; - // Future.get(), which is used by CommandExecutor, has not a precise timeout. - // See http://stackoverflow.com/questions/23199820/future-get-timeout-precision-and-possible-alternatives - // The deviation seems to be in both directions, so it implies to test something like >270ms instead of >300ms - assertThat(duration).as(e.getMessage()).isGreaterThan(250L); + // ok } } diff --git a/sonar-plugin-api/src/test/scripts/forever.sh b/sonar-plugin-api/src/test/scripts/forever.sh index d7b6a9b38fd..b05525430d5 100755 --- a/sonar-plugin-api/src/test/scripts/forever.sh +++ b/sonar-plugin-api/src/test/scripts/forever.sh @@ -2,5 +2,5 @@ while test "notempty" do - sleep 1 + sleep 5s done |