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

Issue:
Empty distro file with `avocado distro`
When running  `avocado distro` to generate a definition file as indicated in the manpage, there is a problem and the resulting distro file is empty.

```
$ avocado distro --distro-def-create --distro-def-name avocadix --distro-def-version 1 --distro-def-arch x86_64 --distro-def-type rpm --distro-def-path /mnt/dvd
Loading distro information from tree... Please wait...
Avocado crashed unexpectedly: a bytes-like object is required, not 'str'
You can find details in /home/anguerre/avocado/data/crashes/avocado-traceback-2021-05-12_22:29:25-3_t5qeh8.log
```

```
$ cat /home/anguerre/avocado/data/crashes/avocado-traceback-2021-05-12_22:29:25-3_t5qeh8.log
Avocado crashed:
Traceback (most recent call last):
  File "/usr/bin/avocado", line 11, in <module>
    load_entry_point('avocado-framework==85.0', 'console_scripts', 'avocado')()
  File "/usr/lib/python3.6/site-packages/avocado/core/main.py", line 76, in main
    return app.run()
  File "/usr/lib/python3.6/site-packages/avocado/core/app.py", line 112, in run
    return method(self.parser.config)
  File "/usr/lib/python3.6/site-packages/avocado/plugins/distro.py", line 403, in run
    save_distro(distro, output_file_name)
  File "/usr/lib/python3.6/site-packages/avocado/plugins/distro.py", line 237, in save_distro
    output.write(bz2.compress(linux_distro.to_json()))
  File "/usr/lib64/python3.6/bz2.py", line 338, in compress
    return comp.compress(data) + comp.flush()
TypeError: a bytes-like object is required, not 'str'

```            
And the file  `avocadix-1-x86_64.distro` is created empty.


Discussion:

