e3.testsuite.driver.adacore
===========================

.. py:module:: e3.testsuite.driver.adacore


Classes
-------

.. autoapisummary::

   e3.testsuite.driver.adacore.AdaCoreLegacyTestDriver


Module Contents
---------------

.. py:class:: AdaCoreLegacyTestDriver(env: e3.env.Env, test_env: Dict[str, Any])

   Bases: :py:obj:`e3.testsuite.driver.diff.DiffTestDriver`


   Test driver for legacy AdaCore testsuites.

   This test driver expects a "test.cmd", "test.sh" or "test.py" script in its
   directory, runs it, and succeeds iff its output matches the content of the
   "test.out" file (or is empty, if that file is missing). Execution of tests
   is controlled by "test.opt" files.

   This driver assumes that the list of discriminants for the "test.opt" file
   is available as "self.env.discs" (i.e. it is a list of strings), and that
   the environ for subprocesses is available as "self.env.test_environ".

   If the TEST_SUPPORT_DIR environment variable is defined, consider that it
   contains the name of a directory that contains a "support.sh" script, that
   is sourced at the beginning of every CMD/Shell test script.


   .. py:attribute:: copy_test_directory
      :value: False


      Return whether to automatically copy test directory to working dir.

      If this returns True, the working directory is automatically
      synchronized to the test directory before running the testcase:



   .. py:attribute:: default_encoding
      :value: 'binary'


      Return the default encoding to decode process outputs.

      If "binary", consider that process outputs are binary, so do not try to
      decode them to text.



   .. py:attribute:: diff_ignore_white_chars
      :value: True


      Whether to ignore white characters in diff computations.

      This returns whether the comparison between test output and baseline
      must ignore whitespaces (leading and trailing spaces, tabs and carriage
      returns on lines, and empty lines). Note that if we don't ignore them,
      we still canonicalize line separators (CRLF are replaced by LF before
      the comparison).

      Note that at some point, this mechanism should be unified with the
      ``output_refiners`` machinery. However, this relies on e3.diff's
      ignore_white_chars feature, which is not trivial to reimplement.



   .. py:attribute:: argv
      :type:  List[str]


   .. py:attribute:: test_environ
      :type:  Dict[str, str]


   .. py:attribute:: test_process
      :type:  Optional[e3.testsuite.driver.classic.ProcessResult]


   .. py:property:: test_control_creator
      :type: e3.testsuite.control.AdaCoreLegacyTestControlCreator


      Return a test control creator for this test.

      By default, this returns a YAMLTestControlCreator instance tied to this
      driver with an empty condition environment. Subclasses are free to
      override this to suit their needs: for instance returning a
      OptfileCreater to process "test.opt" files.



   .. py:property:: baseline_file
      :type: Tuple[str, bool]


      Return the test output baseline file.

      :return: The name of the text file (relative to test directories) that
          contains the expected test output and whether the baseline is a
          regexp.



   .. py:method:: set_up() -> None

      Run initialization operations before a test runs.

      Subclasses can override this to prepare testcase execution.

      Having a callback separate from "run" is useful when dealing with
      inheritance: overriding the "set_up" method in subclasses allows to
      append setup actions before the testcase execution actually takes place
      (in the "run" method).

      If everything happened in "run" method, that would not be possible
      unless re-implementing the "run" method in each subclass, with obvious
      code duplication issues.



   .. py:attribute:: default_substitutions
      :type:  List[Tuple[Pattern[str], str]]


   .. py:property:: cmd_substitutions
      :type: List[Tuple[Pattern[str], str]]


      List of substitutions to apply to scripts.

      This returns a list of patterns/replacements couples for substitutions
      to apply to scripts in order to convert them from "cmd" syntax to
      Bourne shell.



   .. py:property:: script_encoding
      :type: str


      Return the encoding to decode shell scripts.

      By default, this is the same as the ``default_encoding`` property,
      except in one case: when it returns ``binary``: assume UTF-8 in that
      case.



   .. py:method:: get_script_command_line() -> List[str]

      Return the command line to run the test script.



   .. py:property:: output_refiners
      :type: List[e3.testsuite.driver.diff.OutputRefiner[bytes]]


      List of refiners for test baselines/outputs.

      This just returns a refiner to canonicalize line endings unless the
      test environment contains a "strict_line_endings" key associated to
      true.



   .. py:method:: run() -> None

      Run the testcase.

      Subclasses must override this.



   .. py:method:: compute_failures() -> List[str]

      Return a failure if ``self.output.log`` does not match the baseline.

      This computes a diff with the content of the baseline file, unless
      there is a "baseline_regexp" entry in the test environment that
      evaluates to true.

      Subclasses can override this if they need more involved analysis:
      for instance computing multiple diffs.



