diff options
Diffstat (limited to 'test/functional/lib/rspamd.py')
-rw-r--r-- | test/functional/lib/rspamd.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index f938ba124..2bb5ce3d2 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -31,22 +31,23 @@ def save_run_results(directory, filenames): current_directory = os.getcwd() suite_name = BuiltIn().get_variable_value("${SUITE_NAME}") test_name = BuiltIn().get_variable_value("${TEST NAME}") - onlyfiles = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))] - logger.debug('%s content before cleanup: %s' % (directory, onlyfiles)) - if test_name is None: - # this is suite-level tear down - destination_directory = "%s/robot-save/%s" % (current_directory, suite_name) - else: - destination_directory = "%s/robot-save/%s/%s" % (current_directory, suite_name, test_name) - if not os.path.isdir(destination_directory): - os.makedirs(destination_directory) - for file in filenames.split(' '): - source_file = "%s/%s" % (directory, file) - logger.debug('check if we can save %s' % source_file) - if os.path.isfile(source_file): - logger.debug('found %s, save it' % file) - shutil.copy(source_file, "%s/%s" % (destination_directory, file)) - shutil.copy(source_file, "%s/robot-save/%s.last" % (current_directory, file)) + if os.path.exists(directory): + onlyfiles = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))] + logger.debug('%s content before cleanup: %s' % (directory, onlyfiles)) + if test_name is None: + # this is suite-level tear down + destination_directory = "%s/robot-save/%s" % (current_directory, suite_name) + else: + destination_directory = "%s/robot-save/%s/%s" % (current_directory, suite_name, test_name) + if not os.path.isdir(destination_directory): + os.makedirs(destination_directory) + for file in filenames.split(' '): + source_file = "%s/%s" % (directory, file) + logger.debug('check if we can save %s' % source_file) + if os.path.isfile(source_file): + logger.debug('found %s, save it' % file) + shutil.copy(source_file, "%s/%s" % (destination_directory, file)) + shutil.copy(source_file, "%s/robot-save/%s.last" % (current_directory, file)) def encode_filename(filename): return "".join(['%%%0X' % ord(b) for b in filename]) @@ -340,3 +341,7 @@ def collect_lua_coverage(): logger.info("%s merged into %s" % (", ".join(input_files), LUA_STATSFILE)) else: logger.info("no *.luacov.stats.out files found in %s" % tmp_dir) + + +def file_exists(file): + return os.path.isfile(file) |