11from typing import Any
2+ from pathlib import Path
23from unittest .mock import ANY , MagicMock , Mock , patch , mock_open
34
45import wasi_test_runner .test_case as tc
@@ -10,9 +11,9 @@ def get_mock_open() -> Mock:
1011 def open_mock (filename : str , * _args : Any , ** _kwargs : Any ) -> Any :
1112 file_content = {
1213 "my-path/manifest.json" : '{"name": "test-suite"}' ,
13- "test1.json" : '{"dirs": [".", "deep/dir"]}' ,
14- "test2.json" : '{"exit_code": 1, "args": ["a", "b"]}' ,
15- "test3.json" : '{"stdout": "output", "env": {"x": "1"}}' ,
14+ "my-path/ test1.json" : '{"dirs": [".", "deep/dir"]}' ,
15+ "my-path/ test2.json" : '{"exit_code": 1, "args": ["a", "b"]}' ,
16+ "my-path/ test3.json" : '{"stdout": "output", "env": {"x": "1"}}' ,
1617 }
1718 if filename in file_content :
1819 return mock_open (read_data = file_content [filename ]).return_value
@@ -26,7 +27,10 @@ def open_mock(filename: str, *_args: Any, **_kwargs: Any) -> Any:
2627@patch ("builtins.open" , get_mock_open ())
2728@patch ("os.path.exists" , Mock (return_value = True ))
2829def test_runner_end_to_end () -> None :
29- test_paths = ["test1.wasm" , "test2.wasm" , "test3.wasm" ]
30+ test_suite_dir = "my-path"
31+ test_suite_name = "test-suite"
32+ test_files = ["test1.wasm" , "test2.wasm" , "test3.wasm" ]
33+ test_paths = [Path (test_suite_dir ) / f for f in test_files ]
3034
3135 failures = [tc .Failure ("a" , "b" ), tc .Failure ("x" , "y" ), tc .Failure ("x" , "z" )]
3236
@@ -75,9 +79,8 @@ def test_runner_end_to_end() -> None:
7579 filt .should_skip .return_value = (False , None )
7680 filters = [filt ]
7781
78- test_suite_dir = "my-path"
79- test_suite_name = "test-suite"
80- with patch ("glob.glob" , return_value = test_paths ):
82+ with (patch ("glob.glob" , return_value = [str (p ) for p in test_paths ]),
83+ patch ("wasi_test_runner.test_suite_runner._cleanup_test_output" )):
8184 suite = tsr .run_tests_from_test_suite (test_suite_dir , runtime ,
8285 validators , # type: ignore
8386 reporters , # type: ignore
@@ -93,8 +96,9 @@ def test_runner_end_to_end() -> None:
9396 # Assert test runner calls
9497 assert runtime .run_test .call_count == 3
9598 for test_path , config in zip (test_paths , expected_config ):
99+ expected_dirs = [(Path (test_suite_dir ) / d , d ) for d in config .dirs ]
96100 runtime .compute_argv .assert_any_call (
97- test_path , config .args , config .env , config . dirs
101+ str ( test_path ) , config .args , config .env , expected_dirs
98102 )
99103 runtime .run_test .assert_called_with (expected_argv )
100104
0 commit comments