Skip to content

Commit

Permalink
Improve IDL parser tests (#5567)
Browse files Browse the repository at this point in the history
* Refs #20523. Fix typo on `#include`

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20523. CMake error when submodule is not initialized.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20523. Move submodule check to idl_parser test CMake.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20523. Uncrustify.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20523. Use lambda for pipe deleter.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20523. Uncrustify.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Jan 13, 2025
1 parent 490e80b commit 74d8e27
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class PreprocessorContext

return std::make_pair(std::move(tmp_file), std::string(filename_buffer.data()));
}

#else
std::pair<std::ofstream, std::string> get_temporary_file() const
{
Expand Down Expand Up @@ -156,6 +157,7 @@ class PreprocessorContext
// Return the file stream and the file name
return std::make_pair(std::move(tmp_file), std::string(filename_template.begin(), filename_template.end() - 1));
}

#endif // _MSC_VER

void replace_all_string(
Expand Down Expand Up @@ -184,8 +186,12 @@ class PreprocessorContext
std::string exec(
const std::string& cmd) const
{
std::unique_ptr<FILE, decltype(& pclose)> pipe(
popen(cmd.c_str(), EPROSIMA_PLATFORM_PIPE_OPEN_FLAGS), pclose);
auto deleter = [](FILE* f)
{
pclose(f);
};
std::unique_ptr<FILE, decltype(deleter)> pipe(
popen(cmd.c_str(), EPROSIMA_PLATFORM_PIPE_OPEN_FLAGS), deleter);
if (!pipe)
{
throw std::runtime_error("popen() failed!");
Expand Down
7 changes: 1 addition & 6 deletions test/feature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@
# limitations under the License.

add_subdirectory(dynamic_types)

if(EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/dds-types-test/IDL")
add_subdirectory(idl_parser)
else()
message(WARNING "Folder thirdparty/dds-types-test/IDL does not exist. Submodule thirdparty/dds-types-test might not have been initialized.")
endif()
add_subdirectory(idl_parser)
4 changes: 4 additions & 0 deletions test/feature/idl_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/dds-types-test/IDL")
message(FATAL_ERROR "Folder thirdparty/dds-types-test/IDL does not exist. Submodule thirdparty/dds-types-test might not have been initialized.")
endif()

if(WIN32)
add_definitions(
-D_WIN32_WINNT=0x0601
Expand Down
Loading

0 comments on commit 74d8e27

Please sign in to comment.