From 739fb1c9d0afa19a8a3f21ff93f046ebf3999efa Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 27 Sep 2021 11:10:52 +0200 Subject: [PATCH 1/5] test: check if extra files were created in Galaxy's file_path --- planemo/galaxy/test/actions.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index b62025333..1b9777e6d 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -3,6 +3,7 @@ import io import json import os +import re from distutils.dir_util import copy_tree import click @@ -121,11 +122,24 @@ def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None return_code, ) + ec = test_results.exit_code structured_data = test_results.structured_data + extra_files = [] + # check if tools created extra files in the file_path + for (path, dirs, files) in os.walk(config.env["GALAXY_CONFIG_OVERRIDE_FILE_PATH"]): + for name in files: + if not (name.endswith(".dat") or re.match('dataset_.*_files', name)): + extra_files += os.path.join(path, name) + if len(extra_files) > 0: + for i in range(len(structured_data["tests"])): + structured_data["tests"][i]["data"]["status"] = "failure" + structured_data["tests"][i]["data"]["job"]["stderr"] += "One of the tested tools wrote to Galaxy's files dir" + error("One of the tested tools wrote to Galaxy's files dir") + ec = 1 return handle_reports_and_summary( ctx, structured_data, - exit_code=test_results.exit_code, + exit_code=ec, kwds=kwds ) From 0a644bfb43484d3dde40591cd75c979b835d94cb Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 27 Sep 2021 15:45:11 +0200 Subject: [PATCH 2/5] fix assumptions of file names --- planemo/galaxy/test/actions.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index 1b9777e6d..856f3d29f 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -125,16 +125,19 @@ def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None ec = test_results.exit_code structured_data = test_results.structured_data extra_files = [] - # check if tools created extra files in the file_path + # check if tools created extra files in the file_path all files in the files path + # - end with '.dat' or + # - are contained in a directory `dataset_.*_files` for (path, dirs, files) in os.walk(config.env["GALAXY_CONFIG_OVERRIDE_FILE_PATH"]): for name in files: - if not (name.endswith(".dat") or re.match('dataset_.*_files', name)): - extra_files += os.path.join(path, name) + if not (name.endswith(".dat") or re.match('.*/dataset_.*_files$', path)): + extra_files.append(os.path.join(path, name)) if len(extra_files) > 0: + msg = f"One of the tested tools wrote to Galaxy's files dir: {extra_files}" for i in range(len(structured_data["tests"])): structured_data["tests"][i]["data"]["status"] = "failure" - structured_data["tests"][i]["data"]["job"]["stderr"] += "One of the tested tools wrote to Galaxy's files dir" - error("One of the tested tools wrote to Galaxy's files dir") + structured_data["tests"][i]["data"]["job"]["stderr"] += msg + error(msg) ec = 1 return handle_reports_and_summary( ctx, From 5a0fedd57675699618127df5a012edcd21fb4717 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 27 Sep 2021 15:45:59 +0200 Subject: [PATCH 3/5] try to fix tests question is why GALAXY_CONFIG_OVERRIDE_FILE_PATH is not set in the tests --- planemo/galaxy/test/actions.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index 856f3d29f..f26cc81ac 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -128,17 +128,18 @@ def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None # check if tools created extra files in the file_path all files in the files path # - end with '.dat' or # - are contained in a directory `dataset_.*_files` - for (path, dirs, files) in os.walk(config.env["GALAXY_CONFIG_OVERRIDE_FILE_PATH"]): - for name in files: - if not (name.endswith(".dat") or re.match('.*/dataset_.*_files$', path)): - extra_files.append(os.path.join(path, name)) - if len(extra_files) > 0: - msg = f"One of the tested tools wrote to Galaxy's files dir: {extra_files}" - for i in range(len(structured_data["tests"])): - structured_data["tests"][i]["data"]["status"] = "failure" - structured_data["tests"][i]["data"]["job"]["stderr"] += msg - error(msg) - ec = 1 + if config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH"): + for (path, dirs, files) in os.walk(config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH")): + for name in files: + if not (name.endswith(".dat") or re.match('.*/dataset_.*_files$', path)): + extra_files.append(os.path.join(path, name)) + if len(extra_files) > 0: + msg = f"One of the tested tools wrote to Galaxy's files dir: {extra_files}" + for i in range(len(structured_data["tests"])): + structured_data["tests"][i]["data"]["status"] = "failure" + structured_data["tests"][i]["data"]["job"]["stderr"] += msg + error(msg) + ec = 1 return handle_reports_and_summary( ctx, structured_data, From c883b9f5643fdbac5ca5483b922a0d329b1b7e61 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 27 Sep 2021 19:59:22 +0200 Subject: [PATCH 4/5] fix to assumption --- planemo/galaxy/test/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index f26cc81ac..50000dc5a 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -131,7 +131,7 @@ def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None if config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH"): for (path, dirs, files) in os.walk(config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH")): for name in files: - if not (name.endswith(".dat") or re.match('.*/dataset_.*_files$', path)): + if not (name.endswith(".dat") or re.match('^.*/dataset_.*_files/.*$', path)): extra_files.append(os.path.join(path, name)) if len(extra_files) > 0: msg = f"One of the tested tools wrote to Galaxy's files dir: {extra_files}" From 6c5b7f0a125e8786a692fc3feba9f78ea487ca16 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 28 Sep 2021 00:22:46 +0200 Subject: [PATCH 5/5] just skip _files directories --- planemo/galaxy/test/actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index 50000dc5a..23ccf7a51 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -130,8 +130,9 @@ def run_in_config(ctx, config, run=run_galaxy_command, test_data_target_dir=None # - are contained in a directory `dataset_.*_files` if config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH"): for (path, dirs, files) in os.walk(config.env.get("GALAXY_CONFIG_OVERRIDE_FILE_PATH")): + dirs[:] = [d for d in dirs if not re.match(r'^dataset_[^/]*_files$', d)] for name in files: - if not (name.endswith(".dat") or re.match('^.*/dataset_.*_files/.*$', path)): + if not name.endswith(".dat"): extra_files.append(os.path.join(path, name)) if len(extra_files) > 0: msg = f"One of the tested tools wrote to Galaxy's files dir: {extra_files}"