Skip to content

test(items): the description language test switches the language with its own item table - #847

Merged
Mosch0512 merged 1 commit into
sven-n:mainfrom
Mosch0512:fix/item-description-test-crash
Oct 23, 2026
Merged

Mosch0512 merged 1 commit into
sven-n:mainfrom
Mosch0512:fix/item-description-test-crash

Conversation

@Mosch0512

Copy link
Copy Markdown
Collaborator

Summary

Running the whole test_item_database_files binary in one process crashed in "A description is in the UI's language also when the item names stay English" (from #813):

test_item_descriptions.cpp(135): FATAL ERROR: test case CRASHED: SIGSEGV - Segmentation violation signal
  • Why: once a test has loaded the item data, the item data handler follows every UI language switch and refills ItemAttribute. In the test binary, ItemAttribute is null outside a ClientDataScope, and this test switches the language outside one.
  • Why CI didn't see it: CTest runs every test case in a process of its own (doctest_discover_tests). Running the binary as a whole, as an IDE does, crashes every time. Two test cases are enough: "Loading item data fills ItemAttribute in the UI locale", then this one.

The fix:

  • The test switches the language inside a ClientDataScope, so it has an item table of its own.
  • It turns "Translate item names" off with g_ItemDataHandler.SetTranslateItemNames(false). Before, it only set the item database's display locale to English. Once the item data was loaded, the handler overrode that on the language switch, so the item names weren't English any more and the test no longer tested what its name says. It now checks that the names stay English.
  • ClientDataScope's comment says that a test which switches the UI language needs one.

Only tests change.

Related issues

Follow-up to #813 (step 1 of #815).

Checklist

  • I have read and followed docs/CODING_RULES.md.
  • I have built the project locally (see docs/build/README.md).
    • Windows x64 Debug: test_item_database_files passes as a whole (160 test cases), also in three random orders (--order-by=rand). With main's version of the test, the same build crashes as above.
    • The changed lines pass clang-format 21.1.8.
  • Changes are focused on one concern; the diff is as small as it reasonably can be.

… its own item table

Run in one process after a test that loaded the item data, "A description
is in the UI's language also when the item names stay English" crashed:
the item data follows every UI language switch and refills ItemAttribute,
which is null outside a ClientDataScope. CTest runs each test case in a
process of its own, so CI never ran into it; a run of the whole test
binary, as an IDE does it, crashed there.

The test now switches the language inside a ClientDataScope. It turns
"Translate item names" off through the item data handler, so the item
names stay English also when the loaded item data follows the switch,
and checks that they do. ClientDataScope's comment says that a test
which switches the UI language needs one.
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.

1 participant