|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ludovic Henry <git@ludovic.dev> |
| 3 | +Date: Wed, 30 Sep 2026 00:00:00 +0000 |
| 4 | +Subject: [PATCH] tests: tolerate a riscv64 JVM stdout warning in |
| 5 | + test_jvm_options |
| 6 | + |
| 7 | +test_jvm_options spawns a subprocess that imports jnius (starting the JVM) |
| 8 | +and then json.dumps the JVM's own input arguments straight to stdout, |
| 9 | +which the parent process parses with json.loads(stdoutdata.decode()). |
| 10 | + |
| 11 | +On riscv64 the JVM itself prints a startup diagnostic to stdout before |
| 12 | +any Python code runs: |
| 13 | + |
| 14 | + WARNING: Not able to assign machine() = riscv64 to a cpu value! |
| 15 | + Using cpu = 'riscv64' instead! |
| 16 | + |
| 17 | +That line lands ahead of the JSON in the same stdout stream, so |
| 18 | +json.loads sees "WARNING: ...\n[...]" and fails with |
| 19 | +JSONDecodeError: Expecting value: line 1 column 1 (char 0), even though |
| 20 | +the JVM started fine and the arguments round-tripped correctly. The |
| 21 | +child's own json.dump() output is always the last line written, so |
| 22 | +parse only that line instead of the whole stream. |
| 23 | + |
| 24 | +Upstream-Status: To upstream [not yet submitted; riscv64-specific JVM startup diagnostic, no reference to check it against yet] |
| 25 | + |
| 26 | +Signed-off-by: Ludovic Henry <git@ludovic.dev> |
| 27 | +--- |
| 28 | +--- a/tests/test_jvm_options.py |
| 29 | ++++ b/tests/test_jvm_options.py |
| 30 | +@@ -27,5 +27,8 @@ |
| 31 | + bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
| 32 | + stdoutdata, _ = process.communicate(json.dumps(options).encode()) |
| 33 | + assert process.wait() == 0 |
| 34 | +- actual_options = json.loads(stdoutdata.decode()) |
| 35 | ++ # The JVM itself can print a startup diagnostic to stdout ahead of |
| 36 | ++ # the child's own json.dump() output; that dump is always the last |
| 37 | ++ # line written, so parse only it. |
| 38 | ++ actual_options = json.loads(stdoutdata.decode().splitlines()[-1]) |
| 39 | + assert list(sorted(options)) == list(sorted(actual_options)) |
0 commit comments