Skip to content

Convert Warcraft III tests to .j and reduce test harness #115

Description

@corepunch

Summary

Migrate Warcraft III gameplay tests from the C harness to .j fixtures wherever the JASS surface is a better fit. The goal is to make tests easier to follow, closer to production scripting, and smaller in the long term.

Why this change exists

  • Tests written in .j mirror the real Warcraft III scripting entrypoint more closely than direct C harness calls.
  • The current harness is carrying a lot of game-state scaffolding that is only there to support gameplay assertions.
  • Once dedicated server mode exists, these tests can run against the real game module instead of mocked C-side state.

Dependency

This issue is blocked by #116 (Add dedicated server mode (headless, no client)). We need a headless runtime before .j gameplay tests can run cleanly against the real game module.

What currently exists

  • There is no hero_inventory_test.j or similar gameplay fixture yet.
  • The closest existing .j file is test_jass_assertions.j, which tests JASS assertion natives rather than gameplay behavior.
  • Gameplay coverage currently lives in C through test_harness.c / test_harness.h.

The harness currently owns:

  • Global game state that normally belongs in g_main.c (gi, globals, game, level, g_edicts)
  • Mock gi function pointers for allocation, entity linking, edict queries, and similar plumbing
  • Hardcoded unit metadata for test actors such as hpea, hfoo, hbar, and Hpal
  • Raw edict allocation helpers that bypass normal spawn/model setup
  • Stubs for game symbols that are not linked into the test binary

Suggested migration order

  1. Make real game natives callable from the JASS test binary.
  2. Convert inventory tests first, since they already map cleanly to UnitItemInSlot / UnitHasItem style checks.
  3. Convert hero, unit-flag, player, alliance, and group tests next.
  4. Delete the C tests that are fully replaced by .j coverage.
  5. Remove dead harness helpers and unused stubs as each migration makes them obsolete.
  6. Trim the test build once the old callers are gone.

Good .j candidates

These are gameplay behaviors that map naturally to JASS natives:

  • Inventory add/get and slot assignment
  • Hero attributes, XP accumulation, and SuspendHeroXP
  • Unit flags such as invulnerable, paused, hidden, and no-pathing
  • Player properties like color, name, and team
  • Alliances
  • Ownership and range checks
  • Group membership helpers

Keep in C

These areas do not have a meaningful Warcraft III gameplay-script surface and should stay as C tests:

  • Pathfinding
  • SLK parsing
  • JASS VM internals
  • Collision and physics
  • UI / FDF rendering and serialization
  • Network and server protocol
  • Combat math that lives in shared engine/game code rather than gameplay scripting

Acceptance criteria

  • At least one .j gameplay fixture exists and runs in CI.
  • The JASS test binary can call the real game natives it needs.
  • Replaced C tests are deleted once their .j equivalents exist.
  • Harness code shrinks where helpers become unused.
  • The build still passes for the remaining C-only suites.

Definition of done

  • Gameplay tests are represented by .j fixtures instead of direct C harness calls where practical.
  • The remaining C harness is smaller and easier to justify.
  • The test suite is deterministic and self-contained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwarcraft-3Warcraft III specific features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions