PAL: Add processing of PPS and CPS tests
[csit.git] / resources / tools / presentation / specification_parser.py
index 548bbff..5a88a7b 100644 (file)
@@ -307,14 +307,15 @@ class Specification:
         else:
             raise PresentationError(f"Not supported build type: {build_type}")
         if ret_code != 0:
-            raise PresentationError(u"Not possible to get the number of the "
-                                    u"build number.")
+            raise PresentationError(
+                f"Not possible to get the build number of {job}."
+            )
         try:
             build_nr = int(build_nr)
             return build_nr
         except ValueError as err:
             raise PresentationError(
-                f"Not possible to get the number of the build number. Reason:\n"
+                f"Not possible to get the build number of {job}. Reason:\n"
                 f"{repr(err)}"
             )
 
@@ -529,14 +530,17 @@ class Specification:
                 if isinstance(builds, dict):
                     build_end = builds.get(u"end", None)
                     max_builds = builds.get(u"max-builds", None)
+                    reverse = builds.get(u"reverse", False)
                     try:
                         build_end = int(build_end)
                     except ValueError:
                         # defined as a range <start, build_type>
                         build_end = self._get_build_number(job, build_end)
-                    builds = [x for x in range(builds[u"start"], build_end + 1)]
+                    builds = list(range(builds[u"start"], build_end + 1))
                     if max_builds and max_builds < len(builds):
-                        builds = builds[:max_builds]
+                        builds = builds[-max_builds:]
+                    if reverse:
+                        builds.reverse()
                     self.configuration[u"data-sets"][set_name][job] = builds
                 elif isinstance(builds, list):
                     for idx, item in enumerate(builds):