Resolving patch:
diff --git a/avocado/plugins/distro.py b/avocado/plugins/distro.py
--- a/avocado/plugins/distro.py
+++ b/avocado/plugins/distro.py
@@ -233,8 +233,9 @@ def save_distro(linux_distro, path):
     :type path: str
     :return: None
     """
-    with open(path, 'w') as output:
-        output.write(bz2.compress(linux_distro.to_json()))
+    with open(path, 'wb') as output:
+        buff = linux_distro.to_json()
+        output.write(bz2.compress(buff.encode('utf-8')))
 
 
 def load_distro(path):


Test patch:
Repository: avocado-framework/avocado

Issue:
Avocado crashed unexpectedly with the SIGINT
When the SIGINT is sent to the avocado in the early stages the avocado will crash.
This is happening on both runner legacy and nrunner. 

```
avocado run /bin/true
JOB ID     : ee66540de61211c164d9d9cb5b0e9aaf65dca8a2
JOB LOG    : /home/jarichte/avocado/job-results/job-2021-05-25T16.36-ee66540/job.log
^CAvocado crashed unexpectedly:
You can find details in /var/lib/avocado/data/crashes/avocado-traceback-2021-05-25_16:36:38-_m3ikjhl.log
```

```
avocado run --test-runner=nrunner /bin/true
JOB ID     : da09a60ab32ff647c79d919781f82db3543e107f
JOB LOG    : /home/jarichte/avocado/job-results/job-2021-05-25T15.09-da09a60/job.log
^CAvocado crashed unexpectedly:
You can find details in /var/lib/avocado/data/crashes/avocado-traceback-2021-05-25_15:09:37-my68_dsy.log
```


Discussion:

Resolving patch:
diff --git a/avocado/core/main.py b/avocado/core/main.py
--- a/avocado/core/main.py
+++ b/avocado/core/main.py
@@ -19,6 +19,7 @@
 import traceback
 
 try:
+    from avocado.core import exit_codes
     from avocado.core.settings import settings
 except ImportError:
     sys.stderr.write("Unable to import Avocado libraries, please verify "
@@ -51,13 +52,16 @@ def handle_exception(*exc_info):
     tmp, name = tempfile.mkstemp(".log", prefix, get_crash_dir())
     os.write(tmp, msg.encode('utf-8'))
     os.close(tmp)
-    # Print friendly message in console-like output
-    msg = ("Avocado crashed unexpectedly: %s\nYou can find details in %s\n"
-           % (exc_info[1], name))
+    if exc_info[0] is KeyboardInterrupt:
+        msg = "%s\nYou can find details in %s\n" % (exc_info[0].__doc__, name)
+        exit_code = exit_codes.AVOCADO_JOB_INTERRUPTED
+    else:
+        # Print friendly message in console-like output
+        msg = ("Avocado crashed unexpectedly: %s\nYou can find details in %s\n"
+               % (exc_info[1], name))
+        exit_code = exit_codes.AVOCADO_GENERIC_CRASH
     os.write(2, msg.encode('utf-8'))
-    # This exit code is replicated from avocado/core/exit_codes.py and not
-    # imported because we are dealing with import failures
-    sys.exit(-1)
+    sys.exit(exit_code)
 
 
 def main():


Test patch:
Repository: avocado-framework/avocado

Issue:
Misc updates to setup.py, check.py and weekly ci
I have grouped 3 different changes in the same PR because I think they're relatively trivial. Tell me if you find it's a bad idea :-)

At bit of context to the changes in `check.py`. While I don't expect to use the disable options often in our internal CI, they are useful locally when debugging things.


Discussion:

Resolving patch:
diff --git a/selftests/check.py b/selftests/check.py
--- a/selftests/check.py
+++ b/selftests/check.py
@@ -2,7 +2,9 @@
 
 import argparse
 import glob
+import multiprocessing
 import os
+import platform
 import sys
 
 from avocado import Test
@@ -563,6 +565,14 @@ def main():
     # ========================================================================
     config = {'core.show': ['app'],
               'run.test_runner': 'nrunner'}
+
+    # Workaround for travis problem on arm64 - https://github.com/avocado-framework/avocado/issues/4768
+    if (platform.machine() == 'aarch64'):
+        max_parallel = int(multiprocessing.cpu_count()/2)
+        for suite in suites:
+            if suite.name == 'check':
+                suite.config['nrunner.max_parallel_tasks'] = max_parallel
+
     with Job(config, suites) as j:
         exit_code = j.run()
     print_failed_tests(j.get_failed_tests())


Test patch:
Repository: avocado-framework/avocado

Issue:
Root logger is getting modified and not getting restored
Using the avocado API found that when then avocado.core.job.run() is getting call the root logger is getting modified for avocado purposes but is not getting restored at the end. The handlers are getting removed and NullHandler is returned.

Before calling job.run()
```
<RootLogger root (D)>

     <StreamHandler <stderr> (NOTSET)>

     <FileHandler /var/folders/pn/xdk10w_12dx8_bvjjrfh35hh0000gn/T/bluegen.rnzog65i.log (D)>
```

After calling job.run()
```
<RootLogger root (D)>

     <NullHandler (NOTSET)>
```

The expectation is that at the end of the job.run() execution the root logger returns to its original configuration.


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
@@ -164,6 +164,7 @@ def __init__(self, config=None, test_suites=None):
         self.time_elapsed = -1
         self.funcatexit = CallbackRegister("JobExit %s" % self.unique_id, LOG_JOB)
         self._stdout_stderr = None
+        self._old_root_level = None
         self.replay_sourcejob = self.config.get('replay_sourcejob')
         self.exitcode = exit_codes.AVOCADO_ALL_OK
 
@@ -201,6 +202,7 @@ def __start_job_logging(self):
                                               logging.FileHandler,
                                               self.logfile, self.loglevel, fmt)
         root_logger = logging.getLogger()
+        self._old_root_level = root_logger.level
         root_logger.addHandler(test_handler)
         root_logger.setLevel(self.loglevel)
         self.__logging_handlers[test_handler] = [LOG_JOB.name, ""]
@@ -252,6 +254,7 @@ def __stop_job_logging(self):
         for handler, loggers in self.__logging_handlers.items():
             for logger in loggers:
                 logging.getLogger(logger).removeHandler(handler)
+        logging.root.level = self._old_root_level
 
     def _log_avocado_config(self):
         LOG_JOB.info('Avocado config:')
diff --git a/avocado/core/output.py b/avocado/core/output.py
--- a/avocado/core/output.py
+++ b/avocado/core/output.py
@@ -643,6 +643,8 @@ def add_log_handler(logger, klass=logging.StreamHandler, stream=sys.stdout,
 
 
 def disable_log_handler(logger):
+    if not logger:
+        return
     if isinstance(logger, str):
         logger = logging.getLogger(logger)
     # Handlers might be reused elsewhere, can't delete them
diff --git a/avocado/core/runners/utils/messages.py b/avocado/core/runners/utils/messages.py
--- a/avocado/core/runners/utils/messages.py
+++ b/avocado/core/runners/utils/messages.py
@@ -201,7 +201,7 @@ def start_logging(config, queue):
     log.addHandler(log_handler)
     log.setLevel(log_level)
     log.propagate = False
-    root_logger = logging.getLogger()
+    root_logger = logging.getLogger('avocado')
     root_logger.addHandler(log_handler)
     output.LOG_UI.addHandler(RunnerLogHandler(queue, 'stdout'))
 


Test patch:
Repository: avocado-framework/avocado

Issue:
tap is not working with hintfiles on nrunner
Given the following `.avocado.hint` file:
```
[kinds]
tap = scripts/*/*.t

[tap]
uri = $testpath
```

The follow run should be enough to execute the test (instead of skip):

```
avocado run --test-runner='nrunner' scripts/domain/050-transient-lifecycle.t 
JOB ID     : 15bffd6ab0b6fe3cee9658ca92ed236000397fa2
JOB LOG    : /home/local/avocado/job-results/job-2021-07-21T15.36-15bffd6/job.log
RESULTS    : PASS 0 | ERROR 0 | FAIL 0 | SKIP 1 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/local/avocado/job-results/job-2021-07-21T15.36-15bffd6/results.html
JOB TIME   : 0.82 s
```


Discussion:

Resolving patch:
diff --git a/avocado/core/nrunner.py b/avocado/core/nrunner.py
--- a/avocado/core/nrunner.py
+++ b/avocado/core/nrunner.py
@@ -460,12 +460,18 @@ def run(self):
 
         if env and 'PATH' not in env:
             env['PATH'] = os.environ.get('PATH')
-        process = subprocess.Popen(
-            [self.runnable.uri] + list(self.runnable.args),
-            stdin=subprocess.DEVNULL,
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE,
-            env=env)
+        try:
+            process = subprocess.Popen(
+                [self.runnable.uri] + list(self.runnable.args),
+                stdin=subprocess.DEVNULL,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.PIPE,
+                env=env)
+        except Exception as e:
+            yield self.prepare_status('started')
+            yield self.prepare_status('finished', {'result': 'error',
+                                                   'fail_reason': str(e)})
+            return
 
         yield self.prepare_status('started')
         most_current_execution_state_time = None


Test patch:
Repository: avocado-framework/avocado

Issue:
TAP parser: warnings are being marked as error
.avocado.hint:

```
  1 [kinds]
  2 tap = ./scripts/*/*.t
  3 
  4 [tap]
  5 uri = $testpath
  6 kwargs = PERL5LIB=./lib,LIBVIRT_TCK_CONFIG=./conf/default.yml,LIBVIRT_TCK_AUTOCLEAN=1
```

test.t:
```bash
#!/bin/bash
echo "1..4
warning: foo
ok 1 - started persistent domain object
ok 2 - dynamic domain label type is svirt_tcg_t
ok 3 - dynamic image label type is svirt_image_t
ok 4 - Domain MCS c40,c302 == Image MCS c40,c302"
```



Discussion:
I'm not sure I understand the problem... where is `warning` supported in TAP?  I looked [here](https://testanything.org/tap-specification.html) and saw nothing about it.
@clebergnu, sorry if I wasn't clear. In fact revisiting the problem, seems to me that is a test issue, since they are writing to the stdout instead of stderror. And from the specification:

> A harness must only read TAP output from standard output and not from standard error. 

So probably we don't have a bug at the end, not sure. Since default tap parsers are ignoring this.
@clebergnu from the specs:

> A harness must only read TAP output from standard output and not from standard error. Lines written to standard output matching /^(not )?ok\b/ must be interpreted as test lines. **All other lines must not be considered test output.**

Resolving patch:
diff --git a/avocado/core/tapparser.py b/avocado/core/tapparser.py
--- a/avocado/core/tapparser.py
+++ b/avocado/core/tapparser.py
@@ -153,8 +153,6 @@ def parse(self):
             if line == '':
                 continue
 
-            yield self.Error('unexpected input at line %d' % (lineno,))
-
         if state == self._YAML:
             yield self.Error('YAML block not terminated (started on line %d)' % (yaml_lineno,))
 


Test patch:
diff --git a/selftests/unit/test_tap.py b/selftests/unit/test_tap.py
--- a/selftests/unit/test_tap.py
+++ b/selftests/unit/test_tap.py
@@ -259,7 +259,6 @@ def test_empty_line(self):
     def test_unexpected(self):
         events = self.parse_tap('1..1\ninvalid\nok 1')
         self.assert_plan(events, count=1, late=False)
-        self.assert_error(events)
         self.assert_test(events, number=1, name='', result=TestResult.PASS)
         self.assert_last(events)
Repository: avocado-framework/avocado

Issue:
Fix env variable AVOCADO_TEST_OUTPUT_DIR
Today, we have two variables: AVOCADO_TEST_OUTPUT_DIR and AVOCADO_TEST_OUTPUTDIR. We need to use the last. 


Discussion:

Resolving patch:
diff --git a/avocado/core/nrunner.py b/avocado/core/nrunner.py
--- a/avocado/core/nrunner.py
+++ b/avocado/core/nrunner.py
@@ -872,7 +872,7 @@ def are_requirements_available(self, runners_registry=None):
 
     def setup_output_dir(self):
         self.output_dir = tempfile.mkdtemp(prefix='.avocado-task-')
-        env_var = {'AVOCADO_TEST_OUTPUT_DIR': self.output_dir}
+        env_var = {'AVOCADO_TEST_OUTPUTDIR': self.output_dir}
         self.runnable.kwargs.update(env_var)
 
     @classmethod
diff --git a/avocado/plugins/jobs.py b/avocado/plugins/jobs.py
--- a/avocado/plugins/jobs.py
+++ b/avocado/plugins/jobs.py
@@ -114,7 +114,7 @@ def configure(self, parser):
                                  positional_arg=True,
                                  parser=show_parser)
         help_msg = ('Download output files generated by tests on '
-                    'AVOCADO_TEST_OUTPUT_DIR')
+                    'AVOCADO_TEST_OUTPUTDIR')
         output_files_parser = subcommands.add_parser('get-output-files',
                                                      help=help_msg)
         settings.register_option(section='jobs.get.output_files',


Test patch:
Repository: avocado-framework/avocado

Issue:
logging: use specific namespaces for each utility library
**Is your feature request related to a problem? Please describe.**

Currently all our libraries are using 'avocado.test' as a logger namespace instead of a specific namespace. Changing this is not trivial, since we need to make sure that test logs are being correctly populated. Also today some users are expecting this as a possible command to see the tests results:

```
$ avocado --show=test run foo.py 
```

**Describe the solution you'd like**

Since we can't be sure that this will always be called from a test we could use a specific namespace for each library for instance:

```python
LOG = logging.getLogger(__name__)
```

This will make debug easier since it will be converted to something like  `avocado.utils.process`. However we need to make sure test's logs are being correctly populated.


Discussion:

Resolving patch:
diff --git a/avocado/utils/debug.py b/avocado/utils/debug.py
--- a/avocado/utils/debug.py
+++ b/avocado/utils/debug.py
@@ -20,7 +20,7 @@
 import time
 
 # Use this for debug logging
-LOGGER = logging.getLogger("avocado.app.debug")
+LOGGER = logging.getLogger(__name__)
 
 # measure_duration global storage
 __MEASURE_DURATION = {}
diff --git a/avocado/utils/download.py b/avocado/utils/download.py
--- a/avocado/utils/download.py
+++ b/avocado/utils/download.py
@@ -28,7 +28,7 @@
 
 from avocado.utils import aurl, crypto, output
 
-log = logging.getLogger('avocado.utils.download')
+log = logging.getLogger(__name__)
 
 
 def url_open(url, data=None, timeout=5):
diff --git a/avocado/utils/stacktrace.py b/avocado/utils/stacktrace.py
--- a/avocado/utils/stacktrace.py
+++ b/avocado/utils/stacktrace.py
@@ -27,13 +27,14 @@ def prepare_exc_info(exc_info):
     return "".join(tb_info(exc_info))
 
 
-def log_exc_info(exc_info, logger=''):
+def log_exc_info(exc_info, logger=None):
     """
     Log exception info to logger_name.
 
     :param exc_info: Exception info produced by sys.exc_info()
     :param logger: Name or logger instance (defaults to '')
     """
+    logger = logger or __name__
     if isinstance(logger, str):
         logger = logging.getLogger(logger)
     logger.error('')
@@ -46,13 +47,14 @@ def log_exc_info(exc_info, logger=''):
     logger.error('')
 
 
-def log_message(message, logger=''):
+def log_message(message, logger=None):
     """
     Log message to logger.
 
     :param message: Message
     :param logger: Name or logger instance (defaults to '')
     """
+    logger = logger or __name__
     if isinstance(logger, str):
         logger = logging.getLogger(logger)
     for line in message.splitlines():


Test patch:
Repository: avocado-framework/avocado

Issue:
Handle "could not import module" errors gracefully
**Describe the bug**
Avocado does not handle "could not import module" errors very gracefully, with error messages that are quite cryptic.

**Steps to reproduce**
Write a valid `avocado-instrumented` test, but with an invalid import.  Example:

```python
from avocado import Test

import foo


class PassTest(Test):

    """
    Example test that passes.

    :avocado: tags=fast
    """

    def test(self):
        """
        A test simply doesn't have to fail in order to pass
        """
```

And run it:

```
$ avocado run examples/tests/passtest.py 
JOB ID     : 3fee9803715e414a16c3dcf1ddb9ff2f6dc6c0bd
JOB LOG    : /home/cleber/avocado/job-results/job-2022-08-11T10.24-3fee980/job.log
 (1/1) examples/tests/passtest.py:PassTest.test: STARTED
 (1/1) examples/tests/passtest.py:PassTest.test:  ERROR: Test.__init__() got an unexpected keyword argument 'run.results_dir' (0.01 s)
RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/cleber/avocado/job-results/job-2022-08-11T10.24-3fee980/results.html
JOB TIME   : 1.47 s
```

**Expected behavior**
Instead of "unexpected argument..." a more clear error message such as: "failed to import the file containing the test" or something similar. 

**Current behavior**

From original reporter @jnsnow:

```
(08/27) tests/protocol.py:Connect.testBadUNIX:  ERROR:
        Test.__init__() got an unexpected keyword argument 'run.results_dir'
        (0.01 s)
```

**System information (please complete the following information):**
 - OS: ```LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	Fedora
Description:	Fedora release 36 (Thirty Six)
Release:	36
Codename:	ThirtySix```
 - Avocado version: 5a0c5b2348da450397287a0954e4c335c0d590a9
 - Avocado installation method: git



Discussion:

Resolving patch:
diff --git a/avocado/core/utils/loader.py b/avocado/core/utils/loader.py
--- a/avocado/core/utils/loader.py
+++ b/avocado/core/utils/loader.py
@@ -30,6 +30,8 @@ def load_test(test_factory):
     :return: an instance of :class:`avocado.core.test.Test`.
     """
     test_class, test_parameters = test_factory
