[PATCH 3 of 8] ui: add debug commands to test interactive prompt

Yuya Nishihara yuya at tcha.org
Fri Mar 9 07:35:36 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1520327149 21600
#      Tue Mar 06 03:05:49 2018 -0600
# Node ID c9ac3a3b0a31abc37a76e5ae3be1b5f14a206cf3
# Parent  0fc636a6f20d51e813b9117961ad18f0eb5f83fb
ui: add debug commands to test interactive prompt

Interactive operations aren't easily covered by tests. So let's add commands
to test them manually.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2459,6 +2459,22 @@ def debugtemplate(ui, repo, tmpl, **opts
             displayer.show(repo[r], **pycompat.strkwargs(props))
         displayer.close()
 
+ at command('debuguigetpass', [
+    ('p', 'prompt', '', _('prompt text'), _('TEXT')),
+], _('[-p TEXT]'), norepo=True)
+def debuguigetpass(ui, prompt=''):
+    """show prompt to type password"""
+    r = ui.getpass(prompt)
+    ui.write(('respose: %s\n') % r)
+
+ at command('debuguiprompt', [
+    ('p', 'prompt', '', _('prompt text'), _('TEXT')),
+], _('[-p TEXT]'), norepo=True)
+def debuguiprompt(ui, prompt=''):
+    """show plain prompt"""
+    r = ui.prompt(prompt)
+    ui.write(('response: %s\n') % r)
+
 @command('debugupdatecaches', [])
 def debugupdatecaches(ui, repo, *pats, **opts):
     """warm all known caches in the repository"""
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -117,6 +117,8 @@ Show debug commands if there are no othe
   debugsub
   debugsuccessorssets
   debugtemplate
+  debuguigetpass
+  debuguiprompt
   debugupdatecaches
   debugupgraderepo
   debugwalk
@@ -299,6 +301,8 @@ Show all commands + options
   debugsub: rev
   debugsuccessorssets: closest
   debugtemplate: rev, define
+  debuguigetpass: prompt
+  debuguiprompt: prompt
   debugupdatecaches: 
   debugupgraderepo: optimize, run
   debugwalk: include, exclude
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -976,6 +976,10 @@ Test list of internal help commands
                  show set of successors for revision
    debugtemplate
                  parse and apply a template
+   debuguigetpass
+                 show prompt to type password
+   debuguiprompt
+                 show plain prompt
    debugupdatecaches
                  warm all known caches in the repository
    debugupgraderepo


More information about the Mercurial-devel mailing list