Skip to content

Commit

Permalink
Fix tests on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Sep 26, 2023
1 parent 96b90cb commit 0b99cd4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.ls.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<argLine>${tycho.testArgLine} ${os.testArgs} ${lombokArgs}</argLine>
<argLine>${tycho.testArgLine} ${os.testArgs} "${lombokArgs}"</argLine>
<runOrder>random</runOrder>
<providerProperties>
<excludegroups>org.eclipse.jdt.ls.tests.Unstable</excludegroups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.junit.Test;

public class ResourceUtilsTest {
Expand Down Expand Up @@ -65,6 +67,12 @@ public void testGetLongestCommonPath() {
public void testURIWithQuery() {
String uriStr = "file:///home/user/vscode?windowId=_blank";
IPath path = ResourceUtils.canonicalFilePathFromURI(uriStr);
assertEquals("/home/user/vscode", path.toString());
String expected = Path.fromOSString("/home/user/vscode").toString();
String result = path.toString();
if (Platform.OS_WIN32.equals(Platform.getOS())) {
assertTrue(result.endsWith(expected));
} else {
assertEquals(expected, result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.util.Map;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
Expand Down Expand Up @@ -124,7 +127,19 @@ public void testGetProjectReferencedLibraryPaths() throws Exception {
String[] actualReferencedLibraryPaths = (String[]) options.get(ProjectCommand.REFERENCED_LIBRARIES);
String expectedReferencedLibraryPath = project.getFolder(ProjectUtils.WORKSPACE_LINK).getFolder("lib").getFile("mylib.jar").getLocation().toOSString();
assertTrue(actualReferencedLibraryPaths.length == 1);
assertEquals(expectedReferencedLibraryPath, actualReferencedLibraryPaths[0]);
if (Platform.OS_WIN32.equals(Platform.getOS())) {
IPath expected = new Path(expectedReferencedLibraryPath);
IPath actual = new Path(actualReferencedLibraryPaths[0]);
if (expected.getDevice() != null) {
expected = expected.setDevice(expected.getDevice().toLowerCase());
}
if (actual.getDevice() != null) {
actual = actual.setDevice(actual.getDevice().toLowerCase());
}
assertTrue(expected.equals(actual));
} else {
assertEquals(expectedReferencedLibraryPath, actualReferencedLibraryPaths[0]);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public void assertEquivalent(Either<Command, CodeAction> action) throws Exceptio
}
String actionContent = evaluateCodeActionCommand(action);
actionContent = ResourceUtils.dos2Unix(actionContent);
content = ResourceUtils.dos2Unix(content);
assertEquals(title + " has the wrong content ", content, actionContent);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public void testHoverInheritedJavadoc() throws Exception {
// then
assertNotNull(hover);
String result = hover.getContents().getLeft().get(1).getLeft();//
result = ResourceUtils.dos2Unix(result);
String expected = "This method comes from Foo\n" + "\n" + " * **Parameters:**\n" + " \n" + " * **input** an input String";
assertEquals("Unexpected hover ", expected, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ls.core.internal.ClassFileUtil;
Expand Down Expand Up @@ -81,7 +82,11 @@ public void testNoClassContentSupport() throws Exception {

@Test
public void testDisassembledSource() throws Exception {
testClass("javax.tools.Tool", 6, 57);
if (Platform.OS_WIN32.equals(Platform.getOS())) {
testClass("javax.tools.Tool", 6, 27);
} else {
testClass("javax.tools.Tool", 6, 57);
}
}

@Test
Expand Down

0 comments on commit 0b99cd4

Please sign in to comment.