internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: avocado-framework/avocado

Issue:
Proper simple tests examples
Even though simple tests are, well, simple, let's have a couple of them in the examples directory.

A big reason for that is that we currently use wrappers as the simple tests examples in the Getting Started guide (`avocado list examples/wrappers`) which can be confusing to new users.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -75,6 +75,11 @@ def get_data_files():
     data_files += [(get_dir(['usr', 'share', 'avocado', 'wrappers'],
                             ['wrappers']),
                     glob.glob('examples/wrappers/*.sh'))]
+
+    data_files += [(get_dir(['usr', 'share', 'avocado', 'simpletests'],
+                            ['simpletests']),
+                    glob.glob('examples/simpletests/*.sh'))]
+
     data_files.append((get_avocado_libexec_dir(), glob.glob('libexec/*')))
     return data_files
 


Test patch:
Repository: avocado-framework/avocado

Issue:
why this is "<" not ">" ?
https://github.com/avocado-framework/avocado/blob/d1503a1dcfe684a1b6ab03fd79546eb0f2bfb511/optional_plugins/runner_remote/avocado_runner_remote/__init__.py#L107


Discussion:
if "<", only loop one times.
Yep, a bug. Are sending the fix?
OK，thx，I‘ll send bug fix lately。

Resolving patch:
diff --git a/optional_plugins/runner_remote/avocado_runner_remote/__init__.py b/optional_plugins/runner_remote/avocado_runner_remote/__init__.py
--- a/optional_plugins/runner_remote/avocado_runner_remote/__init__.py
+++ b/optional_plugins/runner_remote/avocado_runner_remote/__init__.py
@@ -104,7 +104,7 @@ def run(command, ignore_status=False, quiet=True, timeout=60):
         except fabric.network.NetworkError as details:
             fabric_exception = details
             timeout = end_time - time.time()
-        if time.time() < end_time:
+        if time.time() > end_time:
             break
     if fabric_result is None:
         if fabric_exception is not None:


Test patch:
Repository: avocado-framework/avocado

Issue:
jobs get-output-files should split downloaded files into subdirectories
> ```
> ll /home/cleber/avocado/job-results/job-2020-06-04T15.17-9bd5b5e
> total 708
> -rw-rw-r--. 1 cleber cleber     41 Jun  4 15:17 id
> drwxrwxr-x. 2 cleber cleber   4096 Jun  4 15:17 jobdata
> -rw-rw-r--. 1 cleber cleber  15818 Jun  4 15:17 job.log
> -rw-rw-r--. 1 cleber cleber 668480 Jun  4 15:17 results.html
> -rw-rw-r--. 1 cleber cleber   1029 Jun  4 15:17 results.json
> -rw-rw-r--. 1 cleber cleber     36 Jun  4 15:17 results.tap
> -rw-rw-r--. 1 cleber cleber    345 Jun  4 15:17 results.xml
> drwxrwxr-x. 5 cleber cleber   4096 Jun  4 15:17 sysinfo
> -rw-rw-r--. 1 cleber cleber     16 Jun  4 15:18 test2_created
> -rw-rw-r--. 1 cleber cleber     16 Jun  4 15:18 test_created
> drwxrwxr-x. 4 cleber cleber   4096 Jun  4 15:17 test-results
> ```
> 
> I had the expectation that, `test_created` would to to `test-results/1-_tmp_t.sh/` and `test2_created` would go to `test-results/2-_tmp_t2.sh/`. Is this expected now? Yes, no, in the future?


Discussion:

Resolving patch:
diff --git a/avocado/plugins/jobs.py b/avocado/plugins/jobs.py
--- a/avocado/plugins/jobs.py
+++ b/avocado/plugins/jobs.py
@@ -77,9 +77,7 @@ def _save_stream_to_file(self, stream, filename):
         Directory must exists before calling this function.
         """
         dirname = os.path.dirname(filename)
-        if not os.path.isdir(dirname):
-            LOG_UI.error("%s does not exist. Exiting...", dirname)
-            return exit_codes.AVOCADO_GENERIC_CRASH
+        os.makedirs(dirname, exist_ok=True)
 
         with open(filename, 'ab') as output_file:
             output_file.write(stream)
@@ -161,7 +159,9 @@ def _download_tests(self, tests, destination, job_id, spawner):
             try:
                 files_buffers = spawner().stream_output(job_id, test_id)
                 for filename, stream in files_buffers:
-                    dest = os.path.join(destination, filename)
+                    dest = os.path.join(destination,
+                                        test_id.replace('/', '_'),
+                                        filename)
                     self._save_stream_to_file(stream, dest)
             except SpawnerException as ex:
                 LOG_UI.error("Error: Failed to download: %s. Exiting...", ex)


Test patch:
Repository: avocado-framework/avocado

Issue:
Settings: avocado config shows keys out of order
It's helpful to have the keys sorted when doing `avocado config`, and they're currently not.


Discussion:

Resolving patch:
diff --git a/avocado/core/settings.py b/avocado/core/settings.py
--- a/avocado/core/settings.py
+++ b/avocado/core/settings.py
@@ -47,6 +47,10 @@
 from .settings_dispatcher import SettingsDispatcher
 
 
+def sorted_dict(dict_object):
+    return sorted(dict_object.items(), key=lambda t: t[0])
+
+
 class SettingsError(Exception):
     """
     Base settings error.
