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

Upgrade client active object mgr tests to Catch2 #13609

Conversation

JosiahWI
Copy link
Contributor

@JosiahWI JosiahWI commented Jun 19, 2023

In addition to invoking Catch2's test runner after Minetest's homemade runner, this refactors the tests to have expressive names and removes some redundant or useless checks.

The Catch2 runner is invoked after Minetest's runner is finished, and "Catch2 test results:" will be printed out directly before invoking the Catch2 runner.

Part of #13610

To do

Ready for Review.

How to test

Confirm that the results of minetest --run-unittests look correct.

@wsor4035 wsor4035 added Feature ✨ PRs that add or enhance a feature Code quality labels Jun 19, 2023
@wsor4035 wsor4035 added the Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand. label Jun 19, 2023
@wsor4035
Copy link
Contributor

roadmap label added per zughy request. unsubscribing

@rubenwardy rubenwardy added Concept approved Approved by a core dev: PRs welcomed! and removed Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand. labels Jun 19, 2023
@rubenwardy rubenwardy linked an issue Jun 19, 2023 that may be closed by this pull request
@Zughy Zughy added Roadmap The change matches an item on the current roadmap. and removed Concept approved Approved by a core dev: PRs welcomed! labels Jun 20, 2023
@SmallJoker SmallJoker added the Rebase needed The PR needs to be rebased by its author. label Oct 1, 2023
@JosiahWI JosiahWI force-pushed the feat/catch2-client-active-object-mgr-tests branch 2 times, most recently from e3bc72e to 38d2de6 Compare October 8, 2023 18:40
@JosiahWI
Copy link
Contributor Author

JosiahWI commented Oct 8, 2023

I haven't converted the new tests in this file after the rebase, and I'm not currently planning to do it in this PR. Those tests look very clean to me, and although it would be very good to convert them, I would like to focus efforts first on tests that are fragile or incomplete. However, if someone really wants me to convert those in this PR as well, please say so.

@Zughy Zughy removed the Rebase needed The PR needs to be rebased by its author. label Oct 9, 2023
JosiahWI and others added 4 commits October 9, 2023 12:48
In addition to invoking Catch2's test runner after Minetest's homemade
runner, this refactors the tests to follow the DRY principle, and gives
them expressive names and clear assertions. Catch2 is already bundled
with Minetest, so there are no added dependencies.
@JosiahWI JosiahWI force-pushed the feat/catch2-client-active-object-mgr-tests branch from 490437e to 47e88c6 Compare October 9, 2023 18:10
<< "++++++++++++++++++++++++++++++++++++++++" << std::endl;
<< "++++++++++++++++++++++++++++++++++++++++" << std::endl
<< "Catch test results: " << std::endl;
auto catch_test_failures = Catch::Session().run();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just runs the other tests unconditionally after the normal ones with no integration with --test-module

TEST(testGetActiveSelectableObjects)
}

////////////////////////////////////////////////////////////////////////////////

void TestClientActiveObjectMgr::testFreeID()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the plan if any converted tests need to access the gamedef?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. The plan is to move the TestGameDef to its own file and instantiate an instance of it for each Catch test that needs it. If that proves to be too slow, then I think mocking some parts of the gamedef might be appropriate. That's more work than a global gamedef, which almost looks like an amazing solution, but there's a big danger with that because the global instance might be modified by a test and not completely reset at the end. The tests would no longer be independent of each other and the order in which the tests are run could start to matter, which is a big mess. Looking at the code, it seems we could already have this problem.

@sfan5 sfan5 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jan 17, 2024
@Zughy Zughy added the Adoption needed The pull request needs someone to adopt it. Adoption welcomed! label Feb 21, 2024
@Zughy Zughy closed this Feb 21, 2024
@JosiahWI
Copy link
Contributor Author

I'll open this when I'm ready to work on it again; probably at the end of the spring semester.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) Adoption needed The pull request needs someone to adopt it. Adoption welcomed! Code quality Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️ Roadmap The change matches an item on the current roadmap.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate unit tests to Catch2 framework.
7 participants