Skip to content

Commit

Permalink
[GR-49254] Repaired DAP tests on Windows and updated weekly jobs.
Browse files Browse the repository at this point in the history
PullRequest: graal/15826
  • Loading branch information
entlicher committed Oct 24, 2023
2 parents 3280f95 + afca052 commit d5a3b1a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 29 deletions.
21 changes: 11 additions & 10 deletions tools/ci/ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup+: [
["cd", "./tools"],
],
timelimit: "30:00",
timelimit: "45:00",
},

local common_guard = {
Expand All @@ -30,8 +30,8 @@
}
},

local tools_gate_lite = tools_common + {
name: 'gate-tools-lite-oraclejdk' + self.jdk_version + '-' + self.os + '-' + self.arch,
local tools_weekly = tools_common + {
name: 'weekly-tools-oraclejdk' + self.jdk_version + '-' + self.os + '-' + self.arch,
run: [
["mx", "build"],
["mx", "unittest", "--verbose"],
Expand Down Expand Up @@ -81,17 +81,18 @@
},

builds: [
common.linux_amd64 + common.oraclejdk20 + tools_gate,
common.linux_amd64 + common.oraclejdk21 + tools_gate,
common.linux_amd64 + common.oraclejdk17 + tools_gate,

common.linux_amd64 + common.oraclejdk20 + tools_javadoc,
common.linux_amd64 + common.oraclejdk21 + tools_javadoc,
common.linux_amd64 + common.oraclejdk17 + tools_coverage_weekly,
common.linux_aarch64 + common.labsjdk17 + tools_gate_lite,
common.linux_aarch64 + common.labsjdk21 + tools_weekly,
common.linux_aarch64 + common.labsjdk17 + tools_weekly,

common.windows_amd64 + common.oraclejdk20 + tools_gate_lite + devkits["windows-jdk20"],
common.windows_amd64 + common.oraclejdk17 + tools_gate_lite + devkits["windows-jdk17"],
common.windows_amd64 + common.oraclejdk21 + tools_weekly + devkits["windows-jdk21"],
common.windows_amd64 + common.oraclejdk17 + tools_weekly + devkits["windows-jdk17"],

common.darwin_amd64 + common.oraclejdk20 + tools_gate_lite,
common.darwin_amd64 + common.oraclejdk17 + tools_gate_lite,
common.darwin_amd64 + common.oraclejdk21 + tools_weekly,
common.darwin_amd64 + common.oraclejdk17 + tools_weekly,
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.truffle.tools.dap.test;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -47,6 +48,7 @@
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
import org.graalvm.shadowed.org.json.JSONArray;
import org.graalvm.shadowed.org.json.JSONException;
import org.graalvm.shadowed.org.json.JSONObject;
import org.junit.Assert;

Expand Down Expand Up @@ -103,6 +105,7 @@ public void finish() throws IOException {
throw new AssertionError("Last eval(...) has not finished yet", ex);
} catch (ExecutionException ex) {
// Guest language execution failed
throw new AssertionError(ex);
}
}
if (handler.getInputStream().available() > 0) {
Expand All @@ -112,7 +115,16 @@ public void finish() throws IOException {

public Future<Value> eval(Source source) {
lastValue = CompletableFuture.supplyAsync(() -> {
return context.eval(source);
try {
return context.eval(source);
} catch (Throwable t) {
// Async exceptions are not visible till we check the future.
// We might never check the future
// if we're blocked by waiting for an expected output,
// which does not come due to the exception.
t.printStackTrace(System.err);
throw t;
}
}, executor);
return lastValue;
}
Expand Down Expand Up @@ -171,7 +183,15 @@ private static byte[] readMessageBytes(InputStream in) throws IOException {
}

public boolean compareReceivedMessages(String... messages) throws Exception {
List<JSONObject> expectedObjects = Arrays.stream(messages).map(message -> new JSONObject(message)).collect(Collectors.toList());
List<JSONObject> expectedObjects = Arrays.stream(messages).map(message -> {
JSONObject json;
try {
json = new JSONObject(message);
} catch (JSONException jex) {
throw new RuntimeException(message, jex);
}
return json;
}).collect(Collectors.toList());
int size = expectedObjects.size();
while (size > 0) {
final String receivedMessage = getMessage();
Expand Down Expand Up @@ -235,6 +255,18 @@ private static boolean compare(JSONObject expectedObject, JSONObject receivedObj
return true;
}

public static String getFilePath(File file) {
String path;
try {
path = file.getCanonicalPath();
} catch (IOException ex) {
path = file.getAbsolutePath();
}
// We need to escape backlash for correct JSON:
path = path.replace("\\", "\\\\");
return path;
}

private static final class ProxyOutputStream extends OutputStream {

OutputStream delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import static org.junit.Assert.assertTrue;
import org.junit.Test;

import static com.oracle.truffle.tools.dap.test.DAPTester.getFilePath;

/**
* Test of SourcePath option.
*/
Expand Down Expand Up @@ -131,7 +133,7 @@ public void testSourcePath() throws Exception {
tester.compareReceivedMessages("{\"event\":\"thread\",\"body\":{\"threadId\":1,\"reason\":\"started\"},\"type\":\"event\",\"seq\":" + (seq++) + "}");
}
// Suspend at the beginning of the script:
String sourceJson = (i == 0) ? "{\"name\":\"" + new File(resolvedURI[i].getPath()).getName() + "\",\"path\":\"" + resolvedURI[i].getPath() + "\"}"
String sourceJson = (i == 0) ? "{\"name\":\"" + new File(resolvedURI[i].getPath()).getName() + "\",\"path\":\"" + getFilePath(new File(resolvedURI[i])) + "\"}"
: "{\"sourceReference\":" + (i + 1) + ",\"path\":\"" + resolvedURI[i].getSchemeSpecificPart() + "\",\"name\":\"test" + (i + 1) + ".file\"}";
tester.compareReceivedMessages(
"{\"event\":\"loadedSource\",\"body\":{\"reason\":\"new\",\"source\":" + sourceJson + "},\"type\":\"event\",\"seq\":" + (seq++) + "}");
Expand Down Expand Up @@ -175,7 +177,7 @@ public void testNonExistingSourcePath() throws Exception {
tester.sendMessage("{\"command\":\"configurationDone\",\"type\":\"request\",\"seq\":5}");
tester.compareReceivedMessages("{\"success\":true,\"type\":\"response\",\"request_seq\":5,\"command\":\"configurationDone\",\"seq\":5}");

String resolvedPath = new File("relative/path").toPath().toAbsolutePath().toString();
String resolvedPath = getFilePath(new File("relative/path"));

tester.eval(source);
String sourceJson = "{\"sourceReference\":1,\"path\":\"" + resolvedPath + "\",\"name\":\"path\"}";
Expand Down Expand Up @@ -219,7 +221,7 @@ private static void testBreakpoints(int sectionLine, int sectionColumn, int bpLi
TestDebugNoContentLanguage language = new TestDebugNoContentLanguage(relativePath, true, true);
ProxyLanguage.setDelegate(language);
Source source = Source.create(ProxyLanguage.ID, sourceContent);
String sourceJson = "{\"name\":\"" + filePath.getFileName() + "\",\"path\":\"" + filePath + "\"}";
String sourceJson = "{\"name\":\"" + filePath.getFileName() + "\",\"path\":\"" + getFilePath(filePath.toFile()) + "\"}";

DAPTester tester = DAPTester.start(false, null, Collections.singletonList(sourcePathURI));
tester.sendMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.junit.Ignore;
import org.junit.Test;

import static com.oracle.truffle.tools.dap.test.DAPTester.getFilePath;

@Ignore("GR-43473")
public final class SimpleLanguageDAPTest {

Expand Down Expand Up @@ -1196,18 +1198,6 @@ private static File createTemporaryFile(String content) throws IOException {
return file;
}

private static String getFilePath(File file) {
String path;
try {
path = file.getCanonicalPath();
} catch (IOException ex) {
path = file.getAbsolutePath();
}
// We need to escape backlash for correct JSON:
path = path.replace("\\", "\\\\");
return path;
}

private static String replaceNewLines(String nl) {
return nl.replace("\n", "\\n").replace("\r", "\\r");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.oracle.truffle.tools.dap.types.LoadedSourceEvent;

import java.net.URI;
import java.nio.file.InvalidPathException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -204,7 +205,7 @@ private Pair<String, Boolean> getPath(Source source, TruffleContext truffleConte
tFile = context.getEnv().getTruffleFile(truffleContext, path);
}
}
} catch (UnsupportedOperationException ex) {
} catch (UnsupportedOperationException | InvalidPathException ex) {
// Unsupported URI/path
}
if (tFile != null) {
Expand All @@ -217,7 +218,7 @@ private Pair<String, Boolean> getPath(Source source, TruffleContext truffleConte
} else if (path != null) {
try {
srcRef = !context.getEnv().getTruffleFile(truffleContext, path).isReadable();
} catch (SecurityException ex) {
} catch (SecurityException | InvalidPathException ex) {
// Can not verify readability
srcRef = true;
}
Expand Down

0 comments on commit d5a3b1a

Please sign in to comment.