44import click
55
66from . import structures as test_structures
7- from planemo .io import info , warn , shell_join
7+ from planemo .io import error , info , warn , shell_join
88from planemo .galaxy .run import (
99 run_galaxy_command ,
1010 setup_venv ,
1414
1515from galaxy .tools .deps .commands import shell
1616
17- XUNIT_UPGRADE_MESSAGE = ("This version of Galaxy does not support xUnit - "
18- "please update to newest development brach." )
19- NO_XUNIT_MESSAGE = ( "Cannot locate xUnit report option for tests - update "
20- "Galaxy for more detailed breakdown." )
21- NO_JSON_MESSAGE = ( "Cannot locate json report option for tests - update "
22- "Galaxy for more detailed breakdown ." )
17+ NO_XUNIT_REPORT_MESSAGE = ("Cannot locate xUnit report [%s] for tests - "
18+ "required to build planemo report and summarize "
19+ "tests." )
20+ NO_JSON_REPORT_MESSAGE = ( "Cannot locate JSON report [%s] for tests - "
21+ "required to build planemo report and summarize "
22+ "tests ." )
2323NO_TESTS_MESSAGE = "No tests were executed - see Galaxy output for details."
2424ALL_TESTS_PASSED_MESSAGE = "All %d test(s) executed passed."
2525PROBLEM_COUNT_MESSAGE = ("There were problems with %d test(s) - out of %d "
2929GENERIC_TESTS_PASSED_MESSAGE = "No failing tests encountered."
3030
3131
32- def run_in_config (ctx , config , ** kwds ):
32+ def run_in_config (ctx , config , run = run_galaxy_command , ** kwds ):
3333 """Run Galaxy tests with the run_tests.sh command.
3434
3535 The specified `config` object describes the context for tool
@@ -42,7 +42,7 @@ def run_in_config(ctx, config, **kwds):
4242 if job_output_files is None :
4343 job_output_files = os .path .join (config_directory , "jobfiles" )
4444
45- xunit_supported , xunit_report_file = _xunit_state (kwds , config )
45+ xunit_report_file = _xunit_state (kwds , config )
4646 structured_report_file = _structured_report_file (kwds , config )
4747
4848 info ("Testing using galaxy_root %s" , config .galaxy_root )
@@ -75,7 +75,7 @@ def run_in_config(ctx, config, **kwds):
7575 test_cmd ,
7676 )
7777 action = "Testing tools"
78- return_code = run_galaxy_command (
78+ return_code = run (
7979 ctx ,
8080 cmd ,
8181 config .env ,
@@ -85,9 +85,15 @@ def run_in_config(ctx, config, **kwds):
8585 update_cp_args = (job_output_files , config .test_data_dir )
8686 shell ('cp -r "%s"/* "%s"' % update_cp_args )
8787
88- if xunit_report_file and (not os .path .exists (xunit_report_file )):
89- warn (NO_XUNIT_MESSAGE )
90- xunit_report_file = None
88+ if not os .path .exists (xunit_report_file ):
89+ message = NO_XUNIT_REPORT_MESSAGE % xunit_report_file
90+ error (message )
91+ raise Exception (message )
92+
93+ if not os .path .exists (structured_report_file ):
94+ message = NO_JSON_REPORT_MESSAGE % structured_report_file
95+ error (message )
96+ raise Exception (message )
9197
9298 test_results = test_structures .GalaxyTestResults (
9399 structured_report_file ,
@@ -243,33 +249,31 @@ def _print_command_line(structured_data, test_id):
243249
244250
245251def _xunit_state (kwds , config ):
246- xunit_supported = True
247- if shell ("grep -q xunit '%s'/run_tests.sh" % config .galaxy_root ):
248- xunit_supported = False
252+ # This has been supported in Galaxy for well over a year, just going to assume
253+ # it from here on out.
254+ # xunit_supported = True
255+ # if shell("grep -q xunit '%s'/run_tests.sh" % config.galaxy_root):
256+ # xunit_supported = False
249257
250258 xunit_report_file = kwds .get ("test_output_xunit" , None )
251- if xunit_report_file is None and xunit_supported :
259+ if xunit_report_file is None :
252260 xunit_report_file = os .path .join (config .config_directory , "xunit.xml" )
253- elif xunit_report_file is not None and not xunit_supported :
254- warn (XUNIT_UPGRADE_MESSAGE )
255- xunit_report_file = None
256261
257- return xunit_supported , xunit_report_file
262+ return xunit_report_file
258263
259264
260265def _structured_report_file (kwds , config ):
261- structured_data_supported = True
262- if shell ("grep -q structured_data '%s'/run_tests.sh" % config .galaxy_root ):
263- structured_data_supported = False
266+ # This has been supported in Galaxy for well over a year, just going to assume
267+ # it from here on out.
268+ # structured_data_supported = True
269+ # if shell("grep -q structured_data '%s'/run_tests.sh" % config.galaxy_root):
270+ # structured_data_supported = False
264271
265272 structured_report_file = None
266273 structured_report_file = kwds .get ("test_output_json" , None )
267- if structured_report_file is None and structured_data_supported :
274+ if structured_report_file is None :
268275 conf_dir = config .config_directory
269276 structured_report_file = os .path .join (conf_dir , "structured_data.json" )
270- elif structured_report_file is not None and not structured_data_supported :
271- warn (NO_JSON_MESSAGE )
272- structured_report_file = None
273277
274278 return structured_report_file
275279
0 commit comments