# # # add_dir "tests/user_commands" # # add_file "tests/user_commands/__driver__.lua" # content [7b9aabef505324310c292dd5913a04e271182279] # # add_file "tests/user_commands/extra_rc" # content [be7f6758fcf16842f028910afcc940111b76b276] # ============================================================ --- tests/user_commands/__driver__.lua 7b9aabef505324310c292dd5913a04e271182279 +++ tests/user_commands/__driver__.lua 7b9aabef505324310c292dd5913a04e271182279 @@ -0,0 +1,11 @@ +mtn_setup() + +check(get("extra_rc")) + +addfile("foo", "random info\n") +commit() +rev_a = base_revision() + +check(mtn("check_head", "--rcfile=extra_rc", rev_a), 0, true, false) + +check(samelines("stdout", {"heads are equal", "end of command"})) ============================================================ --- tests/user_commands/extra_rc be7f6758fcf16842f028910afcc940111b76b276 +++ tests/user_commands/extra_rc be7f6758fcf16842f028910afcc940111b76b276 @@ -0,0 +1,19 @@ +function check_head(...) + mtn_automate("get_option", "branch") -- make sure we have a valid workspace + ok, heads = mtn_automate("heads") + if not ok then + print("automate call failed") + return + end + arghead = unpack(arg) + heads = heads:gsub("^%s*(.-)%s*$", "%1") -- trim leading and trailing whitespace + if (heads == arghead) then + print("heads are equal") + end + print("end of command") +end + + +register_command("check_head", "Check that the heads of the branch are what is passed in", + "This is a bogus command used to demonstrate user commands.", "check_head") +