# # # delete "tests/t_ambig_update.at" # # delete "tests/t_attr.at" # # delete "tests/t_checkout_dir.at" # # delete "tests/t_checkout_options.at" # # delete "tests/t_explicit_merge.at" # # delete "tests/t_patch_vs_drop_add.at" # # delete "tests/t_persistent_server_keys.at" # # delete "tests/t_persistent_server_revision.at" # # delete "tests/t_rcfile_required.at" # # delete "tests/t_trusted.at" # # add_dir "tests/--rcfile_requires_extant_file" # # add_dir "tests/attr_set_attr_get" # # add_dir "tests/checkout_creates_right__MTN_options" # # add_dir "tests/checkout_validates_target_directory" # # add_dir "tests/explicit_merge" # # add_dir "tests/merge(,_)" # # add_dir "tests/persistent_netsync_server_-_keys" # # add_dir "tests/persistent_netsync_server_-_revs_&_certs" # # add_dir "tests/trust_hooks_and_'trusted'_command" # # add_dir "tests/update_with_multiple_candidates" # # add_file "tests/--rcfile_requires_extant_file/__driver__.lua" # content [879ac16a69e9c3bea190bbcc525cb58d977d91e9] # # add_file "tests/attr_set_attr_get/__driver__.lua" # content [d13140261712c3842a400760b3d831253f15bec2] # # add_file "tests/checkout_creates_right__MTN_options/__driver__.lua" # content [d81cdfcfc714d9177a76fe1893b29ac82c0f5276] # # add_file "tests/checkout_validates_target_directory/__driver__.lua" # content [abf318148884207d412f7f064d350ce298bbcdd5] # # add_file "tests/explicit_merge/__driver__.lua" # content [f8a9fd534b53149ca200fcd6f8ff78b886f02bff] # # add_file "tests/explicit_merge/dont_merge" # content [4ff7cd83142091071622b34f578632c69882c26b] # # add_file "tests/explicit_merge/left" # content [0ffe36a4ca2169de7543a67f92134ea93636b246] # # add_file "tests/explicit_merge/merged" # content [aed28f362beb27308db048db953a985fba45d8e7] # # add_file "tests/explicit_merge/right" # content [7478fc33b2476515959ea9be9306295a36a22d64] # # add_file "tests/explicit_merge/testfile" # content [c537e8ec248c6cd32e54cd6fa98ae15743f996b4] # # add_file "tests/merge(,_)/__driver__.lua" # content [4478c937bffa6df632675027e4bf9f01f64c9a7d] # # add_file "tests/persistent_netsync_server_-_keys/__driver__.lua" # content [eae1ebfb480390a12c894c2fad7425a85ccaa3df] # # add_file "tests/persistent_netsync_server_-_revs_&_certs/__driver__.lua" # content [a77842fd1bbe971e12a5eb922d12b188530b26cd] # # add_file "tests/trust_hooks_and_'trusted'_command/__driver__.lua" # content [2fb2c800231ec5cfaedb2c6d5aa261c4e23af59b] # # add_file "tests/update_with_multiple_candidates/__driver__.lua" # content [6023653c9e719109c4b94f1fad13105a8d5b522c] # # patch "tester.lua" # from [69bd2108dd3803934fca93b26a40ba8f46b746e8] # to [a0d28846349bf1c93501f5fb4bb0bb5b9d76dce0] # # patch "testsuite.at" # from [c83ecb9d36ad6f8cca0db9c9c1662a7bb535d6c3] # to [eea978faa60452bacefc4df9597bbc7b0a56645f] # # patch "testsuite.lua" # from [c7dc38733d0fc0a03252b55c4fa9583422e83eea] # to [2f1522737ecaeb9d3308e3ca2a734b8d84be7de4] # ============================================================ --- tests/--rcfile_requires_extant_file/__driver__.lua 879ac16a69e9c3bea190bbcc525cb58d977d91e9 +++ tests/--rcfile_requires_extant_file/__driver__.lua 879ac16a69e9c3bea190bbcc525cb58d977d91e9 @@ -0,0 +1,6 @@ + +mtn_setup() + +-- rcfiles may contain security settings. So make it a hard error if +-- the user typoes or somesuch. +check(cmd(mtn("--rcfile=no-such-file", "status")), 1, false, false) ============================================================ --- tests/attr_set_attr_get/__driver__.lua d13140261712c3842a400760b3d831253f15bec2 +++ tests/attr_set_attr_get/__driver__.lua d13140261712c3842a400760b3d831253f15bec2 @@ -0,0 +1,12 @@ + +mtn_setup() + +addfile("testfile", "foo bar") +check(cmd(mtn("attr", "set", "testfile", "test:unique_key", "unique_value")), 0, false, false) +check(cmd(mtn("attr", "get", "testfile")), 0, true, false) +check(qgrep("test:unique_key", "stdout")) +check(qgrep("unique_value", "stdout")) +check(cmd(mtn("attr", "get", "testfile", "test:unique_key")), 0, true, false) +check(qgrep("unique_value", "stdout")) + +commit() ============================================================ --- tests/checkout_creates_right__MTN_options/__driver__.lua d81cdfcfc714d9177a76fe1893b29ac82c0f5276 +++ tests/checkout_creates_right__MTN_options/__driver__.lua d81cdfcfc714d9177a76fe1893b29ac82c0f5276 @@ -0,0 +1,37 @@ + +mtn_setup() + +addfile("testfile", "foo") +commit() +rev = base_revision() + +-- We use RAW_MTN because it used to be that passing --db= (as +-- MTN does) would hide a bug in this functionality... + +-- all of these inherit options settings from the current _MTN dir +-- unless they override them on the command line + +check(cmd(raw_mtn("checkout", "test_dir1")), 0, false, false) +check(cmd(raw_mtn("--db=test.db", "checkout", "test_dir2")), 0, false, false) +check(cmd(raw_mtn("--db=test.db", "--branch=testbranch", "checkout", "test_dir3")), 0, false, false) +check(cmd(raw_mtn("--branch=testbranch", "checkout", "test_dir4")), 0, false, false) +check(cmd(raw_mtn("--db=test.db", "--branch=testbranch", "checkout", "--revision", rev, "test_dir5")), 0, false, false) +check(cmd(raw_mtn("--branch=testbranch", "checkout", "--revision", rev, "test_dir6")), 0, false, false) +check(cmd(raw_mtn("--db=test.db", "checkout", "--revision", rev, "test_dir7")), 0, false, false) +check(cmd(raw_mtn("checkout", "--revision", rev, "test_dir8")), 0, false, false) + +-- checkout fails if the specified revision is not a member of the specified branch +check(cmd(raw_mtn("--branch=foobar", "checkout", "--revision", rev, "test_dir9")), 1, false, false) +check(cmd(mtn("cert", rev, "branch", "foobar")), 0, false, false) +check(cmd(raw_mtn("--branch=foobar", "checkout", "--revision", rev, "test_dir10")), 0, false, false) + + +for i = 1,8 do + local dir = "test_dir"..i + L("dir = ", dir, "\n") + check(exists(dir.."/_MTN/options")) + check(qgrep("test.db", dir.."/_MTN/options")) + check(qgrep("testbranch", dir.."/_MTN/options")) +end + +check(qgrep("foobar", "test_dir10/_MTN/options")) ============================================================ --- tests/checkout_validates_target_directory/__driver__.lua abf318148884207d412f7f064d350ce298bbcdd5 +++ tests/checkout_validates_target_directory/__driver__.lua abf318148884207d412f7f064d350ce298bbcdd5 @@ -0,0 +1,43 @@ + +mtn_setup() + +addfile("testfile", "foo") +commit() + +check(cmd(mtn("--branch=testbranch", "checkout", "test_dir1")), + 0, false, false) + +writefile("test_dir2") +check(cmd(mtn("--branch=testbranch", "checkout", "test_dir2")), + 1, false, false) + +mkdir("test_dir3") +check(cmd(mtn("--branch=testbranch", "checkout", "test_dir3")), + 1, false, false) + +if existsonpath("chmod") and existsonpath("test") then + -- skip this part if run as root (hi Gentoo!) + if check(cmd("test", "-O", "/"), false, false, false) == 0 then + partial_skip = true + else + mkdir("test_dir4") + check(cmd("chmod", "444", "test_dir4"), 0, false) + check(cmd(mtn("--branch=testbranch", "checkout", "test_dir4")), + 1, false, false) + check(cmd(mtn("--branch=testbranch", "checkout", "test_dir4/subdir")), + 1, false, false) + -- Reset the permissions so Autotest can correctly clean up our + -- temporary directory. + check(cmd("chmod", "700", "test_dir4"), 0, false) + end +else + partial_skip = true +end + +-- checkout normally is disallowed +-- but as a special case, we allow "checkout ." + +mkdir("test_dir5") +chdir("test_dir5") +check(cmd(mtn("--branch=testbranch", "checkout", ".")), 0, false, false) +chdir("..") ============================================================ --- tests/explicit_merge/__driver__.lua f8a9fd534b53149ca200fcd6f8ff78b886f02bff +++ tests/explicit_merge/__driver__.lua f8a9fd534b53149ca200fcd6f8ff78b886f02bff @@ -0,0 +1,34 @@ + +mtn_setup() + +getfile("testfile") +addfile("testfile") +commit() +anc = base_revision() + +getfile("dont_merge") +getfile("left") +getfile("right") +getfile("merged") + +copyfile("dont_merge", "testfile") +commit() + +revert_to(anc) +copyfile("left", "testfile") +commit() +left = base_revision() + +revert_to(anc) +copyfile("right", "testfile") +commit() +right = base_revision() + +check(cmd(mtn("explicit_merge", left, right, "otherbranch")), 0, false, false) + +-- Check that it didn't end up on our current branch, i.e. update doesn't do anything +check(cmd(mtn("update")), 0, false, false) +check(samefile("right", "testfile")) + +check(cmd(mtn("checkout", "--branch=otherbranch", "otherbranch_co")), 0, false, false) +check(samefile("merged", "otherbranch_co/testfile")) ============================================================ --- tests/explicit_merge/dont_merge 4ff7cd83142091071622b34f578632c69882c26b +++ tests/explicit_merge/dont_merge 4ff7cd83142091071622b34f578632c69882c26b @@ -0,0 +1,5 @@ +1 blah +2 change not to merge +3 blah +4 change not to merge +5 blah ============================================================ --- tests/explicit_merge/left 0ffe36a4ca2169de7543a67f92134ea93636b246 +++ tests/explicit_merge/left 0ffe36a4ca2169de7543a67f92134ea93636b246 @@ -0,0 +1,5 @@ +1 blah +2 left change +3 blah +4 blah +5 blah ============================================================ --- tests/explicit_merge/merged aed28f362beb27308db048db953a985fba45d8e7 +++ tests/explicit_merge/merged aed28f362beb27308db048db953a985fba45d8e7 @@ -0,0 +1,5 @@ +1 blah +2 left change +3 blah +4 right change +5 blah ============================================================ --- tests/explicit_merge/right 7478fc33b2476515959ea9be9306295a36a22d64 +++ tests/explicit_merge/right 7478fc33b2476515959ea9be9306295a36a22d64 @@ -0,0 +1,5 @@ +1 blah +2 blah +3 blah +4 right change +5 blah ============================================================ --- tests/explicit_merge/testfile c537e8ec248c6cd32e54cd6fa98ae15743f996b4 +++ tests/explicit_merge/testfile c537e8ec248c6cd32e54cd6fa98ae15743f996b4 @@ -0,0 +1,5 @@ +1 blah +2 blah +3 blah +4 blah +5 blah ============================================================ --- tests/merge(,_)/__driver__.lua 4478c937bffa6df632675027e4bf9f01f64c9a7d +++ tests/merge(,_)/__driver__.lua 4478c937bffa6df632675027e4bf9f01f64c9a7d @@ -0,0 +1,31 @@ + +mtn_setup() + +-- In this case, the patch should be completely ignored; we shouldn't +-- even try to do a merge. + +writefile("base", "foo blah") +writefile("left", "bar blah") +writefile("new_right", "baz blah") + +copyfile("base", "testfile") +check(cmd(mtn("add", "testfile")), 0, false, false) +commit() +base = base_revision() + +copyfile("left", "testfile") +commit() + +revert_to(base) + +remove("testfile") +check(cmd(mtn("drop", "testfile")), 0, false, false) +commit() + +copyfile("new_right", "testfile") +check(cmd(mtn("add", "testfile")), 0, false, false) +commit() + +check(cmd(mtn("merge")), 0, false, false) +check(cmd(mtn("update")), 0, false, false) +check(samefile("testfile", "new_right")) ============================================================ --- tests/persistent_netsync_server_-_keys/__driver__.lua eae1ebfb480390a12c894c2fad7425a85ccaa3df +++ tests/persistent_netsync_server_-_keys/__driver__.lua eae1ebfb480390a12c894c2fad7425a85ccaa3df @@ -0,0 +1,28 @@ + +mtn_setup() +netsync_setup() + +writefile("testfile", "I am you and you are me and we are all together.") +check(cmd(mtn2("add", "testfile")), 0, false, false) +check(cmd(mtn2("commit", "--branch=testbranch", "--message=foo")), 0, false, false) + +check(cmd(mtn2("genkey", "address@hidden")), 0, false, false, string.rep("address@hidden",2)) + +srv = netsync_serve_start("testbranch") + +netsync_client_run("push", "testbranch", 2) +netsync_client_run("pull", "testbranch", 3) + +check(cmd(mtn3("ls", "keys")), 0, true, false) +check(not qgrep("address@hidden", "stdout")) + +writefile("testfile", "stuffty stuffty") +check(cmd(mtn2("commit", "--branch=testbranch", "--message=foo", "address@hidden")), 0, false, false) + +netsync_client_run("push", "testbranch", 2) +netsync_client_run("pull", "testbranch", 3) + +srv:finish() + +check(cmd(mtn3("ls", "keys")), 0, true, false) +check(qgrep("address@hidden", "stdout")) ============================================================ --- tests/persistent_netsync_server_-_revs_&_certs/__driver__.lua a77842fd1bbe971e12a5eb922d12b188530b26cd +++ tests/persistent_netsync_server_-_revs_&_certs/__driver__.lua a77842fd1bbe971e12a5eb922d12b188530b26cd @@ -0,0 +1,66 @@ + +mtn_setup() +netsync_setup() + +revs = {} + +writefile("testfile", "foo bar") +check(cmd(mtn2("add", "testfile")), 0, false, false) +check(cmd(mtn2("commit", "--branch=testbranch", "--message=foo")), 0, false, false) +revs[1] = base_revision() + +remove_recursive("_MTN") +check(cmd(mtn3("setup", "--branch=testbranch", ".")), 0, false, false) +writefile("otherfile", "baz quux") +check(cmd(mtn3("add", "otherfile")), 0, false, false) +check(cmd(mtn3("commit", "--branch=testbranch", "--message=foo")), 0, false, false) +revs[2] = base_revision() + +srv = netsync_serve_start("testbranch") + +netsync_client_run("sync", "testbranch", 2) +netsync_client_run("sync", "testbranch", 3) + +function chksy(n, co_mtn) + check_same_stdout(cmd(mtn2("automate", "get_revision", revs[n])), + cmd(mtn3("automate", "get_revision", revs[n]))) + check_same_stdout(cmd(mtn2("ls", "certs", revs[n])), + cmd(mtn3("ls", "certs", revs[n]))) + remove_recursive("somedir") + check(cmd(co_mtn("checkout", "--revision", revs[n], "somedir")), 0, false, false) +end + +chksy(1, mtn3) + +netsync_client_run("sync", "testbranch", 2) +chksy(2, mtn2) + +-- And now make sure it works for children, where there are diffs and all + +writefile("otherfile", "foo bar, baz, also quux (on off days)") +check(cmd(mtn3("commit", "--branch=testbranch", "--message=foo")), 0, false, false) +revs[3] = base_revision() + +remove_recursive("_MTN") +check(cmd(mtn2("checkout", "--revision", revs[1], ".")), 0, false, false) +writefile("testfile", "ptang") +check(cmd(mtn2("commit", "--branch=testbranch", "--message=foo")), 0, false, false) +revs[4] = base_revision() + +-- And add a cert on an old revision +check(cmd(mtn3("comment", revs[1], 'sorry dave')), 0, false, false) + +netsync_client_run("sync", "testbranch", 3) +netsync_client_run("sync", "testbranch", 2) + +chksy(3, mtn2) + +-- And check for that extra cert +check_same_stdout(cmd(mtn2("ls", "certs", revs[1])), + cmd(mtn3("ls", "certs", revs[1]))) + +netsync_client_run("sync", "testbranch", 3) + +chksy(4, mtn3) + +srv:finish() ============================================================ --- tests/trust_hooks_and_'trusted'_command/__driver__.lua 2fb2c800231ec5cfaedb2c6d5aa261c4e23af59b +++ tests/trust_hooks_and_'trusted'_command/__driver__.lua 2fb2c800231ec5cfaedb2c6d5aa261c4e23af59b @@ -0,0 +1,31 @@ + +mtn_setup() + +function trusted(rev, name, value, ...) -- ... is signers + check(cmd(mtn("trusted", rev, name, value, unpack(arg))), 0, true, false) + local t = qgrep(" trusted", "stdout") + local u = qgrep(" untrusted", "stdout") or qgrep(" UNtrusted", "stdout") + check(t ~= u) + return t +end + +good = string.rep("1", 40) +bad = string.rep("0", 40) + +-- Idea here is to check a bunch of combinations, to make sure that +-- trust hooks get all information correctly +check(trusted(good, "foo", "bar", "address@hidden")) +check(trusted(good, "foo", "bar", "address@hidden")) +check(not trusted(good, "foo", "bar", "address@hidden")) +check(trusted(good, "bad-cert", "bad-val", "address@hidden")) +check(trusted(bad, "good-cert", "bad-val", "address@hidden")) +check(trusted(bad, "bad-cert", "good-val", "address@hidden")) +check(not trusted(bad, "bad-cert", "bad-val", "address@hidden")) +check(trusted(bad, "bad-cert", "bad-val", "address@hidden")) + +check(trusted(good, "foo", "bar", "address@hidden", "address@hidden")) +check(trusted(good, "foo", "bar", "address@hidden", "address@hidden")) +check(not trusted(good, "foo", "bar", "address@hidden", "address@hidden")) +check(not trusted(good, "foo", "bar", "address@hidden", "address@hidden")) +check(trusted(bad, "bad-cert", "bad-val", "address@hidden", "address@hidden")) +check(trusted(bad, "bad-cert", "bad-val", "address@hidden", "address@hidden")) ============================================================ --- tests/update_with_multiple_candidates/__driver__.lua 6023653c9e719109c4b94f1fad13105a8d5b522c +++ tests/update_with_multiple_candidates/__driver__.lua 6023653c9e719109c4b94f1fad13105a8d5b522c @@ -0,0 +1,48 @@ + +mtn_setup() + +-- Make sure that when there are multiple plausible heads, update +-- fails, and prints some informative message listing the heads. + +addfile("testfile", "foo") +commit() +anc = base_revision() + +addfile("file1", "bar") +commit() +left = base_revision() + +revert_to(anc) + +addfile("file1", "baz") +commit() +right = base_revision() + +revert_to(anc) + +-- There are two possible candidates, so our update should fail. +remove("file1") +check(cmd(mtn("update")), 1, false, true) +check(not exists("file1")) +-- Make sure that the failure message listed the possibilities +check(qgrep(left, "stderr")) +check(qgrep(right, "stderr")) +check(not qgrep(anc, "stderr")) + +-- Check also when one side is deeper than the other... +revert_to(left) +addfile("file2", "blah blah blah") +commit() +left2 = base_revision() + +revert_to(anc) +remove("file1") +remove("file2") +check(cmd(mtn("update")), 1, false, true) +check(not exists("file1")) +check(not exists("file2")) +-- Make sure that the failure message listed the possibilities +check(not qgrep(left, "stderr")) +check(qgrep(left2, "stderr")) +check(qgrep(right, "stderr")) +check(not qgrep(anc, "stderr")) ============================================================ --- tester.lua 69bd2108dd3803934fca93b26a40ba8f46b746e8 +++ tester.lua a0d28846349bf1c93501f5fb4bb0bb5b9d76dce0 @@ -1,9 +1,10 @@ tests = {} srcdir = get_source_dir() test_root = nil testname = nil wanted_fail = false +partial_skip = false -- set this to true if you skip part of the test errfile = "" errline = -1 @@ -404,20 +405,22 @@ err(result, 2) end post_cmd(result, ret, stdout, stderr) + return result end function check(first, ...) if type(first) == "function" then - check_func(first, unpack(arg)) + return check_func(first, unpack(arg)) elseif type(first) == "boolean" then if not first then err("Check failed: false", 2) end elseif type(first) == "number" then if first ~= 0 then err("Check failed: " .. first .. " ~= 0", 2) - end + end else err("Bad argument to check() (" .. type(first) .. ")", 2) end + return first end function skip_if(chk) @@ -493,6 +496,7 @@ bgid = 0 testname = tname wanted_fail = false + partial_skip = false local shortname = nil test_root, shortname = go_to_test_dir(testname) errfile = "" @@ -530,7 +534,11 @@ leave_test_dir() counts.noxfail = counts.noxfail + 1 else - P("ok\n") + if partial_skip then + P("partial skip\n") + else + P("ok\n") + end test_log:close() if not debugging then clean_test_dir(testname) end counts.success = counts.success + 1 ============================================================ --- testsuite.at c83ecb9d36ad6f8cca0db9c9c1662a7bb535d6c3 +++ testsuite.at eea978faa60452bacefc4df9597bbc7b0a56645f @@ -608,16 +608,6 @@ # include all the sub-tests we're going to use -m4_include(tests/t_patch_vs_drop_add.at) -m4_include(tests/t_explicit_merge.at) -m4_include(tests/t_ambig_update.at) -m4_include(tests/t_checkout_dir.at) -m4_include(tests/t_checkout_options.at) -m4_include(tests/t_trusted.at) -m4_include(tests/t_attr.at) -m4_include(tests/t_rcfile_required.at) -m4_include(tests/t_persistent_server_revision.at) -m4_include(tests/t_persistent_server_keys.at) m4_include(tests/t_fmerge_normalize.at) m4_include(tests/t_delete_dir.at) m4_include(tests/t_migrate_schema.at) ============================================================ --- testsuite.lua c7dc38733d0fc0a03252b55c4fa9583422e83eea +++ testsuite.lua 2f1522737ecaeb9d3308e3ca2a734b8d84be7de4 @@ -113,7 +113,7 @@ return out end -function netsync_client_run(oper, pat, res, n) +function netsync_client_run(oper, pat, n, res) if pat == "" or pat == nil then pat = "*" end if n == nil then n = 2 end check(cmd(mtn("--rcfile=netsync.lua", "--keydir=keys"..n, @@ -244,3 +244,13 @@ table.insert(tests, "tests/merge(<>,_)") table.insert(tests, "tests/merge(,_)") table.insert(tests, "tests/merge(<>,_)") +table.insert(tests, "tests/merge(,_)") +table.insert(tests, "tests/explicit_merge") +table.insert(tests, "tests/update_with_multiple_candidates") +table.insert(tests, "tests/checkout_validates_target_directory") +table.insert(tests, "tests/checkout_creates_right__MTN_options") +table.insert(tests, "tests/trust_hooks_and_'trusted'_command") +table.insert(tests, "tests/attr_set_attr_get") +table.insert(tests, "tests/--rcfile_requires_extant_file") +table.insert(tests, "tests/persistent_netsync_server_-_revs_&_certs") +table.insert(tests, "tests/persistent_netsync_server_-_keys")