Files
adareducer/testsuite/testsuite.py
Pierre-Marie de Rodat 84d51d571a Testsuite: add a --no-auto-path option
In the production environment, we want the testsuite to exercize the
adareducer that is being packaged (installed in the environment), not
the adareducer that is part of the testsuite source tree.

This new option prevents the testsuite from automatically adding the
adareducer part of the testsuite source tree to the environment.

TN: V317-010
2022-07-05 09:43:18 +02:00

53 lines
1.3 KiB
Python
Executable File

#! /usr/bin/env python
"""
Usage::
testsuite.py [OPTIONS]
Run the adareducer testsuite. This requires e3-testsuite.
"""
import os
import sys
import e3.testsuite
from drivers.shell_script import ShellScriptDriver
class AdaReducerTestsuite(e3.testsuite.Testsuite):
tests_subdir = "tests"
test_driver_map = {"shell_script": ShellScriptDriver}
default_driver = "shell_script"
def add_options(self, parser):
parser.add_argument(
"--no-auto-path",
dest="auto_path",
action="store_false",
help="Do not automatically make adareducer available, i.e. assume"
" it is already available in the environment."
)
def set_up(self) -> None:
super().set_up()
if self.env.options.auto_path:
# Set PYTHONPATH to find adareducer
root_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..")
)
os.environ["PYTHONPATH"] = "{}:{}".format(
root_dir,
os.environ.get("PYTHONPATH", ""),
)
os.environ["ADAREDUCER"] = f"{root_dir}/adareducer"
else:
os.environ["ADAREDUCER"] = "adareducer"
if __name__ == "__main__":
sys.exit(AdaReducerTestsuite(os.path.dirname(__file__)).testsuite_main())