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 gz sdf command on windows #1344

Closed
wants to merge 2 commits into from
Closed
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
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
9 changes: 5 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 @@ -187,8 +187,9 @@ class Cmd

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

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

/////////////////////////////////////////////////
TEST(checkUnrecognizedElements, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(checkUnrecognizedElements, SDF)
{
std::string pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/sdf";
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)
{
std::string pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/sdf";
Expand Down Expand Up @@ -916,7 +916,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)
{
std::string pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/sdf";
Expand All @@ -939,7 +939,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)
{
std::string pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/integration/model/box";
Expand All @@ -965,7 +965,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 @@ -977,7 +977,7 @@ TEST(describe, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
}

/////////////////////////////////////////////////
TEST(print, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
TEST(print, SDF)
{
std::string pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/sdf";
Expand Down Expand Up @@ -1007,7 +1007,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 @@ -1075,7 +1075,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 @@ -1143,7 +1143,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 @@ -1212,7 +1212,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 @@ -1283,7 +1283,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 @@ -1354,8 +1354,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 @@ -1427,8 +1426,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 @@ -1499,8 +1497,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 @@ -1568,7 +1565,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 @@ -1617,8 +1614,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 @@ -1635,7 +1631,7 @@ TEST(print_snap_to_degrees_tolerance_too_high,
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldPoseRelativeTo))
TEST(GraphCmd, WorldPoseRelativeTo)
{
const std::string pathBase = std::string(PROJECT_SOURCE_PATH) + "/test/sdf";

Expand Down Expand Up @@ -1686,7 +1682,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldPoseRelativeTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelPoseRelativeTo))
TEST(GraphCmd, ModelPoseRelativeTo)
{
const std::string pathBase = std::string(PROJECT_SOURCE_PATH) + "/test/sdf";
const std::string path = pathBase + "/model_relative_to_nested_reference.sdf";
Expand Down Expand Up @@ -1762,7 +1758,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelPoseRelativeTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldFrameAttachedTo))
TEST(GraphCmd, WorldFrameAttachedTo)
{
const std::string pathBase = std::string(PROJECT_SOURCE_PATH) + "/test/sdf";
const std::string path = pathBase + "/world_nested_frame_attached_to.sdf";
Expand Down Expand Up @@ -1808,7 +1804,7 @@ TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(WorldFrameAttachedTo))
}

/////////////////////////////////////////////////
TEST(GraphCmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelFrameAttachedTo))
TEST(GraphCmd, ModelFrameAttachedTo)
{
const std::string pathBase = std::string(PROJECT_SOURCE_PATH) + "/test/sdf";
const std::string path = pathBase + "/model_nested_frame_attached_to.sdf";
Expand Down Expand Up @@ -1859,7 +1855,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 pathBase = PROJECT_SOURCE_PATH;
pathBase += "/test/sdf";
Expand Down Expand Up @@ -1948,7 +1944,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