Belle II Software  release-06-02-00
SteeringFileTest Class Reference
Inheritance diagram for SteeringFileTest:
Collaboration diagram for SteeringFileTest:

Public Member Functions

def test_lessons_1_to_5 (self)
 

Private Member Functions

def _test_examples_dir (self, str path_to_glob, Optional[List[str]] broken=None, Optional[List[str]] additional_arguments=None, Optional[List[str]] expensive_tests=None, Optional[List[str]] skip_in_light=None)
 

Detailed Description

 Test steering files 

Definition at line 40 of file steering_files.py.

Member Function Documentation

◆ _test_examples_dir()

def _test_examples_dir (   self,
str  path_to_glob,
Optional[List[str]]   broken = None,
Optional[List[str]]   additional_arguments = None,
Optional[List[str]]   expensive_tests = None,
Optional[List[str]]   skip_in_light = None 
)
private
Internal function to test a directory full of example scripts with an
optional list of broken scripts to be skipped.

Parameters:
    path_to_glob (str): the path to a directory to search for python
        scripts (must end in .py)
    broken (list(str)): (optional) names of scripts that are known to
        be broken and can be skipped
    additional_arguments (list(str)): (optional) additional arguments
        for basf2 to be passed when testing the scripts
    expensive_tests (list(str)): (optional) names of scripts that take
        longer and should e.g. not run on bamboo
    skip_in_light (list(str)): (optional) names of scripts that have to
        be excluded in light builds

Definition at line 43 of file steering_files.py.

50  ):
51  """
52  Internal function to test a directory full of example scripts with an
53  optional list of broken scripts to be skipped.
54 
55  Parameters:
56  path_to_glob (str): the path to a directory to search for python
57  scripts (must end in .py)
58  broken (list(str)): (optional) names of scripts that are known to
59  be broken and can be skipped
60  additional_arguments (list(str)): (optional) additional arguments
61  for basf2 to be passed when testing the scripts
62  expensive_tests (list(str)): (optional) names of scripts that take
63  longer and should e.g. not run on bamboo
64  skip_in_light (list(str)): (optional) names of scripts that have to
65  be excluded in light builds
66  """
67  if additional_arguments is None:
68  additional_arguments = []
69  if broken is None:
70  broken = []
71  if expensive_tests is None:
72  expensive_tests = []
73  if skip_in_light is None:
74  skip_in_light = []
75  # we have to copy all the steering files (plus other stuffs, like decfiles) we want to test
76  # into a new directory and then cd it as working directory when subprocess.run is executed,
77  # otherwise the test will fail horribly if find_file is called by one of the tested steerings.
78  original_dir = find_file(path_to_glob)
79  working_dir = find_file(shutil.copytree(original_dir, 'working_dir'))
80  all_egs = sorted(glob.glob(working_dir + "/*.py"))
81  for eg in all_egs:
82  filename = os.path.basename(eg)
83  if filename in broken:
84  continue
85  if is_ci() and filename in expensive_tests:
86  continue
87  if light_release() and filename in skip_in_light:
88  continue
89  with self.subTest(msg=filename):
90  result = subprocess.run(
91  ["basf2", "-n1", eg, *additional_arguments],
92  stdout=subprocess.PIPE,
93  stderr=subprocess.STDOUT,
94  cwd=working_dir,
95  )
96  if result.returncode != 0:
97  # failure running example so let's print the output
98  # on stderr so it's not split from output of unittest
99  # done like this since we don't want to decode/encode utf8
100  sys.stdout.buffer.write(result.stdout)
101  self.assertEqual(result.returncode, 0)
102 

◆ test_lessons_1_to_5()

def test_lessons_1_to_5 (   self)
Test lesson on basf2 basics.

Definition at line 109 of file steering_files.py.


The documentation for this class was generated from the following file: