+ # We need at least a path to a recipe file or a dir to a test
+ if not dir and not recipe:
+ raise TestException("Did not get a path to a test or to a recipe file")
+
+ # We cannot decide which to use when we get both
+ if (dir and recipe_file) or (dir and settings_file):
+ raise TestException("Get dir and path to recipe or settings file")
+
+ if dir:
+ try:
+ if not os.path.isabs(dir):
+ self.path = os.path.abspath(dir)
+ except BaseException as e:
+ logger.error("Could not get absolute path")
+ raise e
+
+ logger.debug("Path of this test is: {}".format(self.path))
+
+ self.recipe_file = "{}/recipe".format(self.path)
+ self.settings_file = "{}/settings".format(self.path)
+
+ if recipe_file:
+ if not os.path.isabs(recipe_file):
+ self.recipe_file = os.path.abspath(recipe_file)
+ else:
+ self.recipe_file = recipe_file
+
+ if settings_file:
+ if not os.path.isabs(settings_file):
+ self.settings_file = os.path.abspath(settings_file)
+ else:
+ self.settings_file = settings_file
+
+ # We can also go on without a settings file
+ if self.settings_file:
+ if not os.path.isfile(self.settings_file):
+ logger.error("No such file: {}".format(self.settings_file))
+ raise TestException("No settings file found")
+
+ # os.path.isfile fails if self.recipe_file is None so we need to catch exceptions here
+ try:
+ if not (self.recipe_file or os.path.isfile(self.recipe_file)):
+ logger.error("No such file: {}".format(self.recipe_file))
+ raise TestException("No recipe file found")
+ except BaseException:
+ pass