Skip to content

Commit 42ee616

Browse files
Improve IDL parser tests (#5559)
* Refs #20523. Fix typo on `#include` Signed-off-by: Miguel Company <[email protected]> * Refs #20523. CMake error when submodule is not initialized. Signed-off-by: Miguel Company <[email protected]> * Refs #20523. Move submodule check to idl_parser test CMake. Signed-off-by: Miguel Company <[email protected]> * Refs #20523. Uncrustify. Signed-off-by: Miguel Company <[email protected]> * Refs #20523. Use lambda for pipe deleter. Signed-off-by: Miguel Company <[email protected]> * Refs #20523. Uncrustify. Signed-off-by: Miguel Company <[email protected]> --------- Signed-off-by: Miguel Company <[email protected]>
1 parent bb1ff44 commit 42ee616

File tree

4 files changed

+346
-152
lines changed

4 files changed

+346
-152
lines changed

src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class PreprocessorContext
127127

128128
return std::make_pair(std::move(tmp_file), std::string(filename_buffer.data()));
129129
}
130+
130131
#else
131132
std::pair<std::ofstream, std::string> get_temporary_file() const
132133
{
@@ -156,6 +157,7 @@ class PreprocessorContext
156157
// Return the file stream and the file name
157158
return std::make_pair(std::move(tmp_file), std::string(filename_template.begin(), filename_template.end() - 1));
158159
}
160+
159161
#endif // _MSC_VER
160162

161163
void replace_all_string(
@@ -184,8 +186,12 @@ class PreprocessorContext
184186
std::string exec(
185187
const std::string& cmd) const
186188
{
187-
std::unique_ptr<FILE, decltype(& pclose)> pipe(
188-
popen(cmd.c_str(), EPROSIMA_PLATFORM_PIPE_OPEN_FLAGS), pclose);
189+
auto deleter = [](FILE* f)
190+
{
191+
pclose(f);
192+
};
193+
std::unique_ptr<FILE, decltype(deleter)> pipe(
194+
popen(cmd.c_str(), EPROSIMA_PLATFORM_PIPE_OPEN_FLAGS), deleter);
189195
if (!pipe)
190196
{
191197
throw std::runtime_error("popen() failed!");

test/feature/CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# limitations under the License.
1414

1515
add_subdirectory(dynamic_types)
16-
17-
if(EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/dds-types-test/IDL")
18-
add_subdirectory(idl_parser)
19-
else()
20-
message(WARNING "Folder thirdparty/dds-types-test/IDL does not exist. Submodule thirdparty/dds-types-test might not have been initialized.")
21-
endif()
16+
add_subdirectory(idl_parser)

test/feature/idl_parser/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/dds-types-test/IDL")
16+
message(FATAL_ERROR "Folder thirdparty/dds-types-test/IDL does not exist. Submodule thirdparty/dds-types-test might not have been initialized.")
17+
endif()
18+
1519
if(WIN32)
1620
add_definitions(
1721
-D_WIN32_WINNT=0x0601

0 commit comments

Comments
 (0)