# # # add_dir "tests/commit_default_editor" # # add_file "tests/commit_default_editor/__driver__.lua" # content [8d09d83b970265688cb9825e4e0f78c1db3b52ff] # # add_file "tests/commit_default_editor/test_hooks.lua" # content [b2e3ef495040e76ef61e120e618b9cd27925d23b] # # patch "testlib.lua" # from [dd8669557a3a4bf9933897e29a615cbedc42cf38] # to [690ef91f97bdce15204c3e2a61212eaf3ef99fec] # ============================================================ --- tests/commit_default_editor/__driver__.lua 8d09d83b970265688cb9825e4e0f78c1db3b52ff +++ tests/commit_default_editor/__driver__.lua 8d09d83b970265688cb9825e4e0f78c1db3b52ff @@ -0,0 +1,12 @@ +-- This tests the standard implementation of the edit_comment lua hook, +-- which should look for an "editor" executable on the PATH and run it +-- if neither $EDITOR nor $VISUAL is set in the environment. We have +-- to override the default test hooks, which disable edit_comment. + +mtn_setup() +addfile("a", "hello there") + +check(get("test_hooks.lua")) -- this restores the default edit_comment + -- and provides a fake "editor" executable + +check(mtn("--branch", "testbranch", "commit"), 0, false, false) ============================================================ --- tests/commit_default_editor/test_hooks.lua b2e3ef495040e76ef61e120e618b9cd27925d23b +++ tests/commit_default_editor/test_hooks.lua b2e3ef495040e76ef61e120e618b9cd27925d23b @@ -0,0 +1,23 @@ + +function execute(path,...) + tname, rest = unpack(arg) + if tname == nil then + return 1 + end + if path == "editor" then + tmp = io.open(tname, "w") + tmp:write("Hello\n") + io.close(tmp) + return 0 + end + return 1 +end + +function get_passphrase(keyid) + return keyid +end + +function program_exists_in_path(program) + return (program == "editor") +end + ============================================================ --- testlib.lua dd8669557a3a4bf9933897e29a615cbedc42cf38 +++ testlib.lua 690ef91f97bdce15204c3e2a61212eaf3ef99fec @@ -872,6 +872,10 @@ function run_tests(debugging, list_only, unset_env("SSH_AUTH_SOCK") unset_env("DISPLAY") + -- tests do not use (interactive) editors for commits + unset_env("EDITOR") + unset_env("VISUAL") + logfile = io.open(logname, "w") chdir(run_dir);