Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix splitting tests on windows #407

Merged
merged 4 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions rosbag2_tests/test/rosbag2_tests/record_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class RecordFixture : public TemporaryDirectoryFixture
rclcpp::init(0, nullptr);
}

void TearDown() override
{
remove_directory_recursively(root_bag_path_.string());
}

static void TearDownTestCase()
{
rclcpp::shutdown();
Expand Down Expand Up @@ -92,6 +97,11 @@ class RecordFixture : public TemporaryDirectoryFixture
return root_bag_path_ / (get_bag_file_name(split_index) + ".db3");
}

rcpputils::fs::path get_relative_bag_file_path(int split_index)
{
return rcpputils::fs::path(get_bag_file_name(split_index) + ".db3");
}

void wait_for_metadata()
{
const auto metadata_path = root_bag_path_ / "metadata.yaml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,9 @@ TEST_F(RecordFixture, record_end_to_end_with_splitting_bagsize_split_is_at_least

// Loop until expected_splits in case it split or the bagfile doesn't exist.
for (int i = 0; i < expected_splits; ++i) {
const auto bag_file_path = get_bag_file_name(i);

if (rcpputils::fs::path(bag_file_path).exists()) {
metadata.relative_file_paths.push_back(bag_file_path);
} else {
break;
const auto bag_file_path = get_relative_bag_file_path(i);
if (rcpputils::fs::exists(root_bag_path_ / bag_file_path)) {
metadata.relative_file_paths.push_back(bag_file_path.string());
}
}

Expand Down Expand Up @@ -390,13 +387,13 @@ TEST_F(RecordFixture, record_end_to_end_with_splitting_splits_bagfile) {
metadata.storage_identifier = "sqlite3";

for (int i = 0; i < expected_splits; ++i) {
const auto bag_file_path = get_bag_file_name(i);
const auto rel_bag_file_path = get_relative_bag_file_path(i);

// There is no guarantee that the bagfile split expected_split times
// due to possible io sync delays. Instead, assert that the bagfile split
// at least once
if (rcpputils::fs::path(bag_file_path).exists()) {
metadata.relative_file_paths.push_back(bag_file_path);
if (rcpputils::fs::exists(root_bag_path_ / rel_bag_file_path)) {
metadata.relative_file_paths.push_back(rel_bag_file_path.string());
}
}

Expand Down