Files
chatterino2/tests
pajlada 6e0533e1da chore: make sanitizers opt in (#6493)
Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers.

Building tests is not required - sanitizers can be enabled in the app by itself.
2025-09-25 23:43:54 +02:00
..

To run tests, you'll first need to enable the test flag in cmake. You can do this by adding the -DBUILD_TESTS=On flag to your cmake setup call. (e.g. mkdir build && cd build && cmake -DBUILD_TESTS=On ..)

After you've built Chatterino, you can now run the tests with ctest or by manually running the newly created chatterino-test executable

Pre-requisites to running tests

  • Download & run httpbox
    We expect this to be listening to port 9051, you can launch it like this:
    httpbox --port 9051

  • Download & run twitch-pubsub-server-test
    We expect this to be listening to port 9050, you can launch it like this: twitch-pubsub-server-test 127.0.0.1:9050

Modifying message building

If you make a change that has to do with message building, there's a big chance that some of the snapshot tests will fail. If this happens, you might want to:

  1. Set the UPDATE_SNAPSHOTS boolean at the top of the IrcMessageHandler.cpp test file to true
  2. Re-run the tests (this will update the snapshots to match your new reality)
  3. Reset UPDATE_SNAPSHOTS to false again
  4. Then run the tests a final time.

Once this is done, you should take a look at the changes made to the snapshot json files to ensure that it looks correct.