1. 26 2月, 2018 1 次提交
    • C
      avocado/utils/process.py: make CmdResult.std{out,err}_text smarter · 72bdab0f
      Cleber Rosa 提交于
      In situations where a user of the CmdResult class manually sets the
      stdout/stderr attributes to a string, instead of the recommended and
      documented content of type "bytes", it won't be possible to "decode"
      the bytes into a string of a given encoding, and we'll end up with
      a crash.
      
      Since the goal of std{out,err}_text is to return a text version
      of stdout, if itself already is of such a type, let's just return
      it.
      
      Additionally, if the data cannot be "decode()d", let's raise an
      explicit TypeError on this location, rather than later in the code
      when its value is attempted to be used.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      72bdab0f
  2. 23 2月, 2018 9 次提交
    • A
      Support variants dump/load · cf6aab6a
      Amador Pahim 提交于
      Depending on the number of parameters, generating the Variants can be
      compute intensive. This patch adds the ability to dump/load the variants
      to/from a JSON file so the Variants generation can be offloaded from the
      machine under test.
      
      Reference: https://trello.com/c/llZJKBdiSigned-off-by: NAmador Pahim <apahim@redhat.com>
      cf6aab6a
    • C
      selftests/unit/test_runner_queue.py: use absolute path for module · 1e4fdaa8
      Cleber Rosa 提交于
      Looks like the Python 3 module import code behaves differently than
      Python 2 with regards to where it looks modules by name:
      
         File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 932, in _run_avocado
            raise test_exception
         File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 819, in _run_avocado
            testMethod()
         File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 1371, in test
            self.error(self.exception)
         File "/home/cleber/src/avocado/avocado/avocado/core/test.py", line 1041, in error
            raise exceptions.TestError(message)\navocado.core.exceptions.TestError: Traceback (most recent call last):
         File "/usr/lib64/python3.6/imp.py", line 297, in find_module
            raise ImportError(_ERR_MSG.format(name), name=name)
         ImportError: No module named \'whiteboard\'\n\n'
      
      Effectively, this means when running this test, on Python 3, on the
      parallel mode, the change of directory implemented there
      (on selftests/checkall) will make Python 3 fail to find this module,
      and the test will fail.
      
      This makes the reference to the module path absolute, so no matter
      where this test is run from, it should be able to find the module.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      1e4fdaa8
    • C
      Python 3: do not allow failures on CI, but only run unittests and doc · 494405ae
      Cleber Rosa 提交于
      This removes the exception of allowing failures on the Travis CI jobs
      with Python 3, while, at the same time, temporary restricts Python 3
      jobs to run only unittests and the documentation build for the Avocado
      core.  That is, it excludes the functional tests, and the optional
      plugin's tests.
      
      While it may look like a step back, it's actually a step forward in the
      Python 3 port, because now any regression on the unittests will be caught.
      And, when the additional fixes are applied to address the functional tests
      and plugin's tests, the whole set of tests will be enabled for Python 3.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      494405ae
    • C
      selftests/functional/test_basic.py: also check for HTML entity references · f5b0ac93
      Cleber Rosa 提交于
      The pystache library on Python 3 will generated an HTML file with entity
      references for the single quote char, instead of the literal char.
      
      Let's check for either one of them in the functional test
      test_basic.RunnerSimpleTest.test_fs_unfriendly_run().
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      f5b0ac93
    • C
      selftests/functional/test_output.py: use bytes in comparison · 1cc77039
      Cleber Rosa 提交于
      The content on the file is being read as bytes, so let's use byte
      literals in the comparison.
      
      The error message received some adjustments, mainly because it could
      produce weird stuff text such as "1th" or "2th".  To be honest, I'd
      remove this error message completely, the assertion error is pretty
      easy to spot IMO.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      1cc77039
    • C
      selftests/functional/test_loader.py: use text in comparisons · b038ca38
      Cleber Rosa 提交于
      This fixes the functional test
      test_loader.LoaderTestFunctional.test_yaml_loader_run.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      b038ca38
    • C
      selftests/functional/test_output.py: use command output as text · 67804026
      Cleber Rosa 提交于
      Instead of as bytes in assertions, specially because of a part of it
      is going to be used as a path.  This fixes the following issue:
      
          ======================================================================
          ERROR: test_default_enabled_plugins (test_output.OutputPluginTest)
          ----------------------------------------------------------------------
          Traceback (most recent call last):
            File "/home/cleber/src/avocado/avocado/selftests/functional/test_output.py", line 509, in test_default_enabled_plugins
              self.check_output_files(debug_log)
            File "/home/cleber/src/avocado/avocado/selftests/functional/test_output.py", line 286, in check_output_files
              json_output_path = os.path.join(base_dir, 'results.json')
            File "/usr/lib64/python3.6/posixpath.py", line 92, in join
              genericpath._check_arg_types('join', a, *p)
            File "/usr/lib64/python3.6/genericpath.py", line 151, in _check_arg_types
              raise TypeError("Can't mix strings and bytes in path components") from None
          TypeError: Can't mix strings and bytes in path components
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      67804026
    • C
      selftests/functional/test_job_timeout.py: use bytes in comparison · 840389cb
      Cleber Rosa 提交于
      This fixes the functional test "test_invalid_values" (from
      test_job_timeout.JobTimeOutTest).
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      840389cb
    • C
      13127695
  3. 22 2月, 2018 5 次提交
  4. 16 2月, 2018 2 次提交
    • C
      avocado.utils.iso9660: always deal with bytes · 01c84866
      Cleber Rosa 提交于
      The avocado.utils.process module has been changed so that the content
      of stdout and stderr are now bytes.  The content generated by the
      iso9660 backend implementations should also operate on bytes, given
      that it makes little sense for the library to assume a given content
      type of a file (inside an iso9660 archive).
      
      To make the data returned by the various backend `read()`
      implementations always return bytes on both Python 2 and 3, an
      explicit conversion is done from strings to bytes (which affects only
      Python 2, since Python 3 already operates with bytes on files opened
      in binary mode).
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      01c84866
    • C
      avocado.utils.process: use bytes for raw stdout/stderr · 7d0e6a44
      Cleber Rosa 提交于
      This brings a change in behaviour, in which the stdout/stderr of the
      executed process will now be of bytes type, instead of a string type.
      
      Two new attributes, which are implemented as properties, have been
      added to the CmdResult class, `stdout_text` and `stderr_text`.  Those
      are convenience methods that will return the same content that is in
      `stdout` and `stderr`, reespectively, but decoded on the fly[1].
      
      With regards to encoding, if one is not provided, the result of
      `sys.getdefaultencoding()` will be used ("utf-8" for Python 3 and
      "ascii" for Python 2).
      
      Applications and/or tests using the APIs that return a CmdResult
      should, to the best of my knowledge, set a default encoding themselves
      so a stable behavior across Python versions.  But that if left to
      users of this API.
      
      A different tradeoff/design decision has to do with the tests modified
      here.  One option is to have "text" (as in sequences of human readable
      glyphs) as being of Python type "str".  On Python 2, "str" can be
      compared to "bytes" because a conversion will happen on demand.  That
      is, the following is fine on Python 2:
      
         >>> result = process.run("command")
         >>> "expected" in process.stdout
      
      Where `expected` is of type "str" and `process.stdout` is of type
      "bytes".  This is not true of Python 3, so either the types must match
      or a conversion must be done explicitly.  The solutions to that are:
      
      1) have these "text" as (of type) "bytes" in the source code itself,
         and avoid the conversion whenever possible
      2) have "strings" in the source code itself, and use the conversion
         provided by `CmdResult.stdout_text` and `CmdResult.stderr_text`.
      
      The approach chosen here is to avoid conversion if possible, that is,
      use "byte" types, given the fact that the source code encoding is by
      default 'ascii' and most of the "text" dealt with here can be
      represented in 'ascii' too.  This is equivalent of doing:
      
         result = process.run("command")
         b"expected" in process.stdout
         "errors: %s" % 0 in process.stderr_text
      
      [1] The obvious alternative, instead of decoding these on the fly
          would be to have multiple copies of the "same" data.  This assumes
          that binary data produced on the stdout/stderr will usually be
          larger than textual data.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      7d0e6a44
  5. 15 2月, 2018 4 次提交
  6. 13 2月, 2018 3 次提交
  7. 12 2月, 2018 4 次提交
  8. 10 2月, 2018 1 次提交
    • A
      SIMPLE tests: improve status API · c42bfbc9
      Amador Pahim 提交于
      Currently simple tests have a limited status API, being able to set only
      the WARN status by generating an output string in a very specific and
      hard-coded format.
      
      This patch, while respects the current behaviour, creates configuration
      keys, allowing users to provide regular expressions to search for in the
      test outputs, aiming to set the final test status to either WARN or SKIP
      when the test finishes with exit code 0.
      Signed-off-by: NAmador Pahim <apahim@redhat.com>
      c42bfbc9
  9. 08 2月, 2018 1 次提交
    • C
      Test statuses: do not rely on varianter_yaml_to_mux plugin · 6e14beb9
      Cleber Rosa 提交于
      Which is an optional plugin, and the test statuses feature is at the
      innermost core of Avocado.  While the original test indeed saved a lot
      of duplicated code, it's code that serves a specific testing purpose,
      and it's better to be simpler and more verbose and with the right (no)
      dependencies.
      
      This issue came up during the Python 3 port work.  Now that all the
      unittests (selftests/unit/*) were passing (locally, there's one other
      PR pending to be accepted), the next logical step is getting the
      "core" functional (selftests/functional/*) tests passing.  Because
      the 'varianter_yaml_to_mux' optional plugins port is not done, the
      "core" functional tests fail and the current work flow is broken.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      6e14beb9
  10. 04 2月, 2018 1 次提交
  11. 20 1月, 2018 1 次提交
  12. 19 1月, 2018 3 次提交
    • C
      selftests/unit/test_safeloader.py: do not rely on assertRegex* methods · 70d525f1
      Cleber Rosa 提交于
      The prevailing coding style of Avocado (unittest.TestCase) tests is to
      use the specialized assert methods, such as assertNotRegexpMatches.
      
      Unfortunately, the regular expression related assertion methods have
      been through a messy renaming.  In theory, assertNotRegexpMatches and
      assertRegexpMatches should be available in Python 3.0 and 3.1, but not
      in Python >= 3.2, where it got renamed to assertRegex and
      assertNotRegex.
      
      In practice, in my system with Python 3.6.3, I see:
      
      >>> unittest.TestCase.assertNotRegexpMatches
      <function TestCase._deprecate.<locals>.deprecated_func at 0x7f3b85b709d8>
      
      But in Travis, with Python 3.4, it's not available:
      
      ERROR: test_directives_regex (selftests.unit.test_safeloader.DocstringDirectives)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/travis/build/avocado-framework/avocado/selftests/unit/test_safeloader.py", line 135, in test_directives_regex
          self.assertNotRegexpMatches(directive, safeloader.DOCSTRING_DIRECTIVE_RE)
      AttributeError: 'DocstringDirectives' object has no attribute 'assertNotRegexpMatches'
      
      Let's simplify things and just use a regex match and check for its
      result.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      70d525f1
    • L
      selftests: Use "readlink" instead of "realpath" · 3f66bd69
      Lukáš Doktor 提交于
      The "realpath" is being deprecated in favor of "readlink -f", which
      should mainly work the same way. This is required by Travis as it's
      version of Ubuntu does not contain "realpath".
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      3f66bd69
    • L
      selftests.checkall: Allow 24 tests to fail_once in parallel check · b8f711c0
      Lukáš Doktor 提交于
      In Travis more tests are failing when running in parallel, but still 20
      failed tests in parallel re-ran in series are faster than all tests in
      series.
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      b8f711c0
  13. 04 1月, 2018 3 次提交
  14. 24 12月, 2017 1 次提交
  15. 22 12月, 2017 1 次提交