# # # rename "tests/automate_inventory_path" # to "tests/automate_inventory_restricted" # # patch "automate.cc" # from [4ab65bfa700aaaa42fcce88c0775ff27b91f95eb] # to [0b069225c69d0f003ed861ced836ed760702265f] # # patch "tests/automate_inventory/__driver__.lua" # from [540b5b0d30ee4722cd4fc0a613337418f59edc1d] # to [ed2aa6e3c4fee34bc3b63974eb202b085e7bb13e] # # patch "tests/common/test_utils_inventory.lua" # from [fa05a01424195cd1b145f6e564d161fd1446ae5d] # to [d0343ce781bb1284387d194b7a3e50d2b7a52c0d] # ============================================================ --- automate.cc 4ab65bfa700aaaa42fcce88c0775ff27b91f95eb +++ automate.cc 0b069225c69d0f003ed861ced836ed760702265f @@ -662,7 +662,7 @@ inventory_itemizer::visit_file(file_path void inventory_itemizer::visit_file(file_path const & path) { - if(mask.includes(path)) + if (mask.includes(path)) { inventory_item & item = inventory[path]; @@ -686,7 +686,7 @@ inventory_filesystem(path_restriction co // The constructor file_path() returns ""; the root directory. walk_tree // does not visit that node, so set fs_type now, if it meets the // restriction. - if(mask.includes(root)) + if (mask.includes(root)) { inventory[root].fs_type = path::directory; } @@ -796,12 +796,8 @@ inventory_print_changes(inventory_item c switch (item.old_node.type) { - case path::file : - if (item.fs_ident != old_file->content) - changes.push_back("content"); - break; - - case path::nonexistent : + case path::file: + case path::nonexistent: // A file can be nonexistent due to mtn drop, user delete, mtn // rename, or user rename. If it was drop or delete, it would // not be in the new roster, and we would not get here. So @@ -811,7 +807,7 @@ inventory_print_changes(inventory_item c changes.push_back("content"); break; - case path::directory : + case path::directory: break; } } ============================================================ --- tests/automate_inventory/__driver__.lua 540b5b0d30ee4722cd4fc0a613337418f59edc1d +++ tests/automate_inventory/__driver__.lua ed2aa6e3c4fee34bc3b63974eb202b085e7bb13e @@ -1,6 +1,6 @@ -- Test 'automate inventory', with no path or depth restrictions -- --- path and depth restrictions are tested in ../automate_inventory_path +-- path and depth restrictions are tested in ../automate_inventory_restricted local index = 1 @@ -11,26 +11,7 @@ include ("common/test_utils_inventory.lu include ("common/test_utils_inventory.lua") ---------- --- main process - --- 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 +-- create a basic file history; add some files, then operate on -- each of them in some way. addfile("missing", "missing") ============================================================ --- tests/common/test_utils_inventory.lua fa05a01424195cd1b145f6e564d161fd1446ae5d +++ tests/common/test_utils_inventory.lua d0343ce781bb1284387d194b7a3e50d2b7a52c0d @@ -1,27 +1,31 @@ -- Functions useful in tests/automate_inventory* -function checkexp (label, computed, expected) +function checkexp (label, computed, expected, xfail) -- Throw an error with a helpful message if 'computed' doesn't equal -- 'expected'. if computed ~= expected then - err (label .. " Expected '" .. expected .. "' got '" .. computed .. "'") + if xfail then + err(false, 2) + else + err (label .. " Expected '" .. expected .. "' got '" .. computed .. "'") + end end end -function check_basic_io_line (label, computed, name, value) +function check_basic_io_line (label, computed, name, value, xfail) -- Compare a parsed basic_io line 'computed' to 'name', 'value', throw -- an error (with a helpful message) if they don't match. - checkexp(label .. ".name", computed.name, name) + checkexp(label .. ".name", computed.name, name, xfail) if type(value) == "table" then - checkexp(label .. ".length", #computed.values, #value) + checkexp(label .. ".length", #computed.values, #value, xfail) for i = 1, #value do - checkexp(label .. i, computed.values[i], value[i]) + checkexp(label .. i, computed.values[i], value[i], xfail) end else - checkexp(label .. ".length", #computed.values, 1) - checkexp(label .. "." .. name, computed.values[1], value) + checkexp(label .. ".length", #computed.values, 1, xfail) + checkexp(label .. "." .. name, computed.values[1], value, xfail) end end @@ -43,53 +47,55 @@ end err ("line '" .. line.name .. " " .. line.values .. "' not found") end -function fail_check_inventory (skip, parsed, parsed_index, stanza) --- Skip this test, since it is currently failing; run rest of current test - - return parsed_index + skip +function xfail_inventory (parsed, parsed_index, stanza) + return check_inventory(parsed, parsed_index, stanza, true) end -- check_inventory -function check_inventory (parsed, parsed_index, stanza) +function check_inventory (parsed, parsed_index, stanza, xfail) -- 'stanza' is a table for one stanza -- 'parsed_index' gives the first index for this stanza in 'parsed' -- (which should be the output of parse_basic_io). -- Returns parsed_index incremented to the next index to check. - check_basic_io_line (parsed_index, parsed[parsed_index], "path", stanza.path) + -- we assume that any test failure is not an expected failure if not + -- otherwise given + if xfail == nil then xfail = false end + + check_basic_io_line (parsed_index, parsed[parsed_index], "path", stanza.path, xfail) parsed_index = parsed_index + 1 if stanza.old_type then - check_basic_io_line (parsed_index, parsed[parsed_index], "old_type", stanza.old_type) + check_basic_io_line (parsed_index, parsed[parsed_index], "old_type", stanza.old_type, xfail) parsed_index = parsed_index + 1 end if stanza.new_path then - check_basic_io_line (parsed_index, parsed[parsed_index], "new_path", stanza.new_path) + check_basic_io_line (parsed_index, parsed[parsed_index], "new_path", stanza.new_path, xfail) parsed_index = parsed_index + 1 end if stanza.new_type then - check_basic_io_line (parsed_index, parsed[parsed_index], "new_type", stanza.new_type) + check_basic_io_line (parsed_index, parsed[parsed_index], "new_type", stanza.new_type, xfail) parsed_index = parsed_index + 1 end if stanza.old_path then - check_basic_io_line (parsed_index, parsed[parsed_index], "old_path", stanza.old_path) + check_basic_io_line (parsed_index, parsed[parsed_index], "old_path", stanza.old_path, xfail) parsed_index = parsed_index + 1 end if stanza.fs_type then - check_basic_io_line (parsed_index, parsed[parsed_index], "fs_type", stanza.fs_type) + check_basic_io_line (parsed_index, parsed[parsed_index], "fs_type", stanza.fs_type, xfail) parsed_index = parsed_index + 1 end if stanza.status then - check_basic_io_line (parsed_index, parsed[parsed_index], "status", stanza.status) + check_basic_io_line (parsed_index, parsed[parsed_index], "status", stanza.status, xfail) parsed_index = parsed_index + 1 end if stanza.changes then - check_basic_io_line (parsed_index, parsed[parsed_index], "changes", stanza.changes) + check_basic_io_line (parsed_index, parsed[parsed_index], "changes", stanza.changes, xfail) parsed_index = parsed_index + 1 end