changeset 36792:15c050b5d599

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.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 06 Mar 2018 03:05:49 -0600
parents 30742c216abb
children eca1051e6c22
files mercurial/debugcommands.py tests/test-completion.t tests/test-help.t
diffstat 3 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Tue Mar 06 02:14:11 2018 -0600
+++ b/mercurial/debugcommands.py	Tue Mar 06 03:05:49 2018 -0600
@@ -2459,6 +2459,22 @@
             displayer.show(repo[r], **pycompat.strkwargs(props))
         displayer.close()
 
+@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)
+
+@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"""
--- a/tests/test-completion.t	Tue Mar 06 02:14:11 2018 -0600
+++ b/tests/test-completion.t	Tue Mar 06 03:05:49 2018 -0600
@@ -117,6 +117,8 @@
   debugsub
   debugsuccessorssets
   debugtemplate
+  debuguigetpass
+  debuguiprompt
   debugupdatecaches
   debugupgraderepo
   debugwalk
@@ -299,6 +301,8 @@
   debugsub: rev
   debugsuccessorssets: closest
   debugtemplate: rev, define
+  debuguigetpass: prompt
+  debuguiprompt: prompt
   debugupdatecaches: 
   debugupgraderepo: optimize, run
   debugwalk: include, exclude
--- a/tests/test-help.t	Tue Mar 06 02:14:11 2018 -0600
+++ b/tests/test-help.t	Tue Mar 06 03:05:49 2018 -0600
@@ -976,6 +976,10 @@
                  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