changeset 860:206021e7175e

Don't loose command-line error
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 22 Aug 2014 20:52:31 +0200
parents b1b878449326
children 3f4edc3080db
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Wed Aug 13 11:09:17 2014 +0200
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Fri Aug 22 20:52:31 2014 +0200
@@ -111,6 +111,8 @@
       assert e != null;
       throw new MercurialNotFoundException(getCommand(), e);
     }
+    if (e != null)
+      throw new VcsException(message, e);
     throw new VcsException(message);
   }
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java	Wed Aug 13 11:09:17 2014 +0200
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java	Fri Aug 22 20:52:31 2014 +0200
@@ -124,10 +124,16 @@
     }
   }
 
-  @Test(expectedExceptions = VcsException.class)
+  @Test
   public void should_detect_failure_when_delegate_has_exception() throws VcsException {
-    CommandResult commandResult = commandResultFor(execResult().withException(new RuntimeException()));
-    commandResult.checkCommandFailed();
+    RuntimeException error = new RuntimeException();
+    CommandResult commandResult = commandResultFor(execResult().withException(error));
+    try {
+      commandResult.checkCommandFailed();
+      fail("exception is not detected");
+    } catch (VcsException e) {
+      assertEquals(error, e.getCause());
+    }
   }
 
   public void exception_should_not_contain_command_stdout_or_stderr() {