Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only init game if we're running tests that need it #70901

Merged
merged 10 commits into from
Jan 14, 2024

Conversation

alef
Copy link
Contributor

@alef alef commented Jan 13, 2024

Summary

Infrastructure "Only init game if we're running tests that need it"

Purpose of change

Implement the long-staning TODO in tests/test_main.cpp with the same name.

Describe the solution

The idea is to tag those few TEST_CASE()s with the special [nogame] tag. This is checked before running the tests by looping over all the selected tests. If all have [nogame], then the global game object is not called.
This speeds up some kind of tests a lot by not initializing the game.

Describe alternatives you've considered

Use a tag [g] to do the opposite. But this would have required to review all the 1139 tests.

Testing

  • [utility] do not initialized the game object
  • ✅ other tags do initialize the game object

Additional context

More tests should be reviewed and tagged as [nogame].

@github-actions github-actions bot added Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style json-styled JSON lint passed, label assigned by github actions labels Jan 13, 2024
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 13, 2024
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jan 13, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 14, 2024
tests/test_main.cpp Show resolved Hide resolved
tests/test_main.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Jan 14, 2024
@alef alef marked this pull request as ready for review January 14, 2024 12:54
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 14, 2024
@Maleclypse Maleclypse merged commit 46f8117 into CleverRaven:master Jan 14, 2024
27 of 38 checks passed
@alef alef deleted the test_nogame branch January 14, 2024 16:46
@andrei8l
Copy link
Contributor

andrei8l commented Jan 17, 2024

This broke CI for mods. CI runs the test binary with all mods loaded but no tests selected (~*) and this makes it not load any data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants