fix(ci): bundle Studio protocol fixtures for standalone tests
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

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:
2026-11-19 20:37:44 +00:00
parent da0b1008cc
commit 71b62a8e0a
5 changed files with 31 additions and 12 deletions
@@ -2,7 +2,7 @@ package p.studio.app.runtime.studio;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.nio.file.*;
import java.nio.charset.StandardCharsets;
import java.util.HexFormat;
import p.studio.app.runtime.studio.StudioWire.Reader;
import static org.junit.jupiter.api.Assertions.*;
@@ -16,16 +16,19 @@ class StudioWireTest {
assertEquals(3,logs.size());assertEquals("ready",logs.getFirst().message());
assertEquals(8193,logs.get(1).message().length());assertEquals("last",logs.getLast().message());
}
private byte[] fixture() throws IOException {
String hex=Files.readString(Path.of(System.getProperty("studio.test.protocolFixtures"),"pause.hex"));
return HexFormat.of().parseHex(hex.replaceAll("\\s+",""));
private byte[] fixture(String name) throws IOException {
try (InputStream resource = StudioWireTest.class.getResourceAsStream("/studio-protocol/fixtures/" + name)) {
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 {
assertArrayEquals(fixture(),new Header(PAUSE,0,1,42).encode());
assertEquals(42,Header.decode(fixture()).request());
assertArrayEquals(fixture("pause.hex"),new Header(PAUSE,0,1,42).encode());
assertEquals(42,Header.decode(fixture("pause.hex")).request());
}
@Test void fragmentedReadsWorkButTruncationAndReplayFail() throws Exception {
byte[] bytes=fixture();
byte[] bytes=fixture("pause.hex");
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));}
};
@@ -36,9 +39,9 @@ class StudioWireTest {
assertThrows(IOException.class,reader::receive);
}
@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));}
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,()->frameBytes(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE));
assertThrows(IOException.class,()->frameBytes(480,270,481));
@@ -46,8 +49,7 @@ class StudioWireTest {
assertThrows(IOException.class,()->text(new byte[]{(byte)0xff},0));
}
@Test void rgbaPayloadMatchesSharedFixture() throws Exception {
byte[] bytes=HexFormat.of().parseHex(Files.readString(Path.of(
System.getProperty("studio.test.protocolFixtures"),"rgba.hex")).replaceAll("\\s+",""));
byte[] bytes=fixture("rgba.hex");
var reader=new Reader(new ByteArrayInputStream(bytes));var h=reader.nextHeader();
assertEquals(FRAME,h.kind());assertEquals(56,h.length());
byte[] metadata=new byte[48];reader.readFully(metadata,0,48);