From f308a9d9e30aa0eb6625b07cd690ffe5ee3b0db9 Mon Sep 17 00:00:00 2001 From: Marwan Taher Date: Thu, 16 Jul 2020 15:25:35 +0100 Subject: [PATCH] fixed failing tests Signed-off-by: Marwan Taher --- rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp | 9 +++++++++ .../test/rosbag2_tests/test_rosbag2_cpp_api.cpp | 2 -- .../rosbag2_tests/test_rosbag2_record_end_to_end.cpp | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp b/rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp index c9631662a..88a2beebb 100644 --- a/rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp +++ b/rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp @@ -47,6 +47,9 @@ class SequentialWriterTest : public Test storage_options_ = rosbag2_cpp::StorageOptions{}; storage_options_.uri = "uri"; + rcpputils::fs::path dir(storage_options_.uri); + rcpputils::fs::remove(dir); + ON_CALL(*storage_factory_, open_read_write(_, _)).WillByDefault( DoAll( Invoke( @@ -59,6 +62,12 @@ class SequentialWriterTest : public Test *storage_factory_, open_read_write(_, _)).Times(AtLeast(0)); } + ~SequentialWriterTest() + { + rcpputils::fs::path dir(storage_options_.uri); + rcpputils::fs::remove(dir); + } + std::unique_ptr> storage_factory_; std::shared_ptr> storage_; std::shared_ptr> converter_factory_; diff --git a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp index bf2f69b51..1a73038a4 100644 --- a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp +++ b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp @@ -43,8 +43,6 @@ TEST(TestRosbag2CPPAPI, minimal_writer_example) auto rosbag_directory = rcpputils::fs::path("test_rosbag2_writer_api_bag"); // in case the bag was previously not cleaned up rcpputils::fs::remove_all(rosbag_directory); - // See https://github.com/ros2/rosbag2/issues/448 - rcpputils::fs::create_directories(rosbag_directory); rosbag2_cpp::StorageOptions storage_options; storage_options.uri = rosbag_directory.string(); diff --git a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp index aa3f18ae2..05a317a46 100644 --- a/rosbag2_tests/test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp +++ b/rosbag2_tests/test/rosbag2_tests/test_rosbag2_record_end_to_end.cpp @@ -559,7 +559,7 @@ TEST_F(RecordFixture, record_fails_gracefully_if_bag_already_exists) { TEST_F(RecordFixture, record_fails_if_both_all_and_topic_list_is_specified) { internal::CaptureStderr(); auto exit_code = - execute_and_wait_until_completion("ros2 bag record -a /some_topic", temporary_dir_path_); + WEXITSTATUS(std::system("ros2 bag record -a /some_topic")); auto error_output = internal::GetCapturedStderr(); EXPECT_THAT(exit_code, Eq(EXIT_FAILURE)); @@ -569,7 +569,7 @@ TEST_F(RecordFixture, record_fails_if_both_all_and_topic_list_is_specified) { TEST_F(RecordFixture, record_fails_gracefully_if_plugin_for_given_encoding_does_not_exist) { internal::CaptureStderr(); auto exit_code = - execute_and_wait_until_completion("ros2 bag record -a -f some_rmw", temporary_dir_path_); + WEXITSTATUS(std::system("ros2 bag record -a -f some_rmw")); auto error_output = internal::GetCapturedStderr(); EXPECT_THAT(exit_code, Eq(EXIT_SUCCESS));