166 Commits

Author SHA1 Message Date
Maleclypse 44473d73d4 Merge pull request #88580 from IcarusOfTroy/feature/windows-test-runner-stability 2026-09-08 10:15:33 -05:00
Matthew Richmond 9020833ece Stabilize test state resets and highway debug logging (#88577)
* Stabilize test state resets and highway debug logging

* tests: widen melee damage tolerance

* ci: retry overmap coverage

* ci: retry shader compile
2026-09-08 15:08:34 +02:00
Matthew Richmond aecca5e1c5 tests: stabilize local Windows test runs 2026-09-07 21:08:35 -04:00
ShnitzelX2 c40d0a528f initialize dimension_prefix to default dimension 2026-07-15 20:19:06 -04:00
dumb-kevin 661b45d89c Vendor plf_colony/plf_list verbatim under src/third-party/plf/
- Add upstream plf_colony v5.10 and plf_list v1.60 verbatim
- Add upstream zLib LICENSE
- Replace src/colony.h with thin cata::colony alias wrapper
- Replace src/list.h with thin cata::list alias wrapper
- Drop colony|list path from .clang-tidy header exclude regex
- Suppress Win32 test-exe abort dialog via _set_abort_behavior
2026-05-18 21:56:09 +04:00
dumb-kevin 05ab42807e tests/: wrap TU-local test fixture types in anon namespaces
- addiction_test: wrap addict_effect_totals
- battery_density_test: wrap battery_chemistry_family
- comestible_test: wrap all_stats
- encumbrance_test: wrap add_trait
- invlet_test: fuse inventory_location + invlet_state + test_action enums
- throwing_test: fuse throw_test_data + throw_test_pstats, move operator<< inside anon-ns
- vehicle_test: wrap vehicle_preset, damage_preset, folded_item_damage_preset, fuse rack_activation + rack_preset
- vision_test: wrap vision_test_case
- water_movement_test: fuse 6 swimmer/swim structs into one block
- weakpoint_test: wrap weakpoint_test_data, weakpoint_expectation, weakpoint_report
2026-05-12 10:53:28 +04:00
dumb-kevin fc8a251e6d Add NOLINTs for intentional clang-tidy violations
- debug.cpp: bugprone-command-processor on the three popen call sites
  (nm symbol resolution, addr2line frame symbolization, crash-handler
  shell_exec helper). These are debug/crash paths that intentionally
  shell out.
- flexbuffer_cache.cpp: append bugprone-unchecked-string-to-number-conversion
  to the existing cert-err34-c NOLINTs on the three sscanf calls that
  parse compiler error strings; the parsed values are validated below.
- rng_test.cpp: append bugprone-float-loop-counter to the two existing
  NOLINTs guarding the log-distribution sampling loop.
- test_main.cpp: bugprone-exception-escape on main; the test runner
  lets exceptions propagate by design.
- zzip_test.cpp: append misc-predictable-rand to the existing NOLINT
  guarding deterministic test byte generation.
- ncurses_def.cpp: cata-use-string_view on set_title; signature has
  to mirror the sdltiles and wincurse implementations that use .c_str().
2026-05-12 10:53:27 +04:00
dumb-kevin cdd3a91ca1 NPC local resource acquisition: drink, eat, wear from environment
NPCs now drink from nearby water terrain, eat food from the ground,
and wear warm clothing from the ground. Seven reusable find/act
helpers with full pickup governance (ally rules, NO_NPC_PICKUP zones,
ownership, LOS). Danger-gate split: adjacent actions before the gate,
pathing after. Warmth gate switched from BT subtree to direct
needs_warmth_badly predicate.
2026-03-23 17:21:37 +04:00
dumb-kevin 8c9155e226 Remove Catch2 v2 internal API usage from test runner
Lazy game init in the listener replaces the filterTests/getAllTestCasesSorted
pre-scan. CataCIReporter (unused ConsoleReporter subclass) removed.
normalized_test_names_test internal API call extracted into a helper.
Listener stream member replaced with std::cerr (v3 removes it).
2026-03-16 08:25:04 +04:00
dumb-kevin f28cc8ddec Suppress clang-tidy false positive in test cleanup listener 2026-03-10 01:31:32 +04:00
dumb-kevin 9f7ddb6fb6 Reset calendar and weather state between test cases
Add a testCaseEnded hook to the Catch2 listener that resets
commonly-leaked lightweight global state after each test case.

Currently calendar::turn, weather overrides, and temperature
cache leak freely between tests, causing order-dependent failures.
Expensive operations like clear_map() stay manual and explicit.
2026-03-10 00:16:07 +04:00
dumb-kevin ddddabfc1a Add --rng-seed-fuzz N to test runner
Reruns tests N times with varying RNG seeds without reloading game data.
With --rng-seed X: seeds X..X+N-1. Without: random seeds each iteration.
2026-03-06 00:00:54 +04:00
akrieger ae59c8298a Add some boilerplate to make it easier to substitute different allocators. 2026-02-24 12:26:09 -08:00
akrieger 329efcbf3a Add noop test for helping profile game load and other startup steps without the overhead of the main menu. (#85463)
Co-authored-by: akrieger <akrieger@users.noreply.github.com>
2026-02-22 16:27:53 -08:00
carambola 0027ecb483 Update test_main.cpp
Fixed a spelling error in the command help section of tests/test_main.cpp.
2025-12-02 21:52:52 +08:00
alef 2d59ff2237 Add --limit-debug-level to test main (#79824)
* Add `--limit-debug-level` to test main

* Update tests/test_main.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update tests/test_main.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Obey linters

* Rename to `--set-debug-level-mask`

* Update tests/test_main.cpp

Co-authored-by: moxian <moxian@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: moxian <moxian@users.noreply.github.com>
2025-02-24 10:08:24 +01:00
moxian b24aa517ea code style 2025-02-16 19:45:21 -08:00
moxian bb7873fd6e Log the current test name.
This should make test issues *a tiny bit* easier to debug.
For example, it will now be easy to know where does the
'loading non-main map at (0,0,0) which overlaps with main map (abs_sub =
(-5,-5,0))'
come from
2025-02-16 19:45:20 -08:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian 2ee44002fd Mechanically IWYU the tests
python3 ~/github/include-what-you-use/iwyu_tool.py -j5 -p build $( find
src/ tests/ -maxdepth 1 -name '*.cpp' | grep -v -f
tools/iwyu/bad_files.txt )  --  -Xiwyu --comment_style=long -Xiwyu -
-max_line_length=1000 -Xiwyu --cxx17ns -Xiwyu
--mapping_file=../tools/iwyu/cata.imp   | tee out/iwyu/f-a-01.txt >
/dev/null

followed by

cat out/iwyu/f-a-02.txt | python3
~/github/include-what-you-use/fix_includes.py --reorder --nosafe_headers

followed by manual fixups of <stddef.h> -> <cstddef> and similar.

tests/generic_factory_test.cpp gets mangled very badly (IWYU bug) so
it's excluded from the list.

Code size:
includes:
$ cat obj/tiles/*.inc | wc
 288068  576136 17898260
$ cat tests/obj/tiles/*.inc | wc
 167044  334088 10465766

post-processed source (clang -E):
./make_preproc.sh src/
68567896 177775140 2134075721
./make_preproc.sh tests/
39341957 102891720 1243323710
2025-02-10 00:46:57 -08:00
ShnitzelX2 f4bdff9e7b Update test_main.cpp
rename bad time names
not astyled, not sure if needed
2025-01-20 17:55:54 -05:00
mqrause b7e10ba1f1 reset seed in sections even when no explicit seed given 2025-01-09 22:00:27 +01:00
Anton Burmistrov 4589bf80f4 Merge pull request #77730 from sparr/point_constant_static_members
Replace point constants with static class members
2024-11-26 23:24:03 +04:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
Procyonae c957667136 Update test_main.cpp 2024-11-25 10:06:43 +00:00
Daniel Brooks 734ec4c79c rewrite the loading screen to use ImGui (#75998)
* rewrite the loading screen to use ImGui

and simplify the usage too.

* write a loading screen for when we’re not using ImGui too

Fixes #75678

* add a stupid comment to appease clang

plus some other small changes to appease a different version of clang

---------

Co-authored-by: Daniel Brooks <db48x@orod-na-thon.tailcd79e.ts.net>
2024-09-05 10:37:18 -05:00
Binrui Dong ad33116b92 Do not save map on init failure in tests 2024-01-31 11:46:11 +08:00
alef 46f811746a Only init game if we're running tests that need it (#70901)
* Only init game if no select tests have [nogame] tag

* Tests tagged [utility] never require a game object

* Add elapsed time for `[nogame]` too

* Obey astyle

* Obey clang-tidy

* Optimize for cases of invalid tags leading quitting

* Tag more tests with `[nogame]`

* Fix logic to derive `needs_game` from `[nogame]`

https://github.com/CleverRaven/Cataclysm-DDA/pull/70901#discussion_r1451648340

* Do not access `world_generator` when no game was initialized

https://github.com/CleverRaven/Cataclysm-DDA/pull/70901#discussion_r1451648830

* Obey astyle
2024-01-14 09:50:47 -06:00
alef 08e4839066 cata_test does not wait for --list-tests anymore (#70514)
* Use Catch2 own argument parser

Parsing functions now works on strings, or removed.
Local variables promoted file global for upcoming listeners.

* Run init_global_game_state from Catch2 event listener

This avoid delay for Catch2 processing own options like --list-tests

* Obey linters

* Obey clang-tidy

Use `static`, `string_view`, avoid `auto`

* Apply .astylerc

* Fix crashing and print invalid values on listing
2024-01-08 15:33:04 +03:00
alef 6f376d2e93 Add rng_get_first_seed and use it in cata_test (#70497)
* Remember the RNG seed used the very first time

* Report the seed used by the game engine

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-12-28 16:28:45 -06:00
Alexey c011e9de12 Improve output for JSON errors (#66623)
* Colorize JSON errors

* Make formatter feed source filename to TextJsonIn

* Throw exception instead of dumping output to std::cerr

* Adjust math parser's caret appearance

* Set color in chkjson

* Adjust tests and formatters

* Add json error cursor check for unicode string

* Squelch global state lint for entry points

* Adjust stream offset so the buffer for utf8_width is pointing at a codepoint
2023-07-17 19:51:50 -05:00
Alexey b35d0cd8c7 Tests tweaks (#66228)
* Log SDL renderers on one line

* Don't try to enumerate non-existing directories

* Remove a few more lines of log noise

* Actually leave the test world for inspection
2023-06-16 12:31:49 -03:00
John Bytheway c000771088 Re-enable cata-almost-never-auto
In LLVM 16 this check was a lot more effective.  So, it was briefly
disabled during the migration.  This fixes all its warnings again, and
re-enables it.
2023-05-20 08:55:37 -04:00
Jianxiang Wang (王健翔) 719e63678e Add clang-tidy check to enforce use of fs::u8path and fix path encoding error (#65223)
* Add clang-tidy check to ensure fs::u8path is used to construct path from utf-8 string

* Fix fs::u8path and nullptr warnings

* Print error instead of showing a popup in test mode in write_to_file

* Remove cata::fstream wrappers
2023-05-17 08:52:46 -03:00
akrieger b36496f5f3 Fix unvisited member reporting from global destructors in atexit. (#65477) 2023-05-05 14:16:09 -07:00
John Bytheway 4be58c14c8 Improve error message regarding user dir
To help me debug CI issues.
2023-03-14 19:26:16 -04:00
akrieger 3b22d13aa9 Move scope helpers to cata_scope_helpers.h 2022-09-15 22:04:51 -07:00
John Bytheway 1b953deb9e Enable clang-tidy check misc-misplaced-const (#58982)
This check is mostly about using 'const Foo' where Foo is a typedef of a
pointer type.  That can be confusing because people might think the
constness applies to the pointee type (like it would if Foo was a
macro), but it doesn't.

All the examples in CDDA were a result of the WORLDPTR typedef.  I just
removed that typedef entirely since it served no real purpose; it was
just a longer way to type WORLD*.  This change allowed improved
const-correctness and removing one const_cast.
2022-07-06 20:53:01 -04:00
David Seguin f51a26cd1f Jsonify addictions: promote add_type to JSON object 2022-04-17 13:18:55 -04:00
John Bytheway e95a4fc9b8 Promote string_id constants to global statics
Our string_id constants were a mixture of temporaries, locals, and
globals.  Pull them all out as globals, for consistency and efficiency.
The efficiency comes from the fact that each string_id instance caches
its respective int_id, and sharing one instance means that value need
not be recomputed.
2021-11-19 19:10:09 -05:00
Jianxiang Wang (王健翔) a11d8cf5ac Add code to check for irregular plural forms (#51259) 2021-09-11 07:49:42 -07:00
John Bytheway 9eb8e7682f Add cata_fatal macro (#51507)
Extend the cata-assert check to suggest using cata_fatal, a new macro
for fatal errors.

Use that new macro to replace uses of abort, assert( false ), etc.
2021-09-10 22:32:34 -07:00
Kevin Granade 20bf2deb75 Merge pull request #51313 from eltank/abs_pos
Migrate creature positions to absolute tripoints
2021-09-07 14:16:10 -07:00
actual-nh cc982740a8 If want successful test output, include messages (#51441)
The output for successful tests, even if such is requested of via
Catch2's `-s` flag, now includes messages; it didn't before.

Co-authored-by: actual-nh <actual-nh@users.noreply.github.com>
2021-09-06 16:48:37 -07:00
eltank 2e0f644b7a Migrate avatar to absolute position 2021-09-05 18:38:41 -07:00
Binrui Dong a1b9ffa295 Reset x86 floating point mode on Windows 2021-08-04 23:54:06 +08:00
John Bytheway ebd549b300 Fix StringMaker ODR violations in tests
Catch2 provides a customization point for converting our types to
strings by specializing the StringMaker template.

We have some specializations in stringmaker.h, but this feature was only
working intermittently.  I finally figured out that was due to an ODR
violation.  The test files that didn't include stringmaker.h were
compiling a different specialization than the ones that did.

Re-jig the test includes so that any file including catch.hpp also
includes stringmaker.h, thereby ensuring that the custom
specializations are used everywhere and there is no ODR violation.

I achieved this by adding a new cata_catch.h header and making all
existing headers include catch.hpp via the new header.
2021-07-03 07:42:06 -07:00
John Bytheway 30e72522eb Fix issues found by new check
Run clang-tidy and fix or suppress all the issues it found.  This
includes a few of the type of issue intended to be found, and one issue
in the check code itself.
2021-03-25 09:53:44 -04:00
Jianxiang Wang (王健翔) 4c32ad11b8 Use sed to conditionally add tag strings to parallel execution (#47905) 2021-03-08 23:16:51 +03:00
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00