@@ -2585,6 +2585,58 @@ def test_shell_cmd_outputspec_3(plugin, results_function, tmpdir):
2585
2585
2586
2586
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2587
2587
def test_shell_cmd_outputspec_4 (plugin , results_function , tmpdir ):
2588
+ """
2589
+ customised output_spec, adding files to the output,
2590
+ using a wildcard in default (in the directory name)
2591
+ """
2592
+ cmd = ["mkdir" , "tmp1" , ";" , "touch" , "tmp1/newfile.txt" ]
2593
+ my_output_spec = SpecInfo (
2594
+ name = "Output" ,
2595
+ fields = [("newfile" , File , "tmp*/newfile.txt" )],
2596
+ bases = (ShellOutSpec ,),
2597
+ )
2598
+ shelly = ShellCommandTask (
2599
+ name = "shelly" , executable = cmd , output_spec = my_output_spec , cache_dir = tmpdir
2600
+ )
2601
+
2602
+ res = results_function (shelly , plugin )
2603
+ assert res .output .stdout == ""
2604
+ assert res .output .newfile .exists ()
2605
+
2606
+
2607
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2608
+ def test_shell_cmd_outputspec_4a (plugin , results_function , tmpdir ):
2609
+ """
2610
+ customised output_spec, adding files to the output,
2611
+ using a wildcard in default (in the directory name), should collect two files
2612
+ """
2613
+ cmd = [
2614
+ "mkdir" ,
2615
+ "tmp1" ,
2616
+ "tmp2" ,
2617
+ ";" ,
2618
+ "touch" ,
2619
+ "tmp1/newfile.txt" ,
2620
+ "tmp2/newfile.txt" ,
2621
+ ]
2622
+ my_output_spec = SpecInfo (
2623
+ name = "Output" ,
2624
+ fields = [("newfile" , File , "tmp*/newfile.txt" )],
2625
+ bases = (ShellOutSpec ,),
2626
+ )
2627
+ shelly = ShellCommandTask (
2628
+ name = "shelly" , executable = cmd , output_spec = my_output_spec , cache_dir = tmpdir
2629
+ )
2630
+
2631
+ res = results_function (shelly , plugin )
2632
+ assert res .output .stdout == ""
2633
+ # newfile is a list
2634
+ assert len (res .output .newfile ) == 2
2635
+ assert all ([file .exists for file in res .output .newfile ])
2636
+
2637
+
2638
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2639
+ def test_shell_cmd_outputspec_5 (plugin , results_function , tmpdir ):
2588
2640
"""
2589
2641
customised output_spec, adding files to the output,
2590
2642
using a function to collect output, the function is saved in the field metadata
@@ -2613,7 +2665,7 @@ def gather_output(field, output_dir):
2613
2665
2614
2666
2615
2667
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2616
- def test_shell_cmd_outputspec_4a (plugin , results_function ):
2668
+ def test_shell_cmd_outputspec_5a (plugin , results_function ):
2617
2669
"""
2618
2670
customised output_spec, adding files to the output,
2619
2671
using a function to collect output, the function is saved in the field metadata
@@ -2639,7 +2691,7 @@ def gather_output(executable, output_dir):
2639
2691
assert all ([file .exists for file in res .output .newfile ])
2640
2692
2641
2693
2642
- def test_shell_cmd_outputspec_4b_error ():
2694
+ def test_shell_cmd_outputspec_5b_error ():
2643
2695
"""
2644
2696
customised output_spec, adding files to the output,
2645
2697
using a function to collect output, the function is saved in the field metadata
@@ -2662,7 +2714,7 @@ def gather_output(executable, output_dir, ble):
2662
2714
2663
2715
2664
2716
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2665
- def test_shell_cmd_outputspec_5 (plugin , results_function , tmpdir ):
2717
+ def test_shell_cmd_outputspec_6 (plugin , results_function , tmpdir ):
2666
2718
"""
2667
2719
providing output name by providing output_file_template
2668
2720
(similar to the previous example, but not touching input_spec)
@@ -2700,7 +2752,7 @@ def test_shell_cmd_outputspec_5(plugin, results_function, tmpdir):
2700
2752
assert res .output .out1 .exists ()
2701
2753
2702
2754
2703
- def test_shell_cmd_outputspec_5a ():
2755
+ def test_shell_cmd_outputspec_6a ():
2704
2756
"""
2705
2757
providing output name by providing output_file_template
2706
2758
(using shorter syntax)
@@ -2730,7 +2782,7 @@ def test_shell_cmd_outputspec_5a():
2730
2782
2731
2783
2732
2784
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2733
- def test_shell_cmd_outputspec_6 (tmpdir , plugin , results_function ):
2785
+ def test_shell_cmd_outputspec_7 (tmpdir , plugin , results_function ):
2734
2786
"""
2735
2787
providing output with output_file_name and using MultiOutputFile as a type.
2736
2788
the input field used in the template is a MultiInputObj, so it can be and is a list
@@ -2806,7 +2858,7 @@ def test_shell_cmd_outputspec_6(tmpdir, plugin, results_function):
2806
2858
2807
2859
2808
2860
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2809
- def test_shell_cmd_outputspec_6a (tmpdir , plugin , results_function ):
2861
+ def test_shell_cmd_outputspec_7a (tmpdir , plugin , results_function ):
2810
2862
"""
2811
2863
providing output with output_file_name and using MultiOutputFile as a type.
2812
2864
the input field used in the template is a MultiInputObj, but a single element is used
@@ -2881,7 +2933,7 @@ def test_shell_cmd_outputspec_6a(tmpdir, plugin, results_function):
2881
2933
2882
2934
2883
2935
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2884
- def test_shell_cmd_outputspec_7a (tmpdir , plugin , results_function ):
2936
+ def test_shell_cmd_outputspec_8a (tmpdir , plugin , results_function ):
2885
2937
"""
2886
2938
customised output_spec, adding int and str to the output,
2887
2939
requiring two callables with parameters stdout and stderr
@@ -2942,7 +2994,7 @@ def get_stderr(stderr):
2942
2994
assert res .output .stderr_field == f"stderr: { res .output .stderr } "
2943
2995
2944
2996
2945
- def test_shell_cmd_outputspec_7b_error ():
2997
+ def test_shell_cmd_outputspec_8b_error ():
2946
2998
"""
2947
2999
customised output_spec, adding Int to the output,
2948
3000
requiring a function to collect output
@@ -2971,7 +3023,7 @@ def test_shell_cmd_outputspec_7b_error():
2971
3023
2972
3024
2973
3025
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
2974
- def test_shell_cmd_outputspec_7c (tmpdir , plugin , results_function ):
3026
+ def test_shell_cmd_outputspec_8c (tmpdir , plugin , results_function ):
2975
3027
"""
2976
3028
customised output_spec, adding Directory to the output named by args
2977
3029
"""
@@ -3014,7 +3066,7 @@ def get_lowest_directory(directory_path):
3014
3066
3015
3067
3016
3068
@pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
3017
- def test_shell_cmd_outputspec_7d (tmpdir , plugin , results_function ):
3069
+ def test_shell_cmd_outputspec_8d (tmpdir , plugin , results_function ):
3018
3070
"""
3019
3071
customised output_spec, adding Directory to the output named by input spec
3020
3072
"""
0 commit comments