@@ -399,13 +403,13 @@ def as_dict(self):
         or via command-line).
         """
         result = {}
-        for namespace, option in self._namespaces.items():
+        for namespace, option in sorted_dict(self._namespaces):
             result[namespace] = option.value
         return result
 
     def as_full_dict(self):
         result = {}
-        for namespace, option in self._namespaces.items():
+        for namespace, option in sorted_dict(self._namespaces):
             result[namespace] = {'help': option.help_msg,
                                  'type': option.key_type,
                                  'default': option.default,
diff --git a/avocado/plugins/config.py b/avocado/plugins/config.py
--- a/avocado/plugins/config.py
+++ b/avocado/plugins/config.py
@@ -52,7 +52,7 @@ def run(self, config):
         if config.get('config_subcommand') == 'reference':
             self.handle_reference(LOG_UI.debug)
         else:
-            self.handle_default(config)
+            self.handle_default()
 
     @staticmethod
     def handle_reference(print_function):
@@ -68,10 +68,12 @@ def handle_reference(print_function):
             print_function("* Type: %s" % option.get('type'))
             print_function("")
 
-    def handle_default(self, config):
+    def handle_default(self):
         LOG_UI.info("Config files read (in order, '*' means the file exists "
                     "and had been read):")
 
+        # Getting from settings because is already sorted
+        config = settings.as_dict()
         for cfg_path in settings.all_config_paths:
             if cfg_path in settings.config_paths:
                 LOG_UI.debug('    * %s', cfg_path)


Test patch:
Repository: avocado-framework/avocado

Issue:
Job: warn when running jobs without test suites 
Currently, when creating a Job through the API, without test suites, the Job will not warn the user about it.

We should either present a warning, or the `RESULT` line with all `0`s, or both.


Discussion:

Resolving patch:
diff --git a/avocado/core/job.py b/avocado/core/job.py
--- a/avocado/core/job.py
+++ b/avocado/core/job.py
@@ -591,6 +591,11 @@ def run_tests(self):
         self._log_job_debug_info()
         jobdata.record(self, sys.argv)
 
+        if self.size == 0:
+            msg = ("Unable to resolve any reference or 'run.references' is "
+                   "empty.")
+            LOG_UI.error(msg)
+
         if not self.test_suites:
             self.exitcode |= exit_codes.AVOCADO_JOB_FAIL
             return self.exitcode


Test patch:
Repository: avocado-framework/avocado

Issue:
avocado list --resolver doesn't work with hint files
Sample setup with QEMU's source code, plus `avocado.hint`:

``` 
[kinds]
tap = ./tests/test-*

[tap]
uri = $testpath
args = 
kwargs =
```

Then, running:

```
$ avocado list --resolver ./tests/test-iov 
exec-test ./tests/test-iov
```

Where `tap` would be expected.



Discussion:
I know why.... :/ I will work on this.

Resolving patch:
diff --git a/avocado/core/suite.py b/avocado/core/suite.py
--- a/avocado/core/suite.py
+++ b/avocado/core/suite.py
@@ -1,3 +1,18 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# See LICENSE for more details.
+#
+# Copyright: Red Hat Inc. 2020
+# Author: Beraldo Leal <bleal@redhat.com>
+
+import os
 from enum import Enum
 from uuid import uuid4
 
@@ -6,6 +21,7 @@
                          OptionValidationError)
 from .loader import (DiscoverMode, LoaderError, LoaderUnhandledReferenceError,
                      loader)
+from .parser import HintParser
 from .resolver import resolve
 from .settings import settings
 from .tags import filter_test_tags
@@ -101,7 +117,13 @@ def _from_config_with_resolver(cls, config, name=None):
         ignore_missing = config.get('run.ignore_missing_references')
         references = config.get('run.references')
         try:
-            resolutions = resolve(references, ignore_missing=ignore_missing)
+            hint = None
+            hint_filepath = '.avocado.hint'
+            if os.path.exists(hint_filepath):
+                hint = HintParser(hint_filepath)
+            resolutions = resolve(references,
+                                  hint=hint,
+                                  ignore_missing=ignore_missing)
         except JobTestSuiteReferenceResolutionError as details:
             raise TestSuiteError(details)
         tasks = resolutions_to_tasks(resolutions, config)


Test patch:
Repository: avocado-framework/avocado

Issue:
docs: Review and test examples on user's guide (section: Introduction)



Discussion:
Part of #4124 
@clebergnu since #3700 is still open, I will wait for all the work that you are doing on the "run" command to continue here. Makes sense?

Resolving patch:
diff --git a/avocado/core/parser.py b/avocado/core/parser.py
--- a/avocado/core/parser.py
+++ b/avocado/core/parser.py
@@ -59,9 +59,9 @@ def __call__(self, parser, namespace, values, option_string=None):
         if values == '-':
             stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)
             if stdout_claimed_by is not None:
-                msg = ('Options %s %s are trying to use stdout '
-                       'simultaneously' % (stdout_claimed_by,
-                                           option_string))
+                msg = ('Options %s %s are trying to use stdout simultaneously.'
+                       ' Please set at least one of them to a file to avoid '
+                       'conflicts' % (stdout_claimed_by, option_string))
                 raise argparse.ArgumentError(self, msg)
             else:
                 setattr(namespace, 'stdout_claimed_by', option_string)


Test patch:
diff --git a/selftests/functional/test_output.py b/selftests/functional/test_output.py
--- a/selftests/functional/test_output.py
+++ b/selftests/functional/test_output.py
@@ -353,10 +353,9 @@ def test_output_incompatible_setup(self):
         self.assertEqual(result.exit_status, expected_rc,
                          "Avocado did not return rc %d:\n%s" %
                          (expected_rc, result))
-        error_regex = re.compile(r'avocado run: error: argument ((--json)|'
-                                 '(--xunit)): Options ((--xunit --json)|'
+        error_regex = re.compile(r'.*Options ((--xunit --json)|'
                                  '(--json --xunit)) are trying to use stdout '
-                                 'simultaneously\n')
+                                 'simultaneously.')
         self.assertIsNotNone(error_regex.match(result.stderr_text),
                              "Missing error message from output:\n%s" %
                              result.stderr)
Repository: avocado-framework/avocado

Issue:
plugin fetchasset error: Attribute object has no attribute id
```
avocado run examples/tests/multiple_tests.py 
Error running method "pre_tests" of plugin "fetchasset": 'Attribute' object has no attribute 'id'
JOB ID     : f8e40b2a453da3f9115aa222f2cea668d62836d1
JOB LOG    : /home/local/avocado/job-results/job-2020-09-02T13.25-f8e40b2/job.log
 (1/2) examples/tests/multiple_tests.py:MultipleTests.test_hello: PASS (0.00 s)
 (2/2) examples/tests/multiple_tests.py:MultipleTests.testIdentity: PASS (0.00 s)
RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/local/avocado/job-results/job-2020-09-02T13.25-f8e40b2/results.html
JOB TIME   : 0.30 s
```


Discussion:

Resolving patch:
diff --git a/avocado/plugins/assets.py b/avocado/plugins/assets.py
--- a/avocado/plugins/assets.py
+++ b/avocado/plugins/assets.py
@@ -168,7 +168,12 @@ def visit_Assign(self, node):  # pylint: disable=C0103
                 # variables to make dictionary assignment line shorter
                 cur_klass = self.current_klass
                 cur_method = self.current_method
-                name = node.targets[0].id
+                # if it is a class attribute, save the attribute name
+                # otherwise, save the local variable name
+                if isinstance(node.targets[0], ast.Attribute):
+                    name = node.targets[0].attr
+                else:
+                    name = node.targets[0].id
                 self.asgmts[cur_klass][cur_method][name] = node.value.s
         self.generic_visit(node)
 


Test patch:
Repository: avocado-framework/avocado

Issue:
distutils depreaction
https://www.python.org/dev/peps/pep-0632/

We have one module using this: `avocado.utils.kernel`.


Discussion:
Hi @beraldoleal, 

To address this issue, one has to replace `distutils` functionalities with any other viable alternatives like `sys`, `os` etc. right?
Hi @t0xic0der, Actually we need to replace `distutils`' calls by `setuptools`' calls.
Makes sense. Small PRs for this too?
This one will be small.
Hi @beraldoleal, you can assign this to me. One of the issues I am working on (#3565) is halfway done as of now. 
Please look into #4248.

Resolving patch:
diff --git a/avocado/utils/kernel.py b/avocado/utils/kernel.py
--- a/avocado/utils/kernel.py
+++ b/avocado/utils/kernel.py
@@ -22,7 +22,8 @@
 import os
 import shutil
 import tempfile
-from distutils.version import LooseVersion  # pylint: disable=E0611
+
+from pkg_resources import packaging
 
 from . import archive, asset, build, distro, process
 
@@ -207,4 +208,6 @@ def check_version(version):
     :type version: string
     :param version: version to be compared with current kernel version
     """
