The Gaudi Framework  v36r13 (995e4364)
collect_for_ctest Namespace Reference

Functions

def pytest_addoption (parser, pluginmanager)
 
def pytest_collection_modifyitems (session, config, items)
 
def pytest_collection_finish (session)
 

Variables

 TEST_DESC_TEMPLATE
 

Function Documentation

◆ pytest_addoption()

def collect_for_ctest.pytest_addoption (   parser,
  pluginmanager 
)

Definition at line 22 of file collect_for_ctest.py.

22 def pytest_addoption(parser, pluginmanager):
23  parser.addoption(
24  "--ctest-output-file",
25  type=argparse.FileType("w"),
26  help="name of the file to write to communicate to ctest the discovered tests",
27  )
28  parser.addoption(
29  "--ctest-pytest-command",
30  default="pytest",
31  help="how pytest has to be invoked (e.g. using wrapper commands)",
32  )
33  parser.addoption(
34  "--ctest-pytest-root-dir",
35  default=Path.cwd(),
36  help="root directory to compute test names",
37  )
38  parser.addoption(
39  "--ctest-prefix",
40  default="",
41  help="string to prefix to the generated test names",
42  )
43  parser.addoption(
44  "--ctest-label",
45  default=["pytest"],
46  action="append",
47  help="labels to attach to the test (the label pytest is always added)",
48  )
49  parser.addoption(
50  "--ctest-properties",
51  default=[],
52  action="append",
53  help="test properties to set for all discovered tests",
54  )
55 
56 

◆ pytest_collection_finish()

def collect_for_ctest.pytest_collection_finish (   session)

Definition at line 75 of file collect_for_ctest.py.

75 def pytest_collection_finish(session):
76  args = session.ctest_args
77  output = args.get("output_file")
78  if not output:
79  # nothing to do if no output file is specified
80  return
81 
82  properties = 'LABELS "{}" '.format(";".join(args["label"]))
83  properties += " ".join(args["properties"])
84 
85  for path in sorted(session.ctest_files):
86  name = (
87  args["prefix"] + os.path.relpath(path, args["pytest_root_dir"])
88  ).replace("/", ".")
89  if name.endswith(".py"):
90  name = name[:-3]
91  output.write(
92  TEST_DESC_TEMPLATE.format(
93  name=name,
94  path=path,
95  pytest_cmd=args["pytest_command"],
96  properties=properties,
97  )
98  )
99 
100  output.close()

◆ pytest_collection_modifyitems()

def collect_for_ctest.pytest_collection_modifyitems (   session,
  config,
  items 
)

Definition at line 57 of file collect_for_ctest.py.

57 def pytest_collection_modifyitems(session, config, items):
58  args = {
59  name[6:]: getattr(config.option, name)
60  for name in dir(config.option)
61  if name.startswith("ctest_")
62  }
63  session.ctest_args = args
64  session.ctest_files = set(
65  item.path if hasattr(item, "path") else Path(item.fspath) for item in items
66  )
67 
68 

Variable Documentation

◆ TEST_DESC_TEMPLATE

collect_for_ctest.TEST_DESC_TEMPLATE

Definition at line 69 of file collect_for_ctest.py.

MyGaudiAlg.Path
Path
Definition: MyGaudiAlg.py:27
collect_for_ctest.pytest_collection_finish
def pytest_collection_finish(session)
Definition: collect_for_ctest.py:75
collect_for_ctest.pytest_collection_modifyitems
def pytest_collection_modifyitems(session, config, items)
Definition: collect_for_ctest.py:57
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
collect_for_ctest.pytest_addoption
def pytest_addoption(parser, pluginmanager)
Definition: collect_for_ctest.py:22