e3.testsuite.driver.adacore

Classes

AdaCoreLegacyTestDriver

Test driver for legacy AdaCore testsuites.

Module Contents

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

Bases: 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.

copy_test_directory = 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:

default_encoding = '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.

diff_ignore_white_chars = 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.

argv: List[str]
test_environ: Dict[str, str]
test_process: e3.testsuite.driver.classic.ProcessResult | None
property test_control_creator: 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.

property baseline_file: Tuple[str, bool]

Return the test output baseline file.

Returns:

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

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.

default_substitutions: List[Tuple[Pattern[str], str]]
property cmd_substitutions: 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.

property script_encoding: 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.

get_script_command_line() List[str]

Return the command line to run the test script.

property output_refiners: 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.

run() None

Run the testcase.

Subclasses must override this.

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.