@@ -13,8 +13,14 @@ def test_log_dir_echo_output(tmp_path: Path) -> None:
13
13
)
14
14
assert "completed success" in stderr , stderr
15
15
assert json .loads (stdout )["out" ].strip ("\n " ) == "hello"
16
- # and then check in `tmp_path` that there is no stdout log file, since `echo.cwl` uses `stdout` itself.
17
- # should there be an empty stderr log, though?
16
+ assert len (list (tmp_path .iterdir ())) == 1
17
+ subdir = next (tmp_path .iterdir ())
18
+ assert subdir .is_dir ()
19
+ assert len (list (subdir .iterdir ())) == 1
20
+ result = next (subdir .iterdir ())
21
+ assert result .name == "out.txt"
22
+ output = open (result ).read ()
23
+ assert output == "hello\n "
18
24
19
25
20
26
def test_log_dir_echo_no_output (tmp_path : Path ) -> None :
@@ -27,8 +33,33 @@ def test_log_dir_echo_no_output(tmp_path: Path) -> None:
27
33
"hello" ,
28
34
]
29
35
)
30
- for dir in os .listdir (tmp_path ):
31
- for file in os .listdir (f"{ tmp_path } /{ dir } " ):
32
- assert file == "out.txt"
33
- output = open (f"{ tmp_path } /{ dir } /{ file } " , "r" ).read ()
34
- assert "hello" in output
36
+ assert len (list (tmp_path .iterdir ())) == 1
37
+ subdir = next (tmp_path .iterdir ())
38
+ assert subdir .name == "echo"
39
+ assert subdir .is_dir ()
40
+ assert len (list (subdir .iterdir ())) == 1
41
+ result = next (subdir .iterdir ())
42
+ assert result .name == "out.txt"
43
+ output = open (result ).read ()
44
+ assert output == "hello\n "
45
+
46
+
47
+ def test_log_dir_echo_stderr (tmp_path : Path ) -> None :
48
+ _ , stdout , stderr = get_main_output (
49
+ [
50
+ "--log-dir" ,
51
+ str (tmp_path ),
52
+ get_data ("tests/echo-stderr.cwl" ),
53
+ "--message" ,
54
+ "hello" ,
55
+ ]
56
+ )
57
+ assert len (list (tmp_path .iterdir ())) == 1
58
+ subdir = next (tmp_path .iterdir ())
59
+ assert subdir .name == "echo-stderr.cwl"
60
+ assert subdir .is_dir ()
61
+ assert len (list (subdir .iterdir ())) == 1
62
+ result = next (subdir .iterdir ())
63
+ assert result .name == "out.txt"
64
+ output = open (result ).read ()
65
+ assert output == "hello\n "
0 commit comments