Skip to content

Commit

Permalink
fix: path separator in vfs (#19061)
Browse files Browse the repository at this point in the history
Fix decision on file separator
character according to string
instead of OS.

Fix ide test to use same format
for file path.

Fixes #19046
  • Loading branch information
caalador committed Mar 28, 2024
1 parent 5675604 commit f817aa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -469,7 +469,7 @@ private static File getPhysicalFileOfJBossVfsJar(URL url)
String vfsJarPath = url.toString();
String fileNamePrefix = vfsJarPath.substring(
vfsJarPath.lastIndexOf(
FrontendUtils.isWindows() ? '\\' : '/') + 1,
vfsJarPath.contains("\\") ? '\\' : '/') + 1,
vfsJarPath.lastIndexOf(".jar"));
Path tempJar = Files.createTempFile(fileNamePrefix, ".jar");

Expand Down
Expand Up @@ -9,9 +9,12 @@
import java.util.Optional;

import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.mockito.Mockito;

import com.vaadin.open.OSUtils;

public class OpenInCurrentIdeTest {

@Test
Expand Down Expand Up @@ -46,7 +49,8 @@ public void ideaOnMacDetected() throws IOException {
// The binary on Mac is /.../IntelliJ IDEA.app/Contents/MacOS/idea
Assert.assertEquals(
new File(baseDirectory, "MacOS/idea").getAbsolutePath(),
OpenInCurrentIde.getBinary(ideCommand.get()));
new File(OpenInCurrentIde.getBinary(ideCommand.get()))
.getAbsolutePath());

}

Expand Down Expand Up @@ -605,6 +609,8 @@ private Info mock(String cmd, String cmdline) {

@Test
public void runThrowsExceptionOnFailure() throws InterruptedException {
Assume.assumeFalse(OSUtils.isWindows());

try {
OpenInCurrentIde.run("/bin/sh", "-c",
"echo 'output1'; echo 'output2'; exit 123");
Expand Down

0 comments on commit f817aa0

Please sign in to comment.