fix(ci): bundle Studio protocol fixtures for standalone tests
Load the fixed protocol vectors from test resources instead of a sibling runtime checkout, preserving all wire assertions. Validation: the Jenkins Gradle command passed under JDK 25 in an isolated Studio checkout without ../runtime; 1064 tests, zero failures, consolidated JaCoCo report generated.
This commit is contained in:
@@ -160,7 +160,6 @@ tasks.register<Test>("headlessMcpDesktopTest") {
|
|||||||
// Subprocess tests exercise the actual Studio main and OS ownership boundaries.
|
// Subprocess tests exercise the actual Studio main and OS ownership boundaries.
|
||||||
tasks.withType<Test>().configureEach {
|
tasks.withType<Test>().configureEach {
|
||||||
systemProperty("studio.test.classpath", sourceSets["test"].runtimeClasspath.asPath)
|
systemProperty("studio.test.classpath", sourceSets["test"].runtimeClasspath.asPath)
|
||||||
systemProperty("studio.test.protocolFixtures", rootProject.file("../runtime/devtools/studio-protocol/fixtures").absolutePath)
|
|
||||||
systemProperty("studio.test.studioHost", providers.gradleProperty("studioPlayHost").getOrElse(
|
systemProperty("studio.test.studioHost", providers.gradleProperty("studioPlayHost").getOrElse(
|
||||||
rootProject.file("../runtime/target/debug/prometeu-host-desktop-winit" + if (System.getProperty("os.name").startsWith("Windows")) ".exe" else "").absolutePath))
|
rootProject.file("../runtime/target/debug/prometeu-host-desktop-winit" + if (System.getProperty("os.name").startsWith("Windows")) ".exe" else "").absolutePath))
|
||||||
systemProperty("studio.test.studioCartridge", rootProject.file("../runtime/test-cartridges/dummy-boy").absolutePath)
|
systemProperty("studio.test.studioCartridge", rootProject.file("../runtime/test-cartridges/dummy-boy").absolutePath)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package p.studio.app.runtime.studio;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.*;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HexFormat;
|
import java.util.HexFormat;
|
||||||
import p.studio.app.runtime.studio.StudioWire.Reader;
|
import p.studio.app.runtime.studio.StudioWire.Reader;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@@ -16,16 +16,19 @@ class StudioWireTest {
|
|||||||
assertEquals(3,logs.size());assertEquals("ready",logs.getFirst().message());
|
assertEquals(3,logs.size());assertEquals("ready",logs.getFirst().message());
|
||||||
assertEquals(8193,logs.get(1).message().length());assertEquals("last",logs.getLast().message());
|
assertEquals(8193,logs.get(1).message().length());assertEquals("last",logs.getLast().message());
|
||||||
}
|
}
|
||||||
private byte[] fixture() throws IOException {
|
private byte[] fixture(String name) throws IOException {
|
||||||
String hex=Files.readString(Path.of(System.getProperty("studio.test.protocolFixtures"),"pause.hex"));
|
try (InputStream resource = StudioWireTest.class.getResourceAsStream("/studio-protocol/fixtures/" + name)) {
|
||||||
return HexFormat.of().parseHex(hex.replaceAll("\\s+",""));
|
assertNotNull(resource, "Missing protocol fixture: " + name);
|
||||||
|
String hex = new String(resource.readAllBytes(), StandardCharsets.US_ASCII);
|
||||||
|
return HexFormat.of().parseHex(hex.replaceAll("\\s+", ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Test void headerMatchesSharedRustFixture() throws Exception {
|
@Test void headerMatchesSharedRustFixture() throws Exception {
|
||||||
assertArrayEquals(fixture(),new Header(PAUSE,0,1,42).encode());
|
assertArrayEquals(fixture("pause.hex"),new Header(PAUSE,0,1,42).encode());
|
||||||
assertEquals(42,Header.decode(fixture()).request());
|
assertEquals(42,Header.decode(fixture("pause.hex")).request());
|
||||||
}
|
}
|
||||||
@Test void fragmentedReadsWorkButTruncationAndReplayFail() throws Exception {
|
@Test void fragmentedReadsWorkButTruncationAndReplayFail() throws Exception {
|
||||||
byte[] bytes=fixture();
|
byte[] bytes=fixture("pause.hex");
|
||||||
InputStream fragmented=new FilterInputStream(new ByteArrayInputStream(bytes)) {
|
InputStream fragmented=new FilterInputStream(new ByteArrayInputStream(bytes)) {
|
||||||
@Override public int read(byte[] b,int off,int len)throws IOException {return super.read(b,off,Math.min(len,3));}
|
@Override public int read(byte[] b,int off,int len)throws IOException {return super.read(b,off,Math.min(len,3));}
|
||||||
};
|
};
|
||||||
@@ -36,9 +39,9 @@ class StudioWireTest {
|
|||||||
assertThrows(IOException.class,reader::receive);
|
assertThrows(IOException.class,reader::receive);
|
||||||
}
|
}
|
||||||
@Test void validatesBeforeAllocatingPayload() throws Exception {
|
@Test void validatesBeforeAllocatingPayload() throws Exception {
|
||||||
for(int offset:new int[]{0,4,6,8,10}) {byte[] bad=fixture();bad[offset]=(byte)255;
|
for(int offset:new int[]{0,4,6,8,10}) {byte[] bad=fixture("pause.hex");bad[offset]=(byte)255;
|
||||||
assertThrows(IOException.class,()->Header.decode(bad));}
|
assertThrows(IOException.class,()->Header.decode(bad));}
|
||||||
byte[] huge=fixture();java.util.Arrays.fill(huge,12,16,(byte)255);
|
byte[] huge=fixture("pause.hex");java.util.Arrays.fill(huge,12,16,(byte)255);
|
||||||
assertThrows(IOException.class,()->Header.decode(huge));
|
assertThrows(IOException.class,()->Header.decode(huge));
|
||||||
assertThrows(IOException.class,()->frameBytes(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE));
|
assertThrows(IOException.class,()->frameBytes(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE));
|
||||||
assertThrows(IOException.class,()->frameBytes(480,270,481));
|
assertThrows(IOException.class,()->frameBytes(480,270,481));
|
||||||
@@ -46,8 +49,7 @@ class StudioWireTest {
|
|||||||
assertThrows(IOException.class,()->text(new byte[]{(byte)0xff},0));
|
assertThrows(IOException.class,()->text(new byte[]{(byte)0xff},0));
|
||||||
}
|
}
|
||||||
@Test void rgbaPayloadMatchesSharedFixture() throws Exception {
|
@Test void rgbaPayloadMatchesSharedFixture() throws Exception {
|
||||||
byte[] bytes=HexFormat.of().parseHex(Files.readString(Path.of(
|
byte[] bytes=fixture("rgba.hex");
|
||||||
System.getProperty("studio.test.protocolFixtures"),"rgba.hex")).replaceAll("\\s+",""));
|
|
||||||
var reader=new Reader(new ByteArrayInputStream(bytes));var h=reader.nextHeader();
|
var reader=new Reader(new ByteArrayInputStream(bytes));var h=reader.nextHeader();
|
||||||
assertEquals(FRAME,h.kind());assertEquals(56,h.length());
|
assertEquals(FRAME,h.kind());assertEquals(56,h.length());
|
||||||
byte[] metadata=new byte[48];reader.readFully(metadata,0,48);
|
byte[] metadata=new byte[48];reader.readFully(metadata,0,48);
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Studio protocol test vectors
|
||||||
|
|
||||||
|
These protocol 1.0 vectors mirror `devtools/studio-protocol/fixtures` in
|
||||||
|
`prometeu-runtime`. Keep both copies identical when changing the protocol.
|
||||||
|
|
||||||
|
`pause.hex` checks the control header; `rgba.hex` checks frame metadata and pixels.
|
||||||
|
They are fixed reference bytes, independent of the Java encoder under test.
|
||||||
|
Studio unit tests load these resources from the classpath so a standalone checkout
|
||||||
|
does not need a sibling runtime repository. Cross-repository qualification belongs
|
||||||
|
to `prometeu-tooling`.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
50 53 54 31 01 00 00 00 04 00 00 00 00 00 00 00
|
||||||
|
01 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
50 53 54 31 01 00 00 00 09 00 00 00 38 00 00 00
|
||||||
|
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||||
|
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
|
||||||
|
01 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00
|
||||||
|
02 00 00 00 01 00 00 00 02 00 00 00 01 00 00 00
|
||||||
|
ff 00 00 ff 00 00 ff 80
|
||||||
Reference in New Issue
Block a user