# # # patch "ChangeLog" # from [4267d049a202992d1272b264ff1aade7b32f6108] # to [f971b25ca4e2179c7e9f1e626b97c094e3d9762c] # # patch "cset.cc" # from [a8497f9a82330f842cda2f242e97ef48e3a6b9fb] # to [5fdac8f01ad19e4a427e40aa4245026b534422f7] # ============================================================ --- ChangeLog 4267d049a202992d1272b264ff1aade7b32f6108 +++ ChangeLog f971b25ca4e2179c7e9f1e626b97c094e3d9762c @@ -1,5 +1,10 @@ 2006-02-25 Nathaniel Smith + * cset.cc (root_dir_test, invalid_csets_test): Don't test that + root dir stuff fails. Test that it works. + +2006-02-25 Nathaniel Smith + * roster.cc (detach_node): Add missing invariant. 2006-02-25 Nathaniel Smith ============================================================ --- cset.cc a8497f9a82330f842cda2f242e97ef48e3a6b9fb +++ cset.cc 5fdac8f01ad19e4a427e40aa4245026b534422f7 @@ -1072,56 +1072,76 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(FL("TEST: can't rename root (for now)")); + L(FL("TEST: can't delete non-empty directory")); setup_roster(r, f1, nis); cset cs; MM(cs); - split_path sp1, sp2; - cs.dirs_added.insert(root); - cs.nodes_renamed.insert(std::make_pair(root, baz)); + cs.nodes_deleted.insert(foo); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(FL("TEST: can't delete non-empty directory")); - setup_roster(r, f1, nis); + L(FL("TEST: attach node with no root directory present")); + // for this test, make sure original roster has no contents + r = roster_t(); cset cs; MM(cs); - cs.nodes_deleted.insert(foo); + split_path sp; + file_path_internal("blah/blah/blah").split(sp); + cs.dirs_added.insert(sp); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(FL("TEST: can't delete root")); - // for this test, make sure root has no contents - r = roster_t(); + L(FL("TEST: can't move a directory underneath itself")); + setup_roster(r, f1, nis); cset cs; MM(cs); - cs.nodes_deleted.insert(root); + split_path foo_blah; + file_path_internal("foo/blah").split(foo_blah); + cs.nodes_renamed.insert(std::make_pair(foo, foo_blah)); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } +} + +void +root_dir_test() +{ + temp_node_id_source nis; + roster_t r; + MM(r); + editable_roster_base tree(r, nis); + + file_id f1(std::string("0000000000000000000000000000000000000001")); + + split_path root, baz; + file_path().split(root); + file_path_internal("baz").split(baz); + { - L(FL("TEST: can't delete and replace root")); - // for this test, make sure root has no contents - r = roster_t(); + L(FL("TEST: can rename root")); + setup_roster(r, f1, nis); cset cs; MM(cs); - cs.nodes_deleted.insert(root); + split_path sp1, sp2; cs.dirs_added.insert(root); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_renamed.insert(std::make_pair(root, baz)); + cs.apply_to(tree); + r.check_sane(true); } { - L(FL("TEST: attach node with no root directory present")); + L(FL("TEST: can delete root (but it makes us insane)")); // for this test, make sure root has no contents r = roster_t(); + r.attach_node(r.create_dir_node(nis), root); cset cs; MM(cs); - split_path sp; - file_path_internal("blah/blah/blah").split(sp); - cs.dirs_added.insert(sp); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_deleted.insert(root); + cs.apply_to(tree); + BOOST_CHECK_THROW(r.check_sane(true), std::logic_error); } { - L(FL("TEST: can't move a directory underneath itself")); - setup_roster(r, f1, nis); + L(FL("TEST: can delete and replace root")); + r = roster_t(); + r.attach_node(r.create_dir_node(nis), root); cset cs; MM(cs); - split_path foo_blah; - file_path_internal("foo/blah").split(foo_blah); - cs.nodes_renamed.insert(std::make_pair(foo, foo_blah)); - BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); + cs.nodes_deleted.insert(root); + cs.dirs_added.insert(root); + cs.apply_to(tree); + r.check_sane(true); } } @@ -1132,6 +1152,7 @@ suite->add(BOOST_TEST_CASE(&basic_csets_test)); suite->add(BOOST_TEST_CASE(&invalid_csets_test)); suite->add(BOOST_TEST_CASE(&cset_written_test)); + suite->add(BOOST_TEST_CASE(&root_dir_test)); } #endif // BUILD_UNIT_TESTS