-    assert LooseVersion(os.uname()[2]) > LooseVersion(version), "Old kernel"
+    os_version = packaging.version.parse(os.uname()[2])
+    version = packaging.version.parse(version)
+    assert os_version > version, "Old kernel"
\ No newline at end of file


Test patch:
Repository: avocado-framework/avocado

Issue:
BP001: Make the option-arguments not optional
Related #3427 


Discussion:

Resolving patch:
diff --git a/avocado/core/loader.py b/avocado/core/loader.py
--- a/avocado/core/loader.py
+++ b/avocado/core/loader.py
@@ -407,7 +407,7 @@ def add_loader_options(parser, section='run'):
                 "settings->plugins.loaders.")
     settings.register_option(section=section,
                              key='loaders',
-                             nargs='*',
+                             nargs='+',
                              key_type=list,
                              default=['file', '@DEFAULT'],
                              help_msg=help_msg,
diff --git a/avocado/plugins/run.py b/avocado/plugins/run.py
--- a/avocado/plugins/run.py
+++ b/avocado/plugins/run.py
@@ -213,7 +213,7 @@ def configure(self, parser):
                     '"$JOB_RESULTS_DIR/$STREAM.$LEVEL."')
         settings.register_option(section='run',
                                  key='store_logging_stream',
-                                 nargs='*',
+                                 nargs='+',
                                  help_msg=help_msg,
                                  default=[],
                                  metavar='STREAM[:LEVEL]',
diff --git a/optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py b/optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
--- a/optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
+++ b/optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
@@ -424,35 +424,35 @@ def configure(self, parser):
                 long_arg='--mux-yaml',
                 short_arg='-m',
                 metavar='FILE',
-                nargs='*',
+                nargs='+',
                 allow_multiple=True)
 
             settings.add_argparser_to_option(
                 namespace="%s.%s" % (self.name, 'filter_only'),
                 parser=agroup,
                 long_arg='--mux-filter-only',
-                nargs='*',
+                nargs='+',
                 allow_multiple=True)
 
             settings.add_argparser_to_option(
                 namespace="%s.%s" % (self.name, 'filter_out'),
                 parser=agroup,
                 long_arg='--mux-filter-out',
-                nargs='*',
+                nargs='+',
                 allow_multiple=True)
 
             settings.add_argparser_to_option(
                 namespace="%s.%s" % (self.name, 'parameter_paths'),
                 parser=agroup,
                 long_arg='--mux-path',
-                nargs='*',
+                nargs='+',
                 allow_multiple=True)
 
             settings.add_argparser_to_option(
                 namespace="%s.%s" % (self.name, 'inject'),
                 parser=agroup,
                 long_arg='--mux-inject',
-                nargs='*',
+                nargs='+',
                 allow_multiple=True)
 
     def run(self, config):


