@@ -107,38 +107,41 @@ def test_get_installed_tools(scoop_dir: Path) -> None:
107107 apps_dir = scoop_dir .joinpath ("apps" )
108108
109109 # Check the details of individual tools
110- tool1 = next (filter (lambda t : t .name == "app1" and t .version == "1.0" , installed_tools ))
111- assert tool1 .name == "app1"
112- assert tool1 .version == "1.0"
113- assert tool1 .path == apps_dir .joinpath ("app1/1.0" )
114- assert tool1 .manifest_file == tool1 .path / "manifest.json"
115- assert tool1 .bin_dirs == [Path ("bin" )]
116- assert tool1 .env_add_path == []
117-
118- tool2 = next (filter (lambda t : t .name == "app1" and t .version == "2.0" , installed_tools ))
119- assert tool2 .name == "app1"
120- assert tool2 .version == "2.0"
121- assert tool2 .path == apps_dir .joinpath ("app1/2.0" )
122- assert tool2 .manifest_file == tool2 .path / "manifest.json"
123- assert tool2 .bin_dirs == [Path ("app" )]
124- assert tool2 .env_add_path == []
125-
126- tool3 = next (filter (lambda t : t .name == "app2" , installed_tools ))
127- assert tool3 .name == "app2"
128- assert tool3 .version == "3.1.1"
129- assert tool3 .path == apps_dir .joinpath ("app2/3.1.1" )
130- assert tool3 .manifest_file == tool3 .path / "manifest.json"
131- assert tool3 .bin_dirs == []
132- assert tool3 .env_add_path == []
133-
134- tool4 = next (filter (lambda t : t .name == "app3" , installed_tools ))
135- assert tool4 .name == "app3"
136- assert tool4 .version == "1.0"
137- assert tool4 .path == apps_dir .joinpath ("app3/1.0" )
138- assert tool4 .manifest_file == tool4 .path / "manifest.json"
139- assert tool4 .bin_dirs == [Path ("bin" )]
140- assert tool4 .env_add_path == [Path ("bin" )]
141- assert len (tool4 .get_all_required_paths ()) == 1 # Only bin path should be included
110+ tool = next (filter (lambda t : t .name == "app1" and t .version == "1.0" , installed_tools ))
111+ assert tool .name == "app1"
112+ assert tool .version == "1.0"
113+ assert tool .path == apps_dir .joinpath ("app1/1.0" )
114+ assert tool .manifest_file == tool .path / "manifest.json"
115+ assert tool .bin_dirs == [Path ("bin" ), Path ("." )]
116+ assert tool .env_add_path == []
117+ assert tool .get_all_required_paths () == [scoop_dir .joinpath (path ) for path in ["apps/app1/1.0/bin" , "apps/app1/1.0" ]]
118+
119+ tool = next (filter (lambda t : t .name == "app1" and t .version == "2.0" , installed_tools ))
120+ assert tool .name == "app1"
121+ assert tool .version == "2.0"
122+ assert tool .path == apps_dir .joinpath ("app1/2.0" )
123+ assert tool .manifest_file == tool .path / "manifest.json"
124+ assert tool .bin_dirs == [Path ("app" ), Path ("." )]
125+ assert tool .env_add_path == []
126+ assert tool .get_all_required_paths () == [scoop_dir .joinpath (path ) for path in ["apps/app1/2.0/app" , "apps/app1/2.0" ]]
127+
128+ tool = next (filter (lambda t : t .name == "app2" , installed_tools ))
129+ assert tool .name == "app2"
130+ assert tool .version == "3.1.1"
131+ assert tool .path == apps_dir .joinpath ("app2/3.1.1" )
132+ assert tool .manifest_file == tool .path / "manifest.json"
133+ assert tool .bin_dirs == [Path ("." )]
134+ assert tool .env_add_path == []
135+ assert tool .get_all_required_paths () == [scoop_dir .joinpath ("apps/app2/3.1.1" )]
136+
137+ tool = next (filter (lambda t : t .name == "app3" , installed_tools ))
138+ assert tool .name == "app3"
139+ assert tool .version == "1.0"
140+ assert tool .path == apps_dir .joinpath ("app3/1.0" )
141+ assert tool .manifest_file == tool .path / "manifest.json"
142+ assert tool .bin_dirs == [Path ("bin" )]
143+ assert tool .env_add_path == [Path ("bin" )]
144+ assert tool .get_all_required_paths () == [scoop_dir .joinpath ("apps/app3/1.0/bin" )]
142145
143146
144147def test_install (scoop_dir : Path , tmp_path : Path ) -> None :
@@ -500,3 +503,25 @@ def test_env_vars_parsing(scoop_dir: Path, env_set: Dict[str, Any], expected_env
500503
501504 # Assert the environment variables are correctly parsed
502505 assert installed_app .env_vars == formatted_expected_env_vars
506+
507+
508+ def test_bin_dirs_with_root_executable (scoop_dir : Path ) -> None :
509+ scoop_wrapper = create_scoop_wrapper (scoop_dir / "scoop.ps1" )
510+
511+ # Create a mock manifest file with a root-level executable
512+ manifest_file = scoop_dir / "apps" / "app_with_root_exe" / "1.0" / "manifest.json"
513+ manifest_file .parent .mkdir (parents = True )
514+ manifest_file .write_text (
515+ json .dumps (
516+ {
517+ "version" : "1.0" ,
518+ "bin" : "ninja.exe" ,
519+ }
520+ )
521+ )
522+
523+ # Parse the manifest file
524+ installed_app = scoop_wrapper .parse_manifest_file (manifest_file )
525+
526+ # Assert the bin_dirs includes the app root directory
527+ assert installed_app .bin_dirs == [Path ("." )], "The app root directory should be included in bin_dirs for root-level executables."
0 commit comments