monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Issues with mtn commit and the latest net.venge.mo


From: Tero Koskinen
Subject: Re: [Monotone-devel] Issues with mtn commit and the latest net.venge.monotone head
Date: Sun, 8 Mar 2009 22:11:15 +0200

On Sat, 7 Mar 2009 09:58:15 -0800 Zack Weinberg wrote:
> Yeah, that's clearly the right fix.  Committed and pushed.  Could you
> please try to write an automated test case for this?
> 
> zw

Test below. I had to overwrite test_hooks.lua, because the default
version overwrites the edit_comment function and without it I cannot
really do the test. :)

(This means that changes to the default test_hooks.lua might need
to be copied into this test also, but hopefully that doesn't
happen often.)

The test works by overwriting execute and program_exists_in_path
functions and using "editor" as the default editor.

#
# old_revision [add275e5fdb0824361d4a2fa15049281e7ada52e]
#
# add_dir "tests/commit_default_editor"
# 
# add_file "tests/commit_default_editor/__driver__.lua"
#  content [f1336793150869e5960430f90b45999ccd79f85f]
# 
# add_file "tests/commit_default_editor/test_hooks.lua"
#  content [065038fea8a04217bf7643d9738fbd573a71119b]
#
============================================================
--- tests/commit_default_editor/__driver__.lua  
f1336793150869e5960430f90b45999ccd79f85f
+++ tests/commit_default_editor/__driver__.lua  
f1336793150869e5960430f90b45999ccd79f85f
@@ -0,0 +1,13 @@
+
+mtn_setup()
+
+unset_env("EDITOR")
+unset_env("VISUAL")
+
+check(get("test_hooks.lua"))
+
+addfile("a", "hello there")
+
+check(mtn("--branch","testbranch","commit"), 0, false, false)
+
+
============================================================
--- tests/commit_default_editor/test_hooks.lua  
065038fea8a04217bf7643d9738fbd573a71119b
+++ tests/commit_default_editor/test_hooks.lua  
065038fea8a04217bf7643d9738fbd573a71119b
@@ -0,0 +1,58 @@
+
+function my_execute(path,...) 
+   tname, rest = unpack(arg)
+   if tname == nil then
+      return 1
+   end
+   if path == "editor" then
+      if tname ~= nil then
+         tmp = io.open(tname, "w")
+         tmp:write("Hello\n")
+         io.close(tmp)
+      end
+      return 0
+   end
+   return 1
+end
+
+function get_revision_cert_trust(signers, id, name, val)
+   for k, v in pairs(signers) do
+      if v == "address@hidden" then return true end
+      if v == "address@hidden" then return false end
+   end
+   if (id == "0000000000000000000000000000000000000000"
+       and name == "bad-cert" and val == "bad-val")
+   then return false end
+   return true             
+end
+
+function get_manifest_cert_trust(signers, id, name, val)
+   return true
+end
+
+function get_file_cert_trust(signers, id, name, val)
+   return true
+end
+
+function get_passphrase(keyid)
+        return keyid
+end
+
+function persist_phrase_ok()
+        return true
+end
+
+function get_author(branchname)
+        return "address@hidden"
+end
+
+function get_mtn_command(host)
+   return os.getenv("mtn")
+end
+
+execute = my_execute
+
+function program_exists_in_path(program)
+   return (program == "editor")
+end
+


-- 
Tero Koskinen <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]