File tree Expand file tree Collapse file tree
main/java/io/github/easy4j/opencli/parser
test/java/io/github/easy4j/opencli/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44# - push / pull_request on the main branch
55# - manual workflow_dispatch
66#
7- # Runs `mvn -B clean verify` which includes the JaCoCo coverage gate
8- # (90% line coverage, haltOnFailure=false) configured in the POM.
7+ # Runs `mvn -B clean verify` which collects JaCoCo coverage and checks the target
8+ # (90% line coverage, warning only: haltOnFailure=false) configured in the POM.
99name : CI
1010
1111on :
3535 cache : maven
3636
3737 - name : Build and verify with JaCoCo coverage gate
38- run : mvn -B --no-transfer-progress clean verify
38+ run : |
39+ mvn -B --no-transfer-progress clean verify
40+ test -s target/jacoco.exec
41+ test -s target/site/jacoco/jacoco.xml
3942
4043 - name : Upload JaCoCo coverage report
4144 if : always()
Original file line number Diff line number Diff line change 5757 <maven .compiler.source>${java.version} </maven .compiler.source>
5858 <maven .compiler.target>${java.version} </maven .compiler.target>
5959 <maven .version>3.0</maven .version>
60+ <!-- Empty fallback supports direct surefire:test without prepare-agent. -->
61+ <jacocoArgLine ></jacocoArgLine >
6062 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
6163 <!-- Dependency versions -->
6264 <commons-exec .version>1.6.0</commons-exec .version>
6365 <commons-lang .version>2.6</commons-lang .version>
64- <jackson .version>2.17.2 </jackson .version>
66+ <jackson .version>2.22.4 </jackson .version>
6567 <java-websocket .version>1.6.0</java-websocket .version>
6668 <junit-jupiter .version>6.1.0</junit-jupiter .version>
6769 <junit .version>4.13.2</junit .version>
344346 <configuration >
345347 <skip >false</skip >
346348 <skipTests >false</skipTests >
347- <argLine >-Xmx1024m -Dfile.encoding=UTF-8</argLine >
349+ <argLine >@{jacocoArgLine} -Xmx1024m -Dfile.encoding=UTF-8</argLine >
348350 <additionalClasspathElements >
349351 <additionalClasspathElement >${basedir} /target/test-classes</additionalClasspathElement >
350352 </additionalClasspathElements >
423425 <executions >
424426 <execution >
425427 <id >prepare-agent</id >
428+ <configuration >
429+ <propertyName >jacocoArgLine</propertyName >
430+ </configuration >
426431 <goals >
427432 <goal >prepare-agent</goal >
428433 </goals >
Original file line number Diff line number Diff line change @@ -41,7 +41,9 @@ public static JsonNode parseLenient(String stdout) {
4141 }
4242 String trim = stdout .trim ();
4343 try {
44- return MAPPER .readTree (trim );
44+ JsonNode node = MAPPER .readTree (trim );
45+ return node == null || node .isMissingNode ()
46+ ? MAPPER .getNodeFactory ().textNode (stdout ) : node ;
4547 } catch (JsonProcessingException e ) {
4648 log .debug ("stdout is not strict JSON, wrapping as text: {}" , e .getMessage ());
4749 return MAPPER .getNodeFactory ().textNode (stdout );
Original file line number Diff line number Diff line change 99
1010class OpenCliStdoutJsonTest {
1111
12+ @ Test
13+ void shouldPreserveWhitespaceOnlyOutput () {
14+ assertEquals (" \n \t " , OpenCliStdoutJson .parseLenient (" \n \t " ).textValue ());
15+ }
16+
17+ @ Test
18+ void shouldRetainJacksonTwoNodeContract () {
19+ assertTrue (OpenCliStdoutJson .parseLenient ("null" ).isNull ());
20+ assertEquals ("hello" , OpenCliStdoutJson .parseLenient ("\" hello\" " ).textValue ());
21+ assertEquals (42 , OpenCliStdoutJson .parseLenient ("42" ).intValue ());
22+ assertEquals ("{broken" , OpenCliStdoutJson .parseLenient ("{broken" ).textValue ());
23+ }
24+
1225 @ Test
1326 void shouldParseValidJsonObject () {
1427 JsonNode node = OpenCliStdoutJson .parseLenient ("{\" a\" :1}" );
You can’t perform that action at this time.
0 commit comments