# # # patch "tests/automate_inventory/__driver__.lua" # from [576e0a16cac638ae1624959055b1c028d24f94c4] # to [35d22f512e8dc2b3098af8b3829615c8dbada266] # ============================================================ --- tests/automate_inventory/__driver__.lua 576e0a16cac638ae1624959055b1c028d24f94c4 +++ tests/automate_inventory/__driver__.lua 35d22f512e8dc2b3098af8b3829615c8dbada266 @@ -41,7 +41,6 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) --- not in previous output -- FIXME: null path is root directory. need to keep for 'pivot_root'; test that index = check_inventory (parsed, index, {path = "", @@ -50,21 +49,18 @@ index = check_inventory (parsed, index, fs_type = "none", status = {"missing"}}) --- AP 0 0 added index = check_inventory (parsed, index, {path = "added", new_type = "file", fs_type = "file", status = {"added", "known"}}) --- D 0 0 dropped index = check_inventory (parsed, index, {path = "dropped", old_type = "file", fs_type = "none", status = "dropped"}) --- I 0 0 ignored index = check_inventory (parsed, index, { path = "ignored~", fs_type = "file", @@ -73,7 +69,6 @@ index = index + 3 * 4 -- skip inventory_hooks.lua, keys, keys/address@hidden, min_hooks.lua index = index + 3 * 4 --- M 0 0 missing index = check_inventory (parsed, index, { path = "missing", old_type = "file", @@ -81,7 +76,6 @@ new_type = "file", fs_type = "none", status = "missing"}) --- R 1 0 original index = check_inventory (parsed, index, { path = "original", old_type = "file", @@ -89,7 +83,6 @@ new_path = "renamed", fs_type = "none", status = "rename_source"}) --- P 0 0 patched index = check_inventory (parsed, index, { path = "patched", old_type = "file", @@ -98,7 +91,6 @@ new_type = "file", status = "known", changes = "content"}) --- R 0 1 renamed index = check_inventory (parsed, index, { path = "renamed", new_type = "file", @@ -109,7 +101,6 @@ index = find_basic_io_line (parsed, {nam -- skip test.db, test_hooks.lua, tester.log, ts-stderr, ts-stdin, ts-stdout index = find_basic_io_line (parsed, {name = "path", values = "unchanged"}) --- 0 0 unchanged index = check_inventory (parsed, index, { path = "unchanged", old_type = "file", @@ -117,13 +108,13 @@ new_type = "file", fs_type = "file", status = "known"}) --- U 0 0 unknown index = check_inventory (parsed, index, { path = "unknown", fs_type = "file", status = "unknown"}) --- swapped but not moved +---------- +-- bookkeep-only swap names check(mtn("revert", "."), 0, false, false) @@ -138,15 +129,16 @@ index = find_basic_io_line (parsed, {nam -- Only check the stanzas for the renamed files index = find_basic_io_line (parsed, {name = "path", values = "original"}) --- FIXME: this output is confusing. And this file's contents are _not_ changed. +-- This requires a bit of explanation. 'path' is the filesystem path. +-- The new manifest says 'original' is renamed to 'unchanged'. But +-- that has not actually been done in the workspace, so the contents +-- of the file are different between the filesystem and the new +-- manifest (they are the same as the old manifest). -- --- tommyd: since the changes were bookkeep-only, the node to which inventory --- refers to with 'path' actually has different contents than what has been --- recorded in the old roster, so its more the question: do we want to guess --- if a file rename was bookkeep-only by comparing fileids or not? If a commit --- happens at this stage, no missing files hinder that, and both file's --- contents are really changed and not swapped as they should, so I vote for --- keeping this flag on here. +-- If the user commits now, they probablyl get something other than +-- what they wanted; '--bookkeep-only' is dangerous. +-- +-- The 'changes' flag indicates that this was bookkeep-only. check_inventory (parsed, index, {path = "original", old_type = "file", @@ -159,7 +151,6 @@ index = find_basic_io_line (parsed, {nam index = find_basic_io_line (parsed, {name = "path", values = "unchanged"}) --- FIXME: this output is confusing. check_inventory (parsed, index, {path = "unchanged", old_type = "file", @@ -170,7 +161,8 @@ check_inventory (parsed, index, status = {"rename_source", "rename_target", "known"}, changes = "content"}) --- swapped and moved +---------- +-- same thing, renamed in filesystem rename("unchanged", "temporary") rename("original", "unchanged") @@ -180,9 +172,9 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) --- Only check the stanzas for the renamed files index = find_basic_io_line (parsed, {name = "path", values = "original"}) +-- Now the 'changes' flag is gone. check_inventory (parsed, index, {path = "original", old_type = "file", @@ -194,7 +186,6 @@ index = find_basic_io_line (parsed, {nam index = find_basic_io_line (parsed, {name = "path", values = "unchanged"}) --- FIXME: this output is confusing. check_inventory (parsed, index, {path = "unchanged", old_type = "file", @@ -204,10 +195,12 @@ check_inventory (parsed, index, fs_type = "file", status = {"rename_source", "rename_target", "known"}}) --- rename foo bar; add foo +---------- +-- rename foo -> bar, add foo check(mtn("revert", "."), 0, false, false) +-- The filesystem rename was done above. check(mtn("rename", "--bookkeep-only", "original", "renamed"), 0, false, false) check(mtn("add", "original"), 0, false, false) @@ -215,9 +208,7 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "original"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "original"}), {path = "original", old_type = "file", new_path = "renamed", @@ -225,9 +216,19 @@ check_inventory (parsed, index, fs_type = "file", status = {"rename_source", "added", "known"}}) --- rotated but not moved +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "renamed"}), +{path = "renamed", + new_type = "file", + old_path = "original", + fs_type = "file", + status = {"rename_target", "known"}}) + +---------- +-- bookkeep-only rename cycle -- dropped -> missing -> original -> dropped +-- "original" has been renamed in filesystem to "renamed" above. + check(mtn("revert", "."), 0, false, false) check(mtn("rename", "--bookkeep-only", "original", "temporary"), 0, false, false) @@ -239,9 +240,9 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "dropped"}) - -check_inventory (parsed, index, +-- This output is pretty confusing. But as we said above in the two +-- file rename test, '--bookkeep-only' is dangerous. +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "dropped"}), {path = "dropped", old_type = "file", new_path = "missing", @@ -275,7 +276,8 @@ old_path = "missing", status = {"rename_source", "rename_target", "known"}, changes = "content"}) --- rotated and moved +---------- +-- same, now renamed in the filesystem rename("original", "temporary") rename("missing", "original") @@ -286,10 +288,7 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "dropped"}) - --- FIXME: the only difference between this and the previous case is the absense of the erroneous 'changes'. -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "dropped"}), {path = "dropped", old_type = "file", new_path = "missing", @@ -298,9 +297,7 @@ old_path = "original", fs_type = "file", status = {"rename_source", "rename_target", "known"}}) -index = find_basic_io_line (parsed, {name = "path", values = "missing"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "missing"}), { path = "missing", old_type = "file", new_path = "original", @@ -309,9 +306,7 @@ old_path = "dropped", fs_type = "file", status = {"rename_source", "rename_target", "known"}}) -index = find_basic_io_line (parsed, {name = "path", values = "original"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "original"}), { path = "original", old_type = "file", new_path = "dropped", @@ -320,7 +315,8 @@ old_path = "missing", fs_type = "file", status = {"rename_source", "rename_target", "known"}}) --- dropped but not removed and thus unknown +---------- +-- bookkeep-only dropped check(mtn("revert", "."), 0, false, false) @@ -330,14 +326,13 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "dropped"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "dropped"}), {path = "dropped", old_type = "file", fs_type = "file", status = {"dropped", "unknown"}}) +---------- -- added but removed and thus missing check(mtn("revert", "."), 0, false, false) @@ -349,15 +344,14 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "added"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "added"}), {path = "added", new_type = "file", fs_type = "none", status = {"added", "missing"}}) --- renamed but not moved and thus unknown source and missing target +---------- +-- bookkeep-only rename; unknown source and missing target check(mtn("revert", "."), 0, false, false) @@ -368,25 +362,22 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "original"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "original"}), {path = "original", old_type = "file", new_path = "renamed", fs_type = "file", status = {"rename_source", "unknown"}}) -index = find_basic_io_line (parsed, {name = "path", values = "renamed"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "renamed"}), {path = "renamed", new_type = "file", old_path = "original", fs_type = "none", status = {"rename_target", "missing"}}) --- moved but not renamed and thus missing source and unknown target +---------- +-- renamed in filesystem only; missing source and unknown target check(mtn("revert", "."), 0, false, false) @@ -396,23 +387,20 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "original"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "original"}), {path = "original", old_type = "file", new_type = "file", fs_type = "none", status = {"missing"}}) -index = find_basic_io_line (parsed, {name = "path", values = "renamed"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "renamed"}), {path = "renamed", fs_type = "file", status = {"unknown"}}) --- renamed and patched +---------- +-- filesystem and manifest renamed and patched check(mtn("revert", "."), 0, false, false) @@ -424,25 +412,22 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "original"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "original"}), {path = "original", old_type = "file", new_path = "renamed", fs_type = "none", status = {"rename_source"}}) -index = find_basic_io_line (parsed, {name = "path", values = "renamed"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "renamed"}), {path = "renamed", new_type = "file", old_path = "original", fs_type = "file", - status = {"renamed", "known"}, + status = {"rename_target", "known"}, changes = "content"}) +---------- -- check if unknown/missing/dropped directories are recognized as such mkdir("new_dir") @@ -450,9 +435,7 @@ parsed = parse_basic_io(readfile("stdout parsed = parse_basic_io(readfile("stdout")) -index = find_basic_io_line (parsed, {name = "path", values = "new_dir"}) - -check_inventory (parsed, index, +check_inventory (parsed, find_basic_io_line (parsed, {name = "path", values = "new_dir"}), {path = "new_dir", fs_type = "directory", status = {"unknown"}})