# # # add_file "tests/common/basic_io.lua" # content [826f7b371bfa7f4091972e8b0aaf7b10adf5b858] # # patch "tests/automate_inventory/__driver__.lua" # from [2e9f9f2eed991ec9008d79eba023e2d634c0191e] # to [0b2f84a2b87b5eec92c2818cbf1b3535631a0922] # # patch "tests/automate_inventory_ignore_dirs/__driver__.lua" # from [6233a5c18211c0718b96af2800b393076a7585ae] # to [03f5ad3fdea64dcddd718785513fc10b0feb4156] # # patch "tests/automate_inventory_options/__driver__.lua" # from [3a0944057bf7a7bda8d5efb98a3769c130885996] # to [8e89bdbaa5b76d80d881ccf0946ea16155a26351] # # patch "tests/automate_inventory_restricted/__driver__.lua" # from [e24990972a5fe7b2ac00d415f91e94a28d3cbf92] # to [64a999ffcc6aff7410d4576a055e4f82eae2de1a] # # patch "tests/automate_key_manage/__driver__.lua" # from [31053a9f53f5fddfe9ff583a324d998a35bd4456] # to [e3f06937fc7cf9b6a5b06d9906c584127b4a6ae6] # # patch "tests/automate_show_conflicts_defaults/__driver__.lua" # from [69dc55a68ddeced4a661699654e15b257679e619] # to [be2e2034286d216850364195cfa0cf3b0ab084c7] # # patch "tests/common/test_utils_inventory.lua" # from [780502a124f1af69badad0d2e53b0b957cfa3caa] # to [a5658a1a522e31daaf136ac92143a5ae59f658d4] # # patch "tests/renaming_a_directory/__driver__.lua" # from [0052b354468484c71e79945a96b4544f74c048f2] # to [b908875126d5318bae9bdb732f4d027462933f1d] # ============================================================ --- tests/common/basic_io.lua 826f7b371bfa7f4091972e8b0aaf7b10adf5b858 +++ tests/common/basic_io.lua 826f7b371bfa7f4091972e8b0aaf7b10adf5b858 @@ -0,0 +1,50 @@ +-- Functions useful with parse_basic_io + +function checkexp (label, computed, expected, xfail) +-- Throw an error with a helpful message if 'computed' doesn't equal +-- 'expected'. + if computed ~= expected then + 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, 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, xfail) + + if type(value) == "table" then + checkexp(label .. ".length", #computed.values, #value, xfail) + for i = 1, #value do + checkexp(label .. i, computed.values[i], value[i], xfail) + end + + else + checkexp(label .. ".length", #computed.values, 1, xfail) + checkexp(label .. "." .. name, computed.values[1], value, xfail) + end +end + +function find_basic_io_line (parsed, line) +-- return index in parsed (output of parse_basic_io) matching +-- line.name, line.values + for I = 1, #parsed do + if parsed[I].name == line.name then + if type (line.values) ~= "table" then + if parsed[I].values[1] == line.values then + return I + end + else + err ("searching for line with table of values not yet supported") + end + end + end + + err ("line '" .. line.name .. " " .. line.values .. "' not found") +end + +-- end of file ============================================================ --- tests/automate_inventory/__driver__.lua 2e9f9f2eed991ec9008d79eba023e2d634c0191e +++ tests/automate_inventory/__driver__.lua 0b2f84a2b87b5eec92c2818cbf1b3535631a0922 @@ -8,7 +8,8 @@ check(getstd("inventory_hooks.lua")) check(getstd("inventory_hooks.lua")) -include ("common/test_utils_inventory.lua") +include("common/basic_io.lua") +include("common/test_utils_inventory.lua") ---------- -- create a basic file history; add some files, then operate on ============================================================ --- tests/automate_inventory_ignore_dirs/__driver__.lua 6233a5c18211c0718b96af2800b393076a7585ae +++ tests/automate_inventory_ignore_dirs/__driver__.lua 03f5ad3fdea64dcddd718785513fc10b0feb4156 @@ -26,7 +26,8 @@ check(get("local_hooks.lua")) check(get("local_hooks.lua")) -include ("common/test_utils_inventory.lua") +include("common/basic_io.lua") +include("common/test_utils_inventory.lua") ---------- -- The local local_hooks.lua defines ignore_file to ignore 'ignored' ============================================================ --- tests/automate_inventory_options/__driver__.lua 3a0944057bf7a7bda8d5efb98a3769c130885996 +++ tests/automate_inventory_options/__driver__.lua 8e89bdbaa5b76d80d881ccf0946ea16155a26351 @@ -21,6 +21,7 @@ check(get("expected-renames-target-no-un check(get("expected-renames-target-no-ignored.stdout")) check(get("expected-renames-target-no-unknown.stdout")) +include("common/basic_io.lua") include("common/test_utils_inventory.lua") mkdir("source") ============================================================ --- tests/automate_inventory_restricted/__driver__.lua e24990972a5fe7b2ac00d415f91e94a28d3cbf92 +++ tests/automate_inventory_restricted/__driver__.lua 64a999ffcc6aff7410d4576a055e4f82eae2de1a @@ -11,7 +11,8 @@ check(getstd("inventory_hooks.lua")) check(getstd("inventory_hooks.lua")) -include ("common/test_utils_inventory.lua") +include("common/basic_io.lua") +include("common/test_utils_inventory.lua") ---------- -- main process ============================================================ --- tests/automate_key_manage/__driver__.lua 31053a9f53f5fddfe9ff583a324d998a35bd4456 +++ tests/automate_key_manage/__driver__.lua e3f06937fc7cf9b6a5b06d9906c584127b4a6ae6 @@ -7,7 +7,7 @@ mtn_setup() mtn_setup() -include ("common/test_utils_inventory.lua") +include("common/basic_io.lua") check(mtn("automate", "genkey", "address@hidden", "foopass"), 0, false, false) check(mtn("pubkey", "address@hidden"), 0, true) ============================================================ --- tests/automate_show_conflicts_defaults/__driver__.lua 69dc55a68ddeced4a661699654e15b257679e619 +++ tests/automate_show_conflicts_defaults/__driver__.lua be2e2034286d216850364195cfa0cf3b0ab084c7 @@ -2,7 +2,7 @@ -- -- See automate_show_conflicts for all conflict cases -include("common/test_utils_inventory.lua") +include("common/basic_io.lua") include("common/automate_stdio.lua") mtn_setup() ============================================================ --- tests/common/test_utils_inventory.lua 780502a124f1af69badad0d2e53b0b957cfa3caa +++ tests/common/test_utils_inventory.lua a5658a1a522e31daaf136ac92143a5ae59f658d4 @@ -1,52 +1,6 @@ -- Functions useful in tests/automate_inventory* +-- uses basic_io.lua -function checkexp (label, computed, expected, xfail) --- Throw an error with a helpful message if 'computed' doesn't equal --- 'expected'. - if computed ~= expected then - 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, 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, xfail) - - if type(value) == "table" then - checkexp(label .. ".length", #computed.values, #value, xfail) - for i = 1, #value do - checkexp(label .. i, computed.values[i], value[i], xfail) - end - - else - checkexp(label .. ".length", #computed.values, 1, xfail) - checkexp(label .. "." .. name, computed.values[1], value, xfail) - end -end - -function find_basic_io_line (parsed, line) --- return index in parsed (output of parse_basic_io) matching --- line.name, line.values - for I = 1, #parsed do - if parsed[I].name == line.name then - if type (line.values) ~= "table" then - if parsed[I].values[1] == line.values then - return I - end - else - err ("searching for line with table of values not yet supported") - end - end - end - - err ("line '" .. line.name .. " " .. line.values .. "' not found") -end - function xfail_inventory (parsed, parsed_index, stanza) return check_inventory(parsed, parsed_index, stanza, true) end ============================================================ --- tests/renaming_a_directory/__driver__.lua 0052b354468484c71e79945a96b4544f74c048f2 +++ tests/renaming_a_directory/__driver__.lua b908875126d5318bae9bdb732f4d027462933f1d @@ -2,7 +2,8 @@ mtn_setup() mtn_setup() -include ("common/test_utils_inventory.lua") +include("common/basic_io.lua") +include("common/test_utils_inventory.lua") mkdir("foo")