Skip to content

Commit 5cfa937

Browse files
committed
Exercise bounded legacy streams across OpenCLI platforms
1 parent 68a7bc8 commit 5cfa937

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎.github/workflows/platform-contracts.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: [macos-latest, macos-15-intel, windows-latest]
16+
os: [ubuntu-latest, macos-latest, macos-15-intel, windows-latest]
1717
runs-on: ${{ matrix.os }}
1818
timeout-minutes: 15
1919
defaults:
@@ -44,7 +44,7 @@ jobs:
4444
bash ./mvnw -version > platform-evidence/maven.txt 2>&1
4545
result=0
4646
bash ./mvnw -B --no-transfer-progress \
47-
-Dtest=OpenCliErrorEnvelopeTest,OpenCliBrowserResultTest,OpenCliBrowserEvidenceResultTest,OpenCliDiagnosticsTest,OpenCliInvocationContextTest,OpenCliArgvContractTest,OpenCliStructuredArgvContractTest,OpenCliProcessContractTest,OpenCliProcessBoundaryTest,SubprocessCleanupFaultTest,SubprocessCompletionRaceTest,SubprocessStreamFailureTest,OpenCliWsReverseAgentSessionTest,OpenCliWsCollectRequestsTest,OpenCliRemoteAgentHttpClientTest,OpenCliProcessPrivacyTest,OpenCliArgSupportTest#shouldKeepConversionExceptionAndNestedCausePrivate,SubprocessExecutionSupportTest#shouldKeepNativePathOutOfDefaultHandlerException \
47+
-Dtest=OpenCliErrorEnvelopeTest,OpenCliBrowserResultTest,OpenCliBrowserEvidenceResultTest,OpenCliDiagnosticsTest,OpenCliInvocationContextTest,OpenCliArgvContractTest,OpenCliStructuredArgvContractTest,OpenCliProcessContractTest,OpenCliProcessBoundaryTest,SubprocessCleanupFaultTest,SubprocessCompletionRaceTest,SubprocessStreamFailureTest,OpenCliWsReverseAgentSessionTest,OpenCliWsCollectRequestsTest,OpenCliRemoteAgentHttpClientTest,OpenCliProcessPrivacyTest,OpenCliArgSupportTest#shouldKeepConversionExceptionAndNestedCausePrivate,SubprocessExecutionSupportTest#shouldKeepNativePathOutOfDefaultHandlerException+legacyOutputStreamsAllowBoundedWritesWithoutChangingExecutionDetails \
4848
test > platform-evidence/maven.log 2>&1 || result=$?
4949
tail -100 platform-evidence/maven.log
5050
python scripts/contract_report.py \

‎openspec/changes/harden-opencli-process-lifecycle/tasks.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,9 @@ JDK 17 定向 29 项通过。JDK 21 使用仓库 Maven Wrapper 执行 `-B -ntp -
9898
Java 21 的一次运行中,未知后代仍在更新心跳,JUnit 已开始清理临时目录,产生 DirectoryNotEmptyException。Java 17 回归加入尾部确认后,旧 fixture 实际执行 1 项、失败 1 项,缺少最后一次心跳确认。现在测试发出自己的 release 信号,等待后代在完成所有心跳写入后创建确认文件,再交还临时目录。测试仍在发出 release 之前确认后代存活及取消预算,SDK 的执行和清理逻辑未改动。
9999

100100
各分支使用 Wrapper 分别在 Java 8、17、21 运行 OpenCliProcessContractTest、OpenCliProcessBoundaryTest、SubprocessCompletionRaceTest、OpenCliProcessPrivacyTest,每条线 31 项通过,零失败、零错误、零跳过。报告位于 target/surefire-reports。
101+
102+
## Linux 维度与旧输出流回归
103+
104+
Java 8、21 功能线的平台矩阵加入 Ubuntu,Java 17 保留现有 Ubuntu JVM 作业。三线平台作业均显式选择旧版输出流的有界写入用例。该用例通过本线 JVM 启动现有 LifecycleProbe,检查退出后从旧 API 写入时的字节上限,并验证此前记录的进程截断事实保持准确。
105+
106+
本地 macOS 上用三个分支的 Wrapper 复跑进程契约、结束竞态、读取失败及两个低层用例,每线 24 项通过,零失败、零错误、零跳过。Linux、macOS 和 Windows 的托管证据按精确功能提交核对。

‎src/test/java/io/github/easy4j/opencli/core/support/SubprocessExecutionSupportTest.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.github.easy4j.opencli.core.support;
22

33
import io.github.easy4j.opencli.core.OpenCliExecutionDetails.TerminationReason;
4+
import io.github.easy4j.opencli.contract.LifecycleProbe;
5+
import java.io.File;
46
import java.io.PrintWriter;
57
import java.io.StringWriter;
68
import java.nio.charset.StandardCharsets;
@@ -14,8 +16,12 @@ class SubprocessExecutionSupportTest {
1416

1517
@Test
1618
void legacyOutputStreamsAllowBoundedWritesWithoutChangingExecutionDetails() throws Exception {
17-
CommandLine command = new CommandLine("/usr/bin/printf");
18-
command.addArgument("abc");
19+
String executable = System.getProperty("os.name").startsWith("Windows") ? "java.exe" : "java";
20+
File java = new File(new File(System.getProperty("java.home"), "bin"), executable);
21+
CommandLine command = new CommandLine(java);
22+
command.addArguments(new String[] {"-cp",
23+
System.getProperty("surefire.test.class.path", System.getProperty("java.class.path")),
24+
LifecycleProbe.class.getName(), "stdout", "3"}, false);
1925
SubprocessExecutionSupport.RunSession session = SubprocessExecutionSupport.execute(
2026
new SubprocessExecutionSupport.ExecutionRequest(command, null, null, 10_000L, 5L));
2127

@@ -25,7 +31,7 @@ void legacyOutputStreamsAllowBoundedWritesWithoutChangingExecutionDetails() thro
2531
stdout.write(new byte[]{'x', 'e', 'f'}, 1, 2);
2632
stderr.write(new byte[]{'!'}, 0, 1);
2733

28-
assertArrayEquals("abcde".getBytes(StandardCharsets.UTF_8), stdout.toByteArray());
34+
assertArrayEquals("xxxde".getBytes(StandardCharsets.UTF_8), stdout.toByteArray());
2935
assertTrue(stdout.isOverflowed());
3036
assertArrayEquals(new byte[]{'!'}, stderr.toByteArray());
3137
assertFalse(session.getExecutionDetails().isStdoutTruncated());

0 commit comments

Comments
 (0)