@@ -2928,6 +2928,35 @@ def gather_output(executable, output_dir, ble):
2928
2928
shelly ()
2929
2929
2930
2930
2931
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2932
+ def test_shell_cmd_outputspec_5c (plugin , results_function ):
2933
+ """
2934
+ Customised output spec defined as a class,
2935
+ using a static function to collect output files.
2936
+ """
2937
+
2938
+ @attr .s (kw_only = True )
2939
+ class MyOutputSpec (ShellOutSpec ):
2940
+ @staticmethod
2941
+ def gather_output (executable , output_dir ):
2942
+ files = executable [1 :]
2943
+ return [Path (output_dir ) / file for file in files ]
2944
+
2945
+ newfile : MultiOutputFile = attr .ib (metadata = {"callable" : gather_output })
2946
+
2947
+ shelly = ShellCommandTask (
2948
+ name = "shelly" ,
2949
+ executable = ["touch" , "newfile_tmp1.txt" , "newfile_tmp2.txt" ],
2950
+ output_spec = SpecInfo (name = "Output" , bases = (MyOutputSpec ,)),
2951
+ )
2952
+
2953
+ res = results_function (shelly , plugin )
2954
+ assert res .output .stdout == ""
2955
+ # newfile is a list
2956
+ assert len (res .output .newfile ) == 2
2957
+ assert all ([file .exists for file in res .output .newfile ])
2958
+
2959
+
2931
2960
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2932
2961
def test_shell_cmd_outputspec_6 (plugin , results_function , tmpdir ):
2933
2962
"""
0 commit comments