Skip to content

Commit

Permalink
Use sdf::Filesystem, const ref, always install
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina committed Jun 15, 2022
1 parent 6a67dec commit 488d2ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 4 additions & 2 deletions cmake/SearchForStuff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ ignition-tools.")
endif()
if (ignition-tools_FOUND)
set (HAVE_IGN_TOOLS TRUE)
set (IGN_TOOLS_VER 1)
endif()
# Note that CLI files are installed regardless of whether the dependency is
# available during build time
set (IGN_TOOLS_VER 1)

################################################
# Find the Python interpreter for running the
Expand Down Expand Up @@ -132,7 +134,7 @@ endmacro()

########################################
# Find ignition cmake2
# Only for using the testing macros and creating the codecheck target, not
# Only for using the testing macros and creating the codecheck target, not
# really being use to configure the whole project
find_package(ignition-cmake2 REQUIRED)
set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR})
Expand Down
12 changes: 5 additions & 7 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition)
configure_file(
"sdf.bash_completion.sh"
"${CMAKE_CURRENT_BINARY_DIR}/sdf${PROJECT_VERSION_MAJOR}.bash_completion.sh" @ONLY)
if (HAVE_IGN_TOOLS)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/sdf${PROJECT_VERSION_MAJOR}.bash_completion.sh
DESTINATION
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${IGN_TOOLS_VER}.completion.d)
endif()
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/sdf${PROJECT_VERSION_MAJOR}.bash_completion.sh
DESTINATION
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${IGN_TOOLS_VER}.completion.d)
11 changes: 6 additions & 5 deletions src/ign_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*
*/

#include <filesystem>
#include <gtest/gtest.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>

#include "sdf/Filesystem.hh"
#include "sdf/parser.hh"
#include "sdf/SDFImpl.hh"
#include "sdf/sdf_config.h"
Expand Down Expand Up @@ -825,12 +825,13 @@ TEST(HelpVsCompletionFlags, SDF)
std::string helpOutput = custom_exec_str(IgnCommand() + " sdf --help");

// Call the output function in the bash completion script
std::filesystem::path scriptPath = PROJECT_SOURCE_PATH;
scriptPath = scriptPath / "src" / "cmd" / "sdf.bash_completion.sh";
std::string scriptPath = PROJECT_SOURCE_PATH;
scriptPath = sdf::filesystem::append(scriptPath, "src", "cmd",
"sdf.bash_completion.sh");

// Equivalent to:
// sh -c "bash -c \". /path/to/sdf.bash_completion.sh; _gz_sdf_flags\""
std::string cmd = "bash -c \". " + scriptPath.string() +
std::string cmd = "bash -c \". " + scriptPath +
"; _gz_sdf_flags\"";
std::string scriptOutput = custom_exec_str(cmd);

Expand All @@ -842,7 +843,7 @@ TEST(HelpVsCompletionFlags, SDF)
EXPECT_GT(flags.size(), 0u);

// Match each flag in script output with help message
for (std::string flag : flags)
for (const auto &flag : flags)
{
EXPECT_NE(std::string::npos, helpOutput.find(flag)) << helpOutput;
}
Expand Down

0 comments on commit 488d2ac

Please sign in to comment.