# # # rename "tests/test_utils_inventory.lua" # to "tests/common/test_utils_inventory.lua" # # patch "automate.cc" # from [025b8c30a4779440a6425650a1f73252a2f9e977] # to [4ab65bfa700aaaa42fcce88c0775ff27b91f95eb] # # patch "tests/automate_inventory/__driver__.lua" # from [bd34de7a1a6b3912bfcd12eecf9d75713326c7e1] # to [540b5b0d30ee4722cd4fc0a613337418f59edc1d] # # patch "tests/automate_inventory_path/__driver__.lua" # from [64fea67a8ee61843c6e50c2787c7299b8b2e0025] # to [1aacea01020abd0928e79bb01f5cd5dd89b73e81] # ============================================================ --- automate.cc 025b8c30a4779440a6425650a1f73252a2f9e977 +++ automate.cc 4ab65bfa700aaaa42fcce88c0775ff27b91f95eb @@ -891,50 +891,15 @@ CMD_AUTOMATE(inventory, N_("[PATH]...") if (i->first.as_internal() == "") { - // This is the workspace root directory. The default algorithm - // displays it wrong, so we treat is as a special case. - // - // FIXME: Consider a just setup'ed workspace where there hasn't been - // any version committed yet, this code produces: - // - // path "." - // old_type "directory" - // new_type "directory" - // fs_type "directory" - // status "added" "missing" - // - // which is purely wrong, because there is no "old_type". It gets - // slightly better if we comment this special treating out: - // - // path "" - // new_type "directory" - // fs_type "none" - // status "added" "missing" - // - // which is still not completly correct, but at least "added" - // complements no wrong "old_type" node. The idea / correct output - // for this example should be: - // - // path "." - // new_type "directory" - // fs_type "directory" - // status "added" - // + // This is the workspace root directory; print a nicer name. st.push_str_pair(syms::path, "."); - st.push_str_pair(syms::old_type, "directory"); - st.push_str_pair(syms::new_type, "directory"); - st.push_str_pair(syms::fs_type, "directory"); - - inventory_print_states(app, i->first, item, old_roster, new_roster, st); - inventory_print_changes(item, old_roster, st); - - pr.print_stanza(st); - continue; } + else + { + // Not the root directory + st.push_file_pair(syms::path, i->first); + } - // Not the root directory - st.push_file_pair(syms::path, i->first); - if (item.old_node.exists) { switch (item.old_node.type) ============================================================ --- tests/automate_inventory/__driver__.lua bd34de7a1a6b3912bfcd12eecf9d75713326c7e1 +++ tests/automate_inventory/__driver__.lua 540b5b0d30ee4722cd4fc0a613337418f59edc1d @@ -8,14 +8,31 @@ check(getstd("inventory_hooks.lua")) check(getstd("inventory_hooks.lua")) -include ("test_utils_inventory.lua") +include ("common/test_utils_inventory.lua") ---------- -- main process --- create a basic file history; add some files, then operate on each --- of them in some way. +-- First test inventory in a totally empty workspace, with no commits +check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) + +parsed = parse_basic_io(readfile("stdout")) + +index = check_inventory (parsed, index, +{path = ".", + fs_type = "directory", + status = {"unknown"}}) +-- FIXME: The correct output for this example should be: +-- path "." +-- new_type "directory" +-- fs_type "directory" +-- status "added" + +---------- +-- Now create a basic file history; add some files, then operate on +-- each of them in some way. + addfile("missing", "missing") addfile("dropped", "dropped") addfile("original", "original") @@ -35,11 +52,13 @@ check(mtn("drop", "--bookkeep-only", "dr check(mtn("rename", "--bookkeep-only", "original", "renamed"), 0, false, false) check(mtn("drop", "--bookkeep-only", "dropped"), 0, false, false) --- Now see what 'automate inventory' has to say +---------- +-- see what 'automate inventory' has to say check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) parsed = parse_basic_io(readfile("stdout")) +index = 1 index = check_inventory (parsed, index, {path = ".", @@ -550,7 +569,7 @@ new_type = "file", -- (there is at least one known wrong state where it is applied: when a -- rename_target item is missing...) --- FIXME: tests for renaming directories +-- FIXME: tests for renaming directories -- also test that iff foo/ is renamed to bar/, any previous foo/node is -- now listed as bar/node ============================================================ --- tests/automate_inventory_path/__driver__.lua 64fea67a8ee61843c6e50c2787c7299b8b2e0025 +++ tests/automate_inventory_path/__driver__.lua 1aacea01020abd0928e79bb01f5cd5dd89b73e81 @@ -11,7 +11,7 @@ check(getstd("inventory_hooks.lua")) check(getstd("inventory_hooks.lua")) -include ("test_utils_inventory.lua") +include ("common/test_utils_inventory.lua") ---------- -- main process