Skip to content

Commit df05d86

Browse files
committed
ci: added IT tests
1 parent 9e5501b commit df05d86

7 files changed

Lines changed: 128 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ jobs:
2626

2727
- name: Build and verify
2828
run: ./mvnw --no-transfer-progress --batch-mode verify
29+
30+
- name: Run IT tests
31+
shell: bash
32+
run: |
33+
MVN="./mvnw --no-transfer-progress --batch-mode verify -DskipITs=false -Dsurefire.skip=true"
34+
if [[ "$RUNNER_OS" == "Linux" ]]; then
35+
# Allocate a PTY so /dev/tty is available for the Terminal IT tests
36+
script -q -e -c "$MVN" /dev/null
37+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
38+
# BSD script: command args follow the output file
39+
script -q /dev/null $MVN
40+
else
41+
$MVN
42+
fi

miniterm-ffm/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@
107107
<argLine>--enable-native-access=ALL-UNNAMED</argLine>
108108
</configuration>
109109
</plugin>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-failsafe-plugin</artifactId>
113+
<configuration>
114+
<argLine>--enable-native-access=ALL-UNNAMED</argLine>
115+
<forkCount>0</forkCount>
116+
</configuration>
117+
<executions>
118+
<execution>
119+
<goals>
120+
<goal>integration-test</goal>
121+
<goal>verify</goal>
122+
</goals>
123+
</execution>
124+
</executions>
125+
</plugin>
110126
<plugin>
111127
<groupId>com.diffplug.spotless</groupId>
112128
<artifactId>spotless-maven-plugin</artifactId>

miniterm-ffm/src/main/java/org/codejive/miniterm/windows/FfmWindowsTerminal.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public final class FfmWindowsTerminal implements Terminal {
3333
private final MemorySegment inputRecord;
3434
private final MemorySegment intBuffer;
3535

36-
private final int savedInputMode;
37-
private final int savedOutputMode;
36+
private int savedInputMode;
37+
private int savedOutputMode;
3838
private boolean rawModeEnabled;
3939
private volatile Consumer<Size> resizeHandler;
4040

@@ -59,28 +59,26 @@ public FfmWindowsTerminal() throws IOException {
5959
inputRecord = arena.allocate(Kernel32.INPUT_RECORD_LAYOUT);
6060
intBuffer = arena.allocate(ValueLayout.JAVA_INT);
6161

62+
rawModeEnabled = false;
63+
}
64+
65+
@Override
66+
public void enableRawMode() throws IOException {
67+
if (rawModeEnabled) {
68+
return;
69+
}
70+
6271
// Save original console modes
6372
if (Kernel32.getConsoleMode(inputHandle, intBuffer) == 0) {
64-
arena.close();
6573
throw new RuntimeException("Failed to get input console mode");
6674
}
6775
savedInputMode = intBuffer.get(ValueLayout.JAVA_INT, 0);
6876

6977
if (Kernel32.getConsoleMode(outputHandle, intBuffer) == 0) {
70-
arena.close();
7178
throw new RuntimeException("Failed to get output console mode");
7279
}
7380
savedOutputMode = intBuffer.get(ValueLayout.JAVA_INT, 0);
7481

75-
rawModeEnabled = false;
76-
}
77-
78-
@Override
79-
public void enableRawMode() throws IOException {
80-
if (rawModeEnabled) {
81-
return;
82-
}
83-
8482
// Set input mode: disable line input, echo, and processed input; enable VT input
8583
var newInputMode =
8684
savedInputMode
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright TamboUI and miniterm Contributors
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
package org.codejive.miniterm;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
import java.io.IOException;
10+
import org.junit.jupiter.api.Test;
11+
12+
class TerminalIT {
13+
14+
@Test
15+
void terminalCanBeCreatedAndClosed() throws IOException {
16+
Terminal terminal = Terminal.create();
17+
try {
18+
assertThat(terminal).isNotNull();
19+
assertThat(terminal.charset()).isNotNull();
20+
assertThat(terminal.rawModeEnabled()).isFalse();
21+
} finally {
22+
terminal.close();
23+
}
24+
}
25+
}

miniterm/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@
8080
</archive>
8181
</configuration>
8282
</plugin>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-failsafe-plugin</artifactId>
86+
<executions>
87+
<execution>
88+
<goals>
89+
<goal>integration-test</goal>
90+
<goal>verify</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
8395
<plugin>
8496
<groupId>com.diffplug.spotless</groupId>
8597
<artifactId>spotless-maven-plugin</artifactId>
@@ -244,6 +256,25 @@
244256
</plugins>
245257
</build>
246258
</profile>
259+
<profile>
260+
<id>macos-it</id>
261+
<activation>
262+
<os><family>mac</family></os>
263+
</activation>
264+
<build>
265+
<plugins>
266+
<plugin>
267+
<groupId>org.apache.maven.plugins</groupId>
268+
<artifactId>maven-failsafe-plugin</artifactId>
269+
<configuration>
270+
<!-- On macOS the forked JVM's stdin is a pipe, not a TTY.
271+
Running in-process avoids the fork so /dev/stdin remains a PTY. -->
272+
<forkCount>0</forkCount>
273+
</configuration>
274+
</plugin>
275+
</plugins>
276+
</build>
277+
</profile>
247278
</profiles>
248279

249280
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright TamboUI and miniterm Contributors
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
package org.codejive.miniterm;
6+
7+
import static org.assertj.core.api.Assertions.assertThat;
8+
9+
import java.io.IOException;
10+
import org.junit.jupiter.api.Test;
11+
12+
class TerminalIT {
13+
14+
@Test
15+
void terminalCanBeCreatedAndClosed() throws IOException {
16+
Terminal terminal = Terminal.create();
17+
try {
18+
assertThat(terminal).isNotNull();
19+
assertThat(terminal.charset()).isNotNull();
20+
assertThat(terminal.rawModeEnabled()).isFalse();
21+
} finally {
22+
terminal.close();
23+
}
24+
}
25+
}

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
<properties>
4848
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
49+
<skipITs>true</skipITs>
4950

5051
<!-- Dependency versions -->
5152
<version.jspecify>1.0.0</version.jspecify>
@@ -99,6 +100,11 @@
99100
<artifactId>maven-surefire-plugin</artifactId>
100101
<version>3.5.5</version>
101102
</plugin>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-failsafe-plugin</artifactId>
106+
<version>3.5.5</version>
107+
</plugin>
102108
<plugin>
103109
<groupId>org.apache.maven.plugins</groupId>
104110
<artifactId>maven-jar-plugin</artifactId>

0 commit comments

Comments
 (0)