@@ -54,7 +54,7 @@ def test_custom_source_root(self, mock_default_dirs, tmp_path):
5454 custom_source .mkdir ()
5555 with patch ("sys.argv" , ["relink.py" , str (custom_source )]):
5656 args = relink .parse_arguments ()
57- assert args .source_root == str (custom_source .resolve ())
57+ assert args .source_root == [ str (custom_source .resolve ())]
5858 assert args .target_root == target_dir
5959
6060 def test_custom_target_root (self , mock_default_dirs , tmp_path ):
@@ -83,7 +83,7 @@ def test_both_custom_paths(self, tmp_path):
8383 ],
8484 ):
8585 args = relink .parse_arguments ()
86- assert args .source_root == str (source_path .resolve ())
86+ assert args .source_root == [ str (source_path .resolve ())]
8787 assert args .target_root == str (target_path .resolve ())
8888
8989 def test_verbose_flag (self , mock_default_dirs ): # pylint: disable=unused-argument
@@ -171,6 +171,49 @@ def test_timing_default(self, mock_default_dirs):
171171 args = relink .parse_arguments ()
172172 assert args .timing is False
173173
174+ def test_multiple_source_roots (self , mock_default_dirs , tmp_path ):
175+ """Test that multiple source root arguments are parsed correctly."""
176+ _ , target_dir = mock_default_dirs
177+ source1 = tmp_path / "source1"
178+ source2 = tmp_path / "source2"
179+ source3 = tmp_path / "source3"
180+ source1 .mkdir ()
181+ source2 .mkdir ()
182+ source3 .mkdir ()
183+
184+ with patch ("sys.argv" , ["relink.py" , str (source1 ), str (source2 ), str (source3 )]):
185+ args = relink .parse_arguments ()
186+ assert len (args .source_root ) == 3
187+ assert str (source1 .resolve ()) in args .source_root
188+ assert str (source2 .resolve ()) in args .source_root
189+ assert str (source3 .resolve ()) in args .source_root
190+ assert args .target_root == target_dir
191+
192+ def test_multiple_source_roots_with_target (self , tmp_path ):
193+ """Test multiple source roots with custom target root."""
194+ source1 = tmp_path / "source1"
195+ source2 = tmp_path / "source2"
196+ target = tmp_path / "target"
197+ source1 .mkdir ()
198+ source2 .mkdir ()
199+ target .mkdir ()
200+
201+ with patch (
202+ "sys.argv" ,
203+ [
204+ "relink.py" ,
205+ str (source1 ),
206+ str (source2 ),
207+ "--target-root" ,
208+ str (target ),
209+ ],
210+ ):
211+ args = relink .parse_arguments ()
212+ assert len (args .source_root ) == 2
213+ assert str (source1 .resolve ()) in args .source_root
214+ assert str (source2 .resolve ()) in args .source_root
215+ assert args .target_root == str (target .resolve ())
216+
174217
175218class TestValidateDirectory :
176219 """Test suite for validate_directory function."""
@@ -232,6 +275,29 @@ def test_symlink_to_directory(self, tmp_path):
232275 # Verify it's still a symlink
233276 assert os .path .islink (result )
234277
278+ def test_list_with_invalid_directory (self , tmp_path ):
279+ """Test that a list with one invalid directory raises error."""
280+ dir1 = tmp_path / "dir1"
281+ dir1 .mkdir ()
282+ nonexistent = tmp_path / "nonexistent"
283+
284+ with pytest .raises (argparse .ArgumentTypeError ) as exc_info :
285+ relink .validate_directory ([str (dir1 ), str (nonexistent )])
286+
287+ assert "does not exist" in str (exc_info .value )
288+
289+ def test_list_with_file_instead_of_directory (self , tmp_path ):
290+ """Test that a list containing a file raises error."""
291+ dir1 = tmp_path / "dir1"
292+ dir1 .mkdir ()
293+ file1 = tmp_path / "file.txt"
294+ file1 .write_text ("content" )
295+
296+ with pytest .raises (argparse .ArgumentTypeError ) as exc_info :
297+ relink .validate_directory ([str (dir1 ), str (file1 )])
298+
299+ assert "not a directory" in str (exc_info .value )
300+
235301
236302class TestProcessArgs :
237303 """Test suite for process_args function."""
0 commit comments