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

Fix macOS workflow and backport windows fix #1409

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
# Workaround for https://github.com/actions/setup-python/issues/577
- name: Clean up python binaries
run: |
rm -f /usr/local/bin/2to3*;
rm -f /usr/local/bin/idle3*;
rm -f /usr/local/bin/pydoc3*;
rm -f /usr/local/bin/python3*;
rm -f /usr/local/bin/python3*-config;
rm -f $(brew --prefix)/bin/2to3*;
rm -f $(brew --prefix)/bin/idle3*;
rm -f $(brew --prefix)/bin/pydoc3*;
rm -f $(brew --prefix)/bin/python3*;
rm -f $(brew --prefix)/bin/python3*-config;
- name: Install base dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
Expand All @@ -50,8 +50,8 @@ jobs:
- name: cmake
working-directory: build
run: |
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python
cmake .. -DCMAKE_INSTALL_PREFIX=$(brew --prefix)/Cellar/${PACKAGE}/HEAD -DPython3_EXECUTABLE=$(brew --prefix python3)/bin/python3
- run: make
working-directory: build
- run: make test
Expand Down
6 changes: 0 additions & 6 deletions src/Console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ using namespace sdf;
static std::shared_ptr<Console> myself;
static std::mutex g_instance_mutex;

/// \todo Output disabled for windows, to allow tests to pass. We should
/// disable output just for tests on windows.
#ifndef _WIN32
static bool g_quiet = false;
#else
static bool g_quiet = true;
#endif

static Console::ConsoleStream g_NullStream(nullptr);

Expand Down
8 changes: 7 additions & 1 deletion src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/cmd${PROJECT_NAME}.rb.con

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${PROJECT_NAME}>")
if (MSVC)
set(library_location_prefix "${CMAKE_INSTALL_BINDIR}")
else()
set(library_location_prefix "${CMAKE_INSTALL_LIBDIR}")
endif()

set(library_location "../../../${library_location_prefix}/$<TARGET_FILE_NAME:${PROJECT_NAME}>")

configure_file(
"cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in"
Expand Down
16 changes: 12 additions & 4 deletions src/cmd/cmdsdformat.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ else
end

require 'optparse'
require 'pathname'


# Constants.
LIBRARY_NAME = '@library_location@'
Expand Down Expand Up @@ -174,9 +176,7 @@ class Cmd
# puts options

# Read the plugin that handles the command.
if LIBRARY_NAME[0] == '/'
# If the first character is a slash, we'll assume that we've been given an
# absolute path to the library. This is only used during test mode.
if Pathname.new(LIBRARY_NAME).absolute?
plugin = LIBRARY_NAME
else
# We're assuming that the library path is relative to the current
Expand All @@ -185,10 +185,18 @@ class Cmd
end
conf_version = LIBRARY_VERSION

if defined? RubyInstaller
# RubyInstaller does not search for dlls in PATH or the directory that tests are running from,
# so we'll add the parent directory of the plugin to the search path.
# https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#-dll-loading
RubyInstaller::Runtime.add_dll_directory(File.dirname(plugin))
end

begin
Importer.dlload plugin
rescue DLError
rescue DLError => error
puts "Library error: [#{plugin}] not found."
puts "DLError: #{error.message}"
exit(-1)
end

Expand Down
58 changes: 32 additions & 26 deletions src/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::string custom_exec_str(std::string _cmd)
}