+    if "run.results_dir" in test_parameters:
+        test_parameters["base_logdir"] = test_parameters.pop("run.results_dir")
     if "modulePath" in test_parameters:
         test_path = test_parameters.pop("modulePath")
     else:
@@ -60,8 +62,6 @@ def load_test(test_factory):
                 if issubclass(obj, test.Test):
                     test_class = obj
                     break
-    if "run.results_dir" in test_parameters:
-        test_parameters["base_logdir"] = test_parameters.pop("run.results_dir")
     test_instance = test_class(**test_parameters)
 
     return test_instance


Test patch:
Repository: tensorflow/tensor2tensor

Issue:
wmt_encs_tokens_32k  - Datagen error
I am trying to start the d
"datagen" for the "wmt_encs_tokens_32k" and I receive the following error:

```
INFO:tensorflow:Generating problems:
  * wmt_encs_tokens_32k

INFO:tensorflow:Generating training data for wmt_encs_tokens_32k.
Traceback (most recent call last):
  File "/home/ahmed/tensorflow/bin/t2t-datagen", line 290, in <module>
    tf.app.run()
  File "/home/ahmed/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/home/ahmed/tensorflow/bin/t2t-datagen", line 239, in main
    generate_data_for_registered_problem(problem)
  File "/home/ahmed/tensorflow/bin/t2t-datagen", line 286, in generate_data_for_registered_problem
    task_id=task_id)
  File "/home/ahmed/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/problem.py", line 383, in generate_data
    self.train_generator(data_dir, tmp_dir, True),
  File "/home/ahmed/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/wmt.py", line 589, in train_generator
    data_dir, tmp_dir, self.vocab_file, self.targeted_vocab_size,
  File "/home/ahmed/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/problem.py", line 371, in vocab_file
    return "%s.%d" % (self.vocab_name, self.targeted_vocab_size)
  File "/home/ahmed/tensorflow/local/lib/python2.7/site-packages/tensor2tensor/data_generators/problem.py", line 343, in targeted_vocab_size
    raise NotImplementedError()  # Not needed if self.is_character_level.
NotImplementedError
```



Discussion:

Resolving patch:
diff --git a/tensor2tensor/data_generators/wmt.py b/tensor2tensor/data_generators/wmt.py
--- a/tensor2tensor/data_generators/wmt.py
+++ b/tensor2tensor/data_generators/wmt.py
@@ -574,7 +574,7 @@ class WMTEnCsTokens32k(WMTProblem):
   """Problem spec for WMT English-Czech translation."""
 
   @property
-  def target_vocab_size(self):
+  def targeted_vocab_size(self):
     return 2**15  # 32768
 
   @property


Test patch: