Automated in-game tests
Unit tests cover the engine, but portals have to be seen and crossed in a real game. For that the mod has a development-only test mode: the client drives itself through a scenario, takes screenshots and checks what happened, and the log tells you whether it passed.
The test mode exists only in development runs. It is never active in normal play.
Running a scenario
Section titled “Running a scenario”Pass the ipreforged.devtest Gradle property to any client run:
./gradlew :fabric:1.21.1:runClient -Pipreforged.devtest./gradlew :neoforge:26.1.2:runClient -Pipreforged.devtest=walk./gradlew :forge:1.20.1:runClient -Pipreforged.devtest=netherIt works on every target. Without a value it runs the default scenario. Screenshots are saved to
run/<loader>-<minecraft>/screenshots/.
The default scenario
Section titled “The default scenario”- Waits for the menus and creates a new creative world.
- Flies up into open air and runs
/ipr make 3 4 minecraft:the_end 0 80 0 true true: a two-way, two-sided portal to the End, two blocks ahead. - After about 15 seconds saves
ipr-devtest-1-portal.png, the End seen through the portal. - Flies through and checks that it arrived in the End without any screen showing (a “Loading
terrain” screen fails the test) and with the terrain already there. Then turns around and saves
ipr-devtest-2-way-back.png: the Overworld through the way back, visible at once. - Quits. Progress is logged with the
[devtest]prefix.
Other scenarios
Section titled “Other scenarios”| Scenario | What it checks |
|---|---|
nether |
The same journey through a lit obsidian frame: the frame becomes a portal, a partner frame appears in the Nether, the crossing is seamless, and breaking the frame removes the whole portal and its light. |
return |
Goes to the Nether the vanilla way, lights a frame there and crosses back into the Overworld. Also freezes the client on purpose for 10 seconds near the end, to check that the freeze is reported. |
resume |
Reopens the newest test world instead of creating one. After a nether run the player starts in the Nether and lights a frame towards the Overworld. |
walk |
Walks slowly through a frame standing on the ground. Checks that a block placed on the other side reaches the client without the chunk being resent, that a block right behind the exit is cut out of the view, and turns the camera in circles right at the portal (the regression test for a freeze). |
pingpong |
Crosses the End portal back and forth 40 times; fails if any screen shows. |
netherpong |
The same through a lit Nether frame. |
mobpong |
netherpong with 40 mobs standing next to each side of the portal. |
quickpong |
netherpong, turning back right after each crossing, so that two crossings reach the server almost together. |
inside |
Holds the camera inside the opening at 30, 7, 4.5, 2.5, 1 and 0.3 cm from the surface, at many angles (264 poses), and saves a screenshot of each. At every distance a pose should look almost the same as at 7 cm. |
strip |
A short netherpong that records every frame around each crossing, with timings and screenshots. Set the environment variable IPR_STRIP_SHOTS=0 to skip the screenshots when you measure frame times. |
watch |
Drives nothing: only turns the diagnostics on, for someone playing by hand. |
Every scenario that lights a frame also checks the portal’s light: the log lines light here and
light there count the cells of each opening that hold the light block, as the client sees them,
with the lowest light level found (all cells, at 15). After the frame is broken,
frame broken: its light is gone confirms that no light block is left.
Every scenario also checks remote calls: right after entering the world
the client calls the server with one value of every supported kind, and the server sends them all
back in a call to the client. The line
remote calls: 26 values came back intact, overloads int,String,long, the unmarked method was refused
means it passed; any difference is reported as FAILED: remote calls: .... The check calls a
method without @RemoteEntry on purpose, so a Remote call ... refused warning in the log and a
red line in the chat are expected.
At the end, every scenario runs /nightlib info ipreforged. Its output goes to the log as
[System] [CHAT] lines: NightLib’s Support: link and one line per section of the mod’s
performance report, with the number of samples and
the average, longest and total time.
With Sodium
Section titled “With Sodium”./gradlew :fabric:26.1.2:runClient -Pipreforged.devtest=walk -Pipreforged.sodium-Pipreforged.sodium adds Sodium to the development client, on Fabric and NeoForge, at the
version set in versions/<minecraft>/gradle.properties (deps.sodium_fabric,
deps.sodium_neoforge), downloaded from Modrinth’s Maven repository. Sodium is never compiled
against and never goes into the mod’s jar. On 1.20.1 the property also turns off a check of
Sodium 0.5 that rejects the LWJGL version of development runs.
With Sodium the log says Vanilla's terrain renderer is replaced (...): the mod’s hooks into
vanilla’s terrain renderer are left out.
Reading the log
Section titled “Reading the log”Besides the [devtest] lines, the test mode logs diagnostics that are at debug level in normal
play:
Crossed on the client: <from> -> <to>on the client, on the frame it switched dimension;Portal crossing reported by the clienton the server when the report arrives.Refused the portal crossing reported by ...gives the reason when the server does not accept it, and the client is sent back.Seamless travel (...)on the server, for every crossing: how many chunks of the destination the client already had (they are not sent again), and how many of the level it left it keeps for the view back.After the travel:on the client, 3 seconds after a crossing: frame count, longest frame, slow frames, chunk packets received again (should be 0) and position corrections from the server (should be 0).Slow frame around a crossing:for each slow frame from 1.5 s before to 3 s after a crossing. A frame is slow above 25 ms, or above 2.5 times the usual frame time when that is longer.[devtest] heartbeatevery 5 seconds, with the memory in use.
A clean run has none of these lines: Caught exception in thread, Mixin apply failed,
InvalidInjectionException, Portal view rendering failed.
Freezes
Section titled “Freezes”In any game, not only in tests, if the client thread stops ticking for 8 seconds in a world, the
log gets The client thread has not ticked for N s with the stack of every active thread. With the
test property set (including watch), the threshold is 2 seconds. While a world loads, saves or
connects, the client draws frames without ticking, so the warning waits 60 seconds there.
Closing a run on 26.3
Section titled “Closing a run on 26.3”From 26.3 the game no longer calls System.exit when it closes, and development runs keep two
non-daemon thread pools of Architectury’s runtime transformer alive: Fabric runs used to end with a
Client shutdown from post-main crash report, and NeoForge runs never ended. Every run
configuration passes -Dipreforged.devrun. With it, the mod ends the JVM 5 seconds after the
game’s main returned and prints [ipreforged] The game has closed; ending this development run
on stderr. A player’s game is never ended this way.
Manual test
Section titled “Manual test”- Start a creative world with cheats enabled.
- Run
/ipr make 3 4 minecraft:the_nether ~ ~ ~. - Look at the portal: after a second or two, once its chunks have streamed in, the Nether appears through it. A faint shimmer of particles marks the surface.
- Walk through. You arrive with your speed and direction kept, and no loading screen.
/ipr infodescribes the nearest portal;/ipr removeremoves its group.- Build an obsidian frame of an unusual shape, light it, and walk through it too.
