Skip to content

feat: Add client gametest for tank rendering verification#21

Merged
turtton merged 6 commits intomainfrom
test/tank-rendering
Mar 9, 2026
Merged

feat: Add client gametest for tank rendering verification#21
turtton merged 6 commits intomainfrom
test/tank-rendering

Conversation

@turtton
Copy link
Owner

@turtton turtton commented Mar 9, 2026

Summary

  • Fabric のクライアントゲームテスト機能を使い、タンク描画のスクリーンショットベース検証テストを追加
  • clientGametest ソースセットを手動作成し、サーバー側 gametest と分離
  • CI に client-game-test ジョブを追加(スクリーンショットをアーティファクトとして保存)

テストケース

  1. 空のタンク単体
  2. 水で満タンのタンク (fillLevel = 1.0)
  3. 水が半分のタンク (fillLevel ≈ 0.5)
  4. 水平連結タンク(横 2 つ並び)
  5. 縦積みタンク(縦 2 つ)

その他の変更

  • CTBlocks.syncGroupBlockEntities の可視性を internalpublic に変更(テストモジュールからのアクセスに必要)
  • .gitignore/net/ を追加(Loom デコンパイルソース除外)

Test plan

  • ./gradlew build 通過
  • ./gradlew spotlessCheck 通過
  • ./gradlew runClientGameTest でスクリーンショットが build/run/clientGameTest/screenshots/ に生成されることを確認
  • CI の client-game-test ジョブが成功し、スクリーンショットがアーティファクトにアップロードされることを確認

turtton added 5 commits March 9, 2026 16:57
…cation

- clientGametest ソースセットを手動作成し、サーバー側 gametest と分離
- FabricClientGameTest を実装し、5 つのスクリーンショットテストを追加
  - 空タンク、水満タン、水半分、水平連結、縦積み連結
- CI に client-game-test ジョブを追加(スクリーンショットをアーティファクトとして保存)
- CTBlocks.syncGroupBlockEntities の可視性を internal → public に変更
  (テストモジュールからのアクセスに必要)
- .gitignore に /net/ を追加(Loom デコンパイルソース除外)
…test

productionRuntimeMods configuration が空だったため、
ClientProductionRunTask 実行時に fabric-api と fabric-language-kotlin が
ロードされず起動に失敗していた。
…ctory

clientGametest ソースセットの jar を remap して getMods() に追加し、
runDir と testModResourcesPath を設定。これにより CI 上で
テスト mod が正しくロードされ、スクリーンショットも期待するパスに出力される。
… jar

RemapJarTask は Jar を継承しているため、同じ archiveClassifier だと
入力 jar と出力先が同じパスになり remap 時にファイルが破壊されていた。
classpath も clientGametest ソースセットのものを設定。
デフォルト容量は 32 バケツだが、テストでは 10 バケツしか入れていなかった。
CTServerConfig.DEFAULT_BUCKET_CAPACITY を参照して正しい量を注入するよう修正。
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Fabric client-side GameTest coverage to verify ConnectedTank rendering via screenshot capture, separating client tests into a dedicated clientGametest source set and wiring CI to run the client test task and upload screenshots as artifacts.

Changes:

  • Introduces a new clientGametest source set + Loom run configurations for client GameTests.
  • Adds a client GameTest mod (connectedtank-client-test) with screenshot-based rendering scenarios.
  • Updates CI to run the production client GameTest task and upload generated screenshots.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/kotlin/net/turtton/connectedtank/block/CTBlocks.kt Makes syncGroupBlockEntities callable from the client test module.
src/clientGametest/resources/fabric.mod.json Declares a separate client-only test mod and entrypoint for Fabric client GameTests.
src/clientGametest/kotlin/net/turtton/connectedtank/test/ConnectedTankClientGameTest.kt Implements screenshot capture scenarios for tank rendering verification.
build.gradle.kts Adds clientGametest source set, Loom run(s), and production client test task.
.gitignore Ignores Loom decompiled sources directory at repo root.
.github/workflows/build.yml Adds client-game-test CI job to run client GameTests and upload screenshots.
Comments suppressed due to low confidence (1)

src/main/kotlin/net/turtton/connectedtank/block/CTBlocks.kt:46

  • syncGroupBlockEntities was changed from internal to public. Since this is effectively an internal sync helper (it mutates client-render-facing block entities from server state), consider marking it explicitly as non-API (e.g., with an internal-use annotation / visibility wrapper) to avoid accidentally committing to it as part of the mod’s public API surface while still allowing test access.
    fun syncGroupBlockEntities(
        world: ServerWorld,
        pos: BlockPos,
        state: FluidStoragePersistentState = world.persistentStateManager.getOrCreate(FluidStoragePersistentState.TYPE),
    ) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import org.lwjgl.glfw.GLFW

object ConnectedTankClientGameTest : FabricClientGameTest {
private val TANK_CAPACITY = CTServerConfig.DEFAULT_BUCKET_CAPACITY.toLong()
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TANK_CAPACITY is a regular val but is named like a compile-time constant (all-caps with underscores). To match Kotlin naming conventions and avoid implying const val semantics, rename this to lowerCamelCase (or make it a const val if you can express it as a compile-time constant).

Suggested change
private val TANK_CAPACITY = CTServerConfig.DEFAULT_BUCKET_CAPACITY.toLong()
private val tankCapacity = CTServerConfig.DEFAULT_BUCKET_CAPACITY.toLong()

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +69
- name: Run client game tests
run: ./gradlew runProductionClientGameTest
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow runs a Minecraft client task on ubuntu-24.04 without setting up an X/GL context (e.g., via xvfb-run). On GitHub-hosted Linux runners, GUI/OpenGL apps typically fail with missing DISPLAY/GL errors unless wrapped in Xvfb (and sometimes mesa libs). Consider running the Gradle command under xvfb-run -a (and installing any required packages) to make the CI job reliable.

Suggested change
- name: Run client game tests
run: ./gradlew runProductionClientGameTest
- name: Install Xvfb and Mesa
run: |
sudo apt-get update
sudo apt-get install -y xvfb mesa-utils
- name: Run client game tests
run: xvfb-run -a ./gradlew runProductionClientGameTest

Copilot uses AI. Check for mistakes.
@turtton turtton merged commit d71f8d3 into main Mar 9, 2026
2 checks passed
@turtton turtton deleted the test/tank-rendering branch March 9, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants