From 26bdb7c8b8cbbc6bc7779363fcbf885726aff3c2 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Fri, 16 Sep 2022 13:39:07 -0700 Subject: [PATCH] Replace `__attribute__((constructor))` with C++ constructor. The use of __attribute__((constructor)) made the previous commit fail to build in MSVC. PiperOrigin-RevId: 474891117 Change-Id: I86a71bb8f3226ee49a8b5e8c07adc613623042b3 --- .github/workflows/build.yml | 1 + test/engine/engine_plugin_test.cc | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de82a656..29079de4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ on: jobs: mujoco: strategy: + fail-fast: false matrix: include: - os: ubuntu-22.04 diff --git a/test/engine/engine_plugin_test.cc b/test/engine/engine_plugin_test.cc index 2b8a870a..e40826ee 100644 --- a/test/engine/engine_plugin_test.cc +++ b/test/engine/engine_plugin_test.cc @@ -31,7 +31,6 @@ namespace mujoco { namespace { -using PluginTest = MujocoTest; using ::testing::HasSubstr; using ::testing::NotNull; @@ -271,19 +270,23 @@ int RegisterActuatorPlugin() { return mjp_registerPlugin(&plugin); } -__attribute__((constructor)) void RegisterAllPlugins() { - RegisterSensorPlugin(); +class PluginTest : public MujocoTest { + public: + // register all plugins + PluginTest() : MujocoTest() { + RegisterSensorPlugin(); - for (int i = 1; i <= kNumFakePlugins; ++i) { - mjpPlugin plugin; - mjp_defaultPlugin(&plugin); - std::string name = absl::StrFormat("mujoco.test.fake%u", i); - plugin.name = name.c_str(); - mjp_registerPlugin(&plugin); + for (int i = 1; i <= kNumFakePlugins; ++i) { + mjpPlugin plugin; + mjp_defaultPlugin(&plugin); + std::string name = absl::StrFormat("mujoco.test.fake%u", i); + plugin.name = name.c_str(); + mjp_registerPlugin(&plugin); + } + + RegisterActuatorPlugin(); } - - RegisterActuatorPlugin(); -} +}; constexpr char xml[] = R"(