@@ -43,7 +43,7 @@ def newcache(x):
4343 outputs = shelly (cache_dir = newcache ("shelly-exec" ))
4444 assert drop_stderr (env_outputs ) == drop_stderr (attrs_values (outputs ))
4545
46- outputs = shelly (environment = Native ())
46+ outputs = shelly (environment = Native (), cache_dir = newcache ( "shelly-call" ) )
4747 assert env_outputs == attrs_values (outputs )
4848
4949 with Submitter (cache_dir = newcache ("shelly-submitter" ), environment = Native ()) as sub :
@@ -59,11 +59,11 @@ def test_docker_1(tmp_path):
5959 def newcache (x ):
6060 makedir (tmp_path , x )
6161
62- cmd = [ "whoami" ]
62+ cmd = "whoami"
6363 docker = Docker (image = "busybox" )
6464 Shelly = shell .define (cmd )
6565 shelly = Shelly ()
66- assert shelly .cmdline == " " . join ( cmd )
66+ assert shelly .cmdline == cmd
6767
6868 shelly_job = Task (
6969 definition = shelly ,
@@ -267,7 +267,7 @@ def newcache(x):
267267 f .write ("hello " )
268268
269269 shelly = shelly_with_input_factory (filename = filename , executable = "cat" )
270- outputs_dict = docker .execute (shelly )
270+ outputs_dict = docker .execute (make_job ( shelly , tmp_path , "shelly" ) )
271271
272272 with Submitter (environment = docker , cache_dir = newcache ("shell_sub" )) as sub :
273273 results = sub (shelly )
@@ -340,7 +340,7 @@ def newcache(x):
340340 outputs = shelly .split (file = filename )(
341341 environment = docker , cache_dir = newcache ("shelly_call" )
342342 )
343- assert [s .strip for s in outputs .stdout ] == ["hello" , "hi" ]
343+ assert [s .strip () for s in outputs .stdout ] == ["hello" , "hi" ]
344344
345345
346346def shelly_outputfile_factory (filename , executable = "cp" ):
@@ -351,16 +351,20 @@ def shelly_outputfile_factory(filename, executable="cp"):
351351 shell .arg (
352352 name = "file_orig" ,
353353 type = File ,
354- position = 2 ,
354+ position = 1 ,
355355 help = "new file" ,
356356 argstr = "" ,
357357 ),
358- shell .arg (
358+ ],
359+ outputs = [
360+ shell .outarg (
359361 name = "file_copy" ,
360- type = str ,
361- output_file_template = "{file_orig}_copy" ,
362+ type = File ,
363+ path_template = "{file_orig}_copy" ,
362364 help = "output file" ,
363365 argstr = "" ,
366+ position = 2 ,
367+ keep_extension = True ,
364368 ),
365369 ],
366370 )
@@ -390,11 +394,10 @@ def newcache(x):
390394 result = sub (shelly )
391395 assert Path (result .outputs .file_copy ) == result .output_dir / "file_copy.txt"
392396
393- outputs = shelly (environment = Native (), cache_dir = newcache ("shelly_call" ))
394- assert (
395- Path (outputs .file_copy )
396- == newcache ("shelly_call" ) / shelly ._checksum / "file_copy.txt"
397- )
397+ call_cache = newcache ("shelly_call" )
398+
399+ outputs = shelly (environment = Native (), cache_dir = call_cache )
400+ assert Path (outputs .file_copy ) == call_cache / shelly ._checksum / "file_copy.txt"
398401
399402
400403def test_shell_fileout_st (tmp_path ):
@@ -414,34 +417,21 @@ def newcache(x):
414417
415418 filename = [filename_1 , filename_2 ]
416419
417- shelly = shelly_outputfile_factory (
418- tempdir = tmp_path , filename = None , name = "shelly_sub"
419- )
420+ shelly = shelly_outputfile_factory (filename = None )
420421 with Submitter (environment = Native (), cache_dir = newcache ("shelly" )) as sub :
421422 results = sub (shelly .split (file_orig = filename ))
422423
423- assert results .outputs .file_copy == [
424- File ( results . output_dir / "file_1_copy.txt" ) ,
425- File ( results . output_dir / "file_2_copy.txt" ) ,
424+ assert [ f . name for f in results .outputs .file_copy ] == [
425+ "file_1_copy.txt" ,
426+ "file_2_copy.txt" ,
426427 ]
427428
428429 call_cache = newcache ("shelly_call" )
429430
430431 outputs = shelly .split (file_orig = filename )(
431432 environment = Native (), cache_dir = call_cache
432433 )
433- assert outputs .file_copy == [
434- File (
435- call_cache
436- / attrs .evolve (shelly , file_orig = filename_1 )._checksum
437- / "file_1_copy.txt"
438- ),
439- File (
440- call_cache
441- / attrs .evolve (shelly , file_orig = filename_1 )._checksum
442- / "file_1_copy.txt"
443- ),
444- ]
434+ assert [f .name for f in outputs .file_copy ] == ["file_1_copy.txt" , "file_2_copy.txt" ]
445435
446436
447437@no_win
@@ -459,15 +449,11 @@ def newcache(x):
459449 with open (filename , "w" ) as f :
460450 f .write ("hello " )
461451
462- shelly_sub = shelly_outputfile_factory (
463- tempdir = tmp_path , filename = filename , name = "shelly_sub"
464- )
465- shelly_sub .environment = docker_env
466- shelly_sub ()
467- assert (
468- Path (shelly_sub .result ().output .file_copy )
469- == shelly_sub .output_dir / "file_copy.txt"
470- )
452+ shelly = shelly_outputfile_factory (filename = filename )
453+
454+ with Submitter (environment = docker_env , cache_dir = newcache ("shelly" )) as sub :
455+ results = sub (shelly )
456+ assert results .outputs .file_copy == File (results .output_dir / "file_copy.txt" )
471457
472458
473459@no_win
@@ -495,15 +481,7 @@ def newcache(x):
495481
496482 with Submitter (environment = docker_env , cache_dir = newcache ("shelly_sub" )) as sub :
497483 results = sub (shelly .split (file_orig = filename ))
498- assert results .outputs .file_copy == [
499- File (
500- results .output_dir
501- / attrs .evolve (shelly , file_orig = filename_1 )._checksum
502- / "file_1_copy.txt"
503- ),
504- File (
505- results .output_dir
506- / attrs .evolve (shelly , file_orig = filename_2 )._checksum
507- / "file_2_copy.txt"
508- ),
484+ assert [f .name for f in results .outputs .file_copy ] == [
485+ "file_1_copy.txt" ,
486+ "file_2_copy.txt" ,
509487 ]
0 commit comments