Test patch:
Repository: avocado-framework/avocado

Issue:
Better output message on cloudint when missing pycdlib
pycdlib is necessary when running `utils/cloudinit.py`


Discussion:

Resolving patch:
diff --git a/avocado/utils/cloudinit.py b/avocado/utils/cloudinit.py
--- a/avocado/utils/cloudinit.py
+++ b/avocado/utils/cloudinit.py
@@ -18,6 +18,9 @@
 This module can be easily used with :mod:`avocado.utils.vmimage`,
 to configure operating system images via the cloudinit tooling.
 
+Please, keep in mind that if you would like to create/write in ISO images, you
+need pycdlib module installed in your environment.
+
 :see: http://cloudinit.readthedocs.io.
 """
 
@@ -104,9 +107,12 @@ def iso(output_path, instance_id, username=None, password=None,
              a case, user is expected to install supporting packages, such as
              pycdlib.
     """
+    # The only supported method to create/write in an ISO today is via pycdlib
     out = iso9660.iso9660(output_path, ["create", "write"])
     if out is None:
-        raise RuntimeError("The system lacks support for creating ISO images")
+        msg = ("The system lacks support for creating ISO images. ",
+               "Please install pycdlib dependency and run again.")
+        raise RuntimeError(msg)
     out.create(flags={"interchange_level": 3, "joliet": 3, "vol_ident": 'cidata'})
     metadata = METADATA_TEMPLATE.format(instance_id,
                                         instance_id).encode(astring.ENCODING)


