This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 47586f27c fix(javascript): fix flaky javascript idl tests (#3565)
47586f27c is described below
commit 47586f27c793a8ce7bf0c5ef29d0d9236df123f1
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Apr 14 20:06:22 2026 +0800
fix(javascript): fix flaky javascript idl tests (#3565)
## Why?
## What does this PR do?
## Related issues
#3394
## AI Contribution Checklist
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review`
summary and screenshot evidence of the final clean AI review results
from both fresh reviewers on the current PR diff or current HEAD after
the latest code changes.
## Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
---
.../apache/fory/idl_tests/IdlRoundTripTest.java | 61 +++++++++++++++++++---
1 file changed, 53 insertions(+), 8 deletions(-)
diff --git
a/integration_tests/idl_tests/java/src/test/java/org/apache/fory/idl_tests/IdlRoundTripTest.java
b/integration_tests/idl_tests/java/src/test/java/org/apache/fory/idl_tests/IdlRoundTripTest.java
index 64b27ab17..95a72c7fe 100644
---
a/integration_tests/idl_tests/java/src/test/java/org/apache/fory/idl_tests/IdlRoundTripTest.java
+++
b/integration_tests/idl_tests/java/src/test/java/org/apache/fory/idl_tests/IdlRoundTripTest.java
@@ -69,8 +69,10 @@ import monster.Color;
import monster.Monster;
import monster.MonsterForyRegistration;
import monster.Vec3;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -729,30 +731,73 @@ public class IdlRoundTripTest {
private void runPeer(PeerCommand command, String peer) throws IOException,
InterruptedException {
ProcessBuilder builder = new ProcessBuilder(command.command);
- builder.inheritIO();
+ // Keep peer output off the forked JVM stdio so Surefire's control channel
+ // cannot be corrupted by child process logs.
+ builder.redirectErrorStream(true);
builder.directory(command.workDir.toFile());
builder.environment().putAll(command.environment);
Process process = builder.start();
+ PeerOutputCollector outputCollector = new
PeerOutputCollector(process.getInputStream(), peer);
+ outputCollector.start();
boolean finished = process.waitFor(180, TimeUnit.SECONDS);
if (!finished) {
process.destroyForcibly();
- Assert.fail("Peer process timed out for " + peer);
+ process.waitFor(10, TimeUnit.SECONDS);
+ String output = outputCollector.awaitOutput();
+ Assert.fail(
+ "Peer process timed out for "
+ + peer
+ + (output.isEmpty() ? "" : "\noutput:\n" + output));
}
int exitCode = process.exitValue();
- String stdout = new String(process.getInputStream().readAllBytes(),
StandardCharsets.UTF_8);
- String stderr = new String(process.getErrorStream().readAllBytes(),
StandardCharsets.UTF_8);
+ String output = outputCollector.awaitOutput();
if (exitCode != 0) {
Assert.fail(
"Peer process failed for "
+ peer
+ " with exit code "
+ exitCode
- + "\nstdout:\n"
- + stdout
- + "\nstderr:\n"
- + stderr);
+ + (output.isEmpty() ? "" : "\noutput:\n" + output));
+ }
+ }
+
+ private static final class PeerOutputCollector extends Thread {
+ private final InputStream inputStream;
+ private final ByteArrayOutputStream outputStream = new
ByteArrayOutputStream();
+ private IOException readFailure;
+
+ private PeerOutputCollector(InputStream inputStream, String peer) {
+ super("idl-peer-output-" + peer);
+ setDaemon(true);
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ public void run() {
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ try {
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ } catch (IOException e) {
+ readFailure = e;
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+
+ private String awaitOutput() throws IOException, InterruptedException {
+ join();
+ if (readFailure != null) {
+ throw readFailure;
+ }
+ return new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]