Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Prepend JaCoCo agent to existing VM options to better deal with other…
Browse files Browse the repository at this point in the history
… agents.
  • Loading branch information
marchof committed Feb 14, 2012
1 parent c914511 commit 194686b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void testGetAttribute() throws CoreException {
}

@Test
public void testGetAttributeAppended() throws CoreException {
public void testGetAttributePrepended() throws CoreException {
mock.pushResult("ORIGINAL");
assertEquals("ORIGINAL EXTRA", adjusted.getAttribute(
assertEquals("EXTRA ORIGINAL", adjusted.getAttribute(
IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, ""));
}

Expand All @@ -90,7 +90,7 @@ public void testGetAttributes() throws CoreException {
new HashSet<String>(Arrays.asList("otherkey",
IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS)), map.keySet());
assertEquals("othervalue", map.get("otherkey"));
assertEquals("ORIGINAL EXTRA",
assertEquals("EXTRA ORIGINAL",
map.get(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void testAddArgument() throws CoreException {
mock.getMock());
final String arg = config.getAttribute(
IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
assertTrue(arg, arg.startsWith("OTHER -javaagent:"));
assertTrue(arg, arg.startsWith("-javaagent:"));
assertTrue(arg, arg.endsWith("OTHER"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ public Map getAttributes() throws CoreException {
}

private String getVMArguments() throws CoreException {
final StringBuilder sb = new StringBuilder();
sb.append(delegate.getAttribute(KEY, "")); //$NON-NLS-1$
if (sb.length() > 0) {
sb.append(' ');
final String original = delegate.getAttribute(KEY, ""); //$NON-NLS-1$
if (original.length() > 0) {
return extraVMArgument + ' ' + original;
} else {
return extraVMArgument;
}
sb.append(extraVMArgument);
return sb.toString();
}

public boolean isWorkingCopy() {
Expand Down

0 comments on commit 194686b

Please sign in to comment.