Test patch:
Repository: avocado-framework/avocado

Issue:
Avocado crash without output
When I run nrunner with the wrong test path avocado crashes without any information. It can be reproduced by:

`avocado run --test-runner=nrunner --ignore-missing-references -- test_utils_partition.py`


Discussion:
@richtja because you are using `--ignore-missing-references`? What is the expected result?
Yes, I think that is happening because of usage of `--ignore-missing-references`. I think that this should be ok to do. But I am getting exit code `2` which means  `AVOCADO_JOB_FAIL`. Sorry that I didn't explain it properly at the beginning. 
Yes, so we should change the return code, but I guess that it is ok to assume no output here.

Resolving patch:
diff --git a/avocado/plugins/run.py b/avocado/plugins/run.py
--- a/avocado/plugins/run.py
+++ b/avocado/plugins/run.py
@@ -296,7 +296,11 @@ def run(self, config):
         try:
             suite = TestSuite.from_config(config, name='')
             if suite.size == 0:
-                sys.exit(exit_codes.AVOCADO_JOB_FAIL)
+                msg = ("Suite is empty. There is no tests to run. This usually "
+                       "happens when you pass --ignore-missing-references and "
+                       "there is no more references to process.")
+                LOG_UI.warning(msg)
+                sys.exit(exit_codes.AVOCADO_FAIL)
         except TestSuiteError as err:
             LOG_UI.error(err)
             sys.exit(exit_codes.AVOCADO_JOB_FAIL)


Test patch:
diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py
--- a/selftests/functional/test_basic.py
+++ b/selftests/functional/test_basic.py
@@ -229,8 +229,8 @@ def test_runner_ignore_missing_references_all_missing(self):
         result = process.run(cmd_line, ignore_status=True)
         self.assertIn(b"Unable to resolve reference(s) 'badtest.py', 'badtest2.py'",
                       result.stderr)
-        self.assertEqual(b'', result.stdout)
-        expected_rc = exit_codes.AVOCADO_JOB_FAIL
+        self.assertIn(b'Suite is empty. There is no tests to run.', result.stderr)
+        expected_rc = exit_codes.AVOCADO_FAIL
         self.assertEqual(result.exit_status, expected_rc,
                          "Avocado did not return rc %d:\n%s" % (expected_rc, result))
Repository: avocado-framework/avocado

Issue:
TestSuite() initialization config param missing error
In the definition of the TestSuite Class the parameter "config" has a default value as None and when the default value is used it fails, forcing us to use a dummy input to get it working.

Error example:
```
'NoneType' object has no attribute 'get'
<class 'AttributeError'>
'NoneType' object has no attribute 'get'
File "/Library/Python/3.7/site-packages/bluegen/common/main.py", line 65, in main
ret = command.get(opts.cmd)(opts)
File "/Library/Python/3.7/site-packages/bluegen/common/command.py", line 142, in
__call__     return self.func(opts, *args, **kwargs)
File "/Library/Python/3.7/site-packages/bluegen/commands/test.py", line 34, in test
test_suites = avocado.suites_generator(opts.sequence_file, opts.tests_ref, opts.parallel,
opts.cfg_dir)
File "/Library/Python/3.7/site-packages/bluegen/utils/avocado.py", line 125, in
suites_generator     job_config=JOB_CONFIG)
File "/Users/marioalvarado/Library/Python/3.7/lib/python/site-
packages/avocado/core/suite.py", line 106, in __init__     if
(config.get('run.dry_run.enabled') and
```

Code example:
```
test_suite = TestSuite(name="BlueGen Sequential Execution",
                                           tests=runnables_with_param,
                                           job_config=JOB_CONFIG)
```


Discussion:

Resolving patch:
diff --git a/avocado/core/suite.py b/avocado/core/suite.py
--- a/avocado/core/suite.py
+++ b/avocado/core/suite.py
@@ -103,7 +103,7 @@ def __init__(self, name, config=None, tests=None, job_config=None,
         self._runner = None
         self._test_parameters = None
 
-        if (config.get('run.dry_run.enabled') and
+        if (self.config.get('run.dry_run.enabled') and
                 self.config.get('run.test_runner') == 'runner'):
             self._convert_to_dry_run()
 


Test patch: