Remove PluginTest and make MujocoTest load plugins.

MujocoTest now loads plugins from MUJOCO_PLUGIN_DIR if set.
PluginTest is removed; all tests use MujocoTest directly.
testspeed binary loads plugins from MUJOCO_PLUGIN_DIR.

This is in preparation for moving common asset format parsing (obj, msh, stl, etc.) where we will always want to load those plugins.

PiperOrigin-RevId: 874194428
Change-Id: Id90805a9ba5de4627911b56d8b9c4ab4e1b29310
This commit is contained in:
Sam Haves
2026-02-23 12:14:37 -08:00
committed by Copybara-Service
parent 6ec808e2ce
commit 82e92cbcaa
8 changed files with 45 additions and 35 deletions
+18 -14
View File
@@ -16,9 +16,12 @@
#define MUJOCO_TEST_FIXTURE_H_
#include <csetjmp>
#include <cstdio> // IWYU pragma: keep
#include <cstdlib> // IWYU pragma: keep
#include <cstring>
#include <iomanip>
#include <iostream>
#include <mutex> // IWYU pragma: keep
#include <string>
#include <string_view>
#include <vector>
@@ -54,6 +57,21 @@ class MujocoErrorTestGuard {
// trigger a test failure.
class MujocoTest : public ::testing::Test {
public:
MujocoTest() {
static std::once_flag flag;
std::call_once(flag, []() {
const char* plugin_dir = std::getenv("MUJOCO_PLUGIN_DIR");
if (plugin_dir) {
mj_loadAllPluginLibraries(
plugin_dir, +[](const char* filename, int first, int count) {
std::printf("Plugins registered by library '%s':\n", filename);
for (int i = first; i < first + count; ++i) {
std::printf(" %s\n", mjp_getPluginAtSlot(i)->name);
}
});
}
});
}
~MujocoTest() { mj_freeLastXML(); }
private:
@@ -183,20 +201,6 @@ class MockFilesystem {
std::string dir_; // current directory
};
// Installs all plugins
class PluginTest : public MujocoTest {
public:
// load plugin library
PluginTest() : MujocoTest() {
mj_loadAllPluginLibraries(
std::string(std::getenv("MUJOCO_PLUGIN_DIR")).c_str(), +[](const char* filename, int first, int count) {
std::printf("Plugins registered by library '%s':\n", filename);
for (int i = first; i < first + count; ++i) {
std::printf(" %s\n", mjp_getPluginAtSlot(i)->name);
}
});
}
};
} // namespace mujoco
#endif // MUJOCO_TEST_FIXTURE_H_