Skip to content

Commit

Permalink
fixed failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
  • Loading branch information
Marwan99 committed Jul 21, 2020
1 parent 0349e04 commit ae6fd06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 9 additions & 0 deletions rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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<StrictMock<MockStorageFactory>> storage_factory_;
std::shared_ptr<NiceMock<MockStorage>> storage_;
std::shared_ptr<StrictMock<MockConverterFactory>> converter_factory_;
Expand Down
2 changes: 0 additions & 2 deletions rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down

0 comments on commit ae6fd06

Please sign in to comment.