Skip to content

Commit

Permalink
Ensure Kyua can clean up a couple of directories
Browse files Browse the repository at this point in the history
If a test case makes a directory or a file unwritable, Kyua may be unable
to delete it during cleanup.  Correct two test cases so that the work
directories can be cleaned up, or else these tests would be marked as
broken when issue #142 is addressed.
  • Loading branch information
jmmv committed Jun 25, 2015
1 parent 5f219e6 commit b7eb0c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion store/migrate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ATF_TEST_CASE_BODY(detail__backup_database__fail_open)
}


ATF_TEST_CASE(detail__backup_database__fail_create);
ATF_TEST_CASE_WITH_CLEANUP(detail__backup_database__fail_create);
ATF_TEST_CASE_HEAD(detail__backup_database__fail_create)
{
set_md_var("require.user", "unprivileged");
Expand All @@ -88,6 +88,14 @@ ATF_TEST_CASE_BODY(detail__backup_database__fail_create)
store::error, "Cannot create.*dir/test.db.v13.backup",
store::detail::backup_database(fs::path("dir/test.db"), 13));
}
ATF_TEST_CASE_CLEANUP(detail__backup_database__fail_create)
{
if (::chmod("dir", 0755) == -1) {
// If we cannot restore the original permissions, we cannot do much
// more. However, leaving an unwritable directory behind will cause the
// runtime engine to report us as broken.
}
}


ATF_TEST_CASE_WITHOUT_HEAD(detail__migration_file__builtin);
Expand Down
10 changes: 9 additions & 1 deletion utils/fs/operations_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ ATF_TEST_CASE_BODY(is_directory__ok)
}


ATF_TEST_CASE(is_directory__fail);
ATF_TEST_CASE_WITH_CLEANUP(is_directory__fail);
ATF_TEST_CASE_HEAD(is_directory__fail)
{
set_md_var("require.user", "unprivileged");
Expand All @@ -318,6 +318,14 @@ ATF_TEST_CASE_BODY(is_directory__fail)
fs::mkdir(fs::path("dir"), 0000);
ATF_REQUIRE_THROW(fs::error, fs::is_directory(fs::path("dir/foo")));
}
ATF_TEST_CASE_CLEANUP(is_directory__fail)
{
if (::chmod("dir", 0755) == -1) {
// If we cannot restore the original permissions, we cannot do much
// more. However, leaving an unwritable directory behind will cause the
// runtime engine to report us as broken.
}
}


ATF_TEST_CASE_WITHOUT_HEAD(mkdir__ok);
Expand Down

0 comments on commit b7eb0c1

Please sign in to comment.