/////////////////////////////////////////////////
TEST(checkUnrecognizedElements, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(checkUnrecognizedElements, SDF)
{
// Check an SDFormat file with unrecognized elements
{
Expand Down Expand Up @@ -120,7 +120,7 @@ TEST(checkUnrecognizedElements, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(check, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(check, SDF)
{
// Check a good SDF file
{
Expand Down Expand Up @@ -1011,7 +1011,7 @@ TEST(check, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(check_shapes_sdf, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(check_shapes_sdf, SDF)
{
{
const auto path =
Expand All @@ -1035,7 +1035,7 @@ TEST(check_shapes_sdf, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(check_model_sdf, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(check_model_sdf, SDF)
{
// Check a good SDF file by passing the absolute path
{
Expand All @@ -1062,7 +1062,7 @@ TEST(check_model_sdf, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(describe, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(describe, SDF)
{
// Get the description
std::string output =
Expand All @@ -1074,7 +1074,7 @@ TEST(describe, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print, SDF)
{
// Check a good SDF file
{
Expand Down Expand Up @@ -1103,7 +1103,7 @@ TEST(print, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_rotations_in_degrees, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_rotations_in_degrees, SDF)
{
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_degrees.sdf");
Expand Down Expand Up @@ -1171,7 +1171,7 @@ TEST(print_rotations_in_degrees, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_rotations_in_radians, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_rotations_in_radians, SDF)
{
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_radians.sdf");
Expand Down Expand Up @@ -1239,7 +1239,7 @@ TEST(print_rotations_in_radians, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_rotations_in_quaternions, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_rotations_in_quaternions, SDF)
{
const auto path = sdf::testing::TestFile(
"sdf", "rotations_in_quaternions.sdf");
Expand Down Expand Up @@ -1308,7 +1308,7 @@ TEST(print_rotations_in_quaternions, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_includes_rotations_in_degrees, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_includes_rotations_in_degrees, SDF)
{
// Set SDF_PATH so that included models can be found
gz::utils::setenv(
Expand Down Expand Up @@ -1379,7 +1379,7 @@ TEST(print_includes_rotations_in_degrees, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_includes_rotations_in_radians, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_includes_rotations_in_radians, SDF)
{
// Set SDF_PATH so that included models can be found
gz::utils::setenv(
Expand Down Expand Up @@ -1450,8 +1450,7 @@ TEST(print_includes_rotations_in_radians, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_includes_rotations_in_quaternions,
GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_includes_rotations_in_quaternions, SDF)
{
// Set SDF_PATH so that included models can be found
gz::utils::setenv(
Expand Down Expand Up @@ -1523,8 +1522,7 @@ TEST(print_includes_rotations_in_quaternions,
}

/////////////////////////////////////////////////
TEST(print_rotations_in_unnormalized_degrees,
GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_rotations_in_unnormalized_degrees, SDF)
{
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_unnormalized_degrees.sdf");
Expand Down Expand Up @@ -1595,8 +1593,7 @@ TEST(print_rotations_in_unnormalized_degrees,
}

/////////////////////////////////////////////////
TEST(print_rotations_in_unnormalized_radians,
GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_rotations_in_unnormalized_radians, SDF)
{
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_unnormalized_radians.sdf");
Expand Down Expand Up @@ -1664,7 +1661,7 @@ TEST(print_rotations_in_unnormalized_radians,
}

/////////////////////////////////////////////////
TEST(shuffled_cmd_flags, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(shuffled_cmd_flags, SDF)
{
const std::string path =
sdf::testing::TestFile("sdf", "rotations_in_unnormalized_radians.sdf");
Expand Down Expand Up @@ -1713,8 +1710,7 @@ TEST(shuffled_cmd_flags, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print_snap_to_degrees_tolerance_too_high,
GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print_snap_to_degrees_tolerance_too_high, SDF)
{
const std::string path = sdf::testing::TestFile(
"sdf",
Expand All @@ -1731,7 +1727,7 @@ TEST(print_snap_to_degrees_tolerance_too_high,
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldPoseRelativeTo))
TEST(GraphCmd, WorldPoseRelativeTo)
{
// world pose relative_to graph
const std::string path =
Expand Down Expand Up @@ -1780,7 +1776,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldPoseRelativeTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelPoseRelativeTo))
TEST(GraphCmd, ModelPoseRelativeTo)
{
const auto path =
sdf::testing::TestFile("sdf", "model_relative_to_nested_reference.sdf");
Expand Down Expand Up @@ -1857,7 +1853,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelPoseRelativeTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldFrameAttachedTo))
TEST(GraphCmd, WorldFrameAttachedTo)
{
const auto path =
sdf::testing::TestFile("sdf", "world_nested_frame_attached_to.sdf");
Expand Down Expand Up @@ -1903,7 +1899,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldFrameAttachedTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelFrameAttachedTo))
TEST(GraphCmd, ModelFrameAttachedTo)
{
const auto path =
sdf::testing::TestFile("sdf", "model_nested_frame_attached_to.sdf");
Expand Down Expand Up @@ -1955,7 +1951,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelFrameAttachedTo))
// Disable on arm
#if !defined __ARM_ARCH
/////////////////////////////////////////////////
TEST(inertial_stats, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(inertial_stats, SDF)
{
std::string expectedOutput =
"Inertial statistics for model: test_model\n"
Expand Down Expand Up @@ -2043,7 +2039,7 @@ TEST(inertial_stats, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))

//////////////////////////////////////////////////
/// \brief Check help message and bash completion script for consistent flags
TEST(HelpVsCompletionFlags, SDF)
TEST(HelpVsCompletionFlags, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
{
// Flags in help message
std::string helpOutput = custom_exec_str(GzCommand() + " sdf --help");
Expand Down Expand Up @@ -2098,6 +2094,16 @@ int main(int argc, char **argv)
gz::utils::setenv("LD_LIBRARY_PATH", testLibraryPath);
#endif

// temporarily set HOME
std::string homeDir;
sdf::testing::TestTmpPath(homeDir);

#ifdef _WIN32
gz::utils::setenv("HOMEPATH", homeDir);
#else
gz::utils::setenv("HOME", homeDir);
#endif

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Loading