Repository: avocado-framework/avocado

Issue:
avocado run with vm plugin hangs bc of pager
Our test suite stopped and hang forever, waiting for the user to quit `less` in a virtual machine.

On the host:

```
 └─avocado /usr/bin/avocado run --vm-domain checkmachine7-fedora-21-x86_64 --vm-username root --vm-password testvm --vm-hostname 192.168.123.5 ...
```

On the VM:

```
─sshd -D
  │   └─sshd    
  │       └─bash -l -c cd ~/avocado/tests; avocado list ...
  │           └─avocado /usr/bin/avocado list ...
  │               └─less -FRSX
```



Discussion:
That's some unexpected less behavior happening here.

@mvollmer What is the OS that your guest runs? What is the version of the less package? We never had such a problem with the versions of less in our regular development machines and VMs (they all use recent versions of Fedora). Anyway, I can patch the `list` command to not use a paginator and work around this problem.

Another possibility that just occurred to me is some sort of special terminal setting in the guest making less to paginate the list leading to this problem. A more proper solution would be to introduce a flag that disables the paginator in `avocado list`, I think I'm leaning towards it.


Resolving patch:
diff --git a/avocado/plugins/plugin_list.py b/avocado/plugins/plugin_list.py
--- a/avocado/plugins/plugin_list.py
+++ b/avocado/plugins/plugin_list.py
@@ -30,10 +30,15 @@ def configure(self, parser):
         self.parser = parser.subcommands.add_parser(
             'plugins',
             help='List all plugins loaded')
+        self.parser.add_argument('--disable-paginator',
+                                 dest='disable_paginator',
+                                 action='store_true',
+                                 help='Disable paginator usage')
         super(PluginList, self).configure(self.parser)
 
     def run(self, args):
-        view = output.View(app_args=args, use_paginator=True)
+        view = output.View(app_args=args,
+                           use_paginator=not args.disable_paginator)
         pm = get_plugin_manager()
         view.notify(event='message', msg='Plugins loaded:')
         blength = 0
diff --git a/avocado/remote/runner.py b/avocado/remote/runner.py
--- a/avocado/remote/runner.py
+++ b/avocado/remote/runner.py
@@ -69,8 +69,9 @@ def run_test(self, urls):
                                       'avocado installed')
 
         urls_str = " ".join(urls)
-        avocado_check_urls_cmd = 'cd %s; avocado list %s' % (self.remote_test_dir,
-                                                             urls_str)
+        avocado_check_urls_cmd = ('cd %s; avocado list %s '
+                                  '--disable-paginator' % (self.remote_test_dir,
+                                                           urls_str))
         check_urls_result = self.result.remote.run(avocado_check_urls_cmd,
                                                    ignore_status=True,
                                                    timeout=None)
diff --git a/selftests/all/unit/avocado/remote_unittest.py b/selftests/all/unit/avocado/remote_unittest.py
--- a/selftests/all/unit/avocado/remote_unittest.py
+++ b/selftests/all/unit/avocado/remote_unittest.py
@@ -41,7 +41,7 @@ def setUp(self):
          .with_args(args, ignore_status=True, timeout=None)
          .once().and_return(version_result))
 
-        args = 'cd ~/avocado/tests; avocado list sleeptest'
+        args = 'cd ~/avocado/tests; avocado list sleeptest --disable-paginator'
         urls_result = flexmock(exit_status=0)
         (Remote.should_receive('run')
          .with_args(args, timeout=None, ignore_status=True)


Test patch:
diff --git a/avocado/plugins/test_list.py b/avocado/plugins/test_list.py
--- a/avocado/plugins/test_list.py
+++ b/avocado/plugins/test_list.py
@@ -54,6 +54,10 @@ def configure(self, parser):
                                  help='Whether to show extra information '
                                       '(headers and summary). Current: %('
                                       'default)s')
+        self.parser.add_argument('--disable-paginator',
+                                 dest='disable_paginator',
+                                 action='store_true',
+                                 help='Disable paginator usage')
         super(TestList, self).configure(self.parser)
 
     def _run(self, args):
@@ -62,7 +66,8 @@ def _run(self, args):
 
         :param args: Command line args received from the list subparser.
         """
-        self.view = output.View(app_args=args, use_paginator=True)
+        self.view = output.View(app_args=args,
+                                use_paginator=not args.disable_paginator)
 
         paths = [data_dir.get_test_dir()]
         if args.paths: