@@ -230,10 +230,15 @@ public void testAddToPathBash() {
230230 String pathEnv = "/usr/bin:/bin" ;
231231 File bashrc = new File (homeDir , ".bashrc" );
232232
233- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
233+ // Use explicit macOS platform to test macOS-specific behavior
234+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
235+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
234236
235237 assertTrue (result );
236238 assertTrue (bashrc .exists (), "bashrc was not created" );
239+ // On macOS, .bash_profile should also be created
240+ File bashProfile = new File (homeDir , ".bash_profile" );
241+ assertTrue (bashProfile .exists (), "bash_profile should be created on macOS" );
237242 }
238243
239244 @ Test
@@ -242,19 +247,25 @@ public void testAddToPathZsh() {
242247 String pathEnv = "/usr/bin:/bin" ;
243248 File zshrc = new File (homeDir , ".zshrc" );
244249
245- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
250+ // Use explicit macOS platform to test macOS-specific behavior
251+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
252+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
246253
247254 assertTrue (result );
248255 assertTrue (zshrc .exists ());
256+ // On macOS, .bash_profile should also be created
257+ File bashProfile = new File (homeDir , ".bash_profile" );
258+ assertTrue (bashProfile .exists (), "bash_profile should be created on macOS" );
249259 }
250260
251261 @ Test
252262 public void testAddToPathAlreadyInPath () {
253263 String shell = "/bin/bash" ;
254264 String pathEnv = "/usr/bin:" + binDir .getAbsolutePath () + ":/bin" ;
255- File bashrc = new File (homeDir , ".bashrc" );
256265
257- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
266+ // Use explicit macOS platform to test macOS-specific behavior
267+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
268+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
258269
259270 assertTrue (result );
260271 }
@@ -269,7 +280,9 @@ public void testAddToPathAlreadyInConfig() throws IOException {
269280 // Pre-populate bashrc with the path
270281 Files .write (bashrc .toPath (), ("export PATH=\" $HOME/.local/bin:$PATH\" \n " ).getBytes (StandardCharsets .UTF_8 ));
271282
272- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
283+ // Use explicit macOS platform to test macOS-specific behavior
284+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
285+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
273286
274287 assertTrue (result );
275288 }
@@ -279,14 +292,16 @@ public void testAddToPathFish() {
279292 String shell = "/usr/bin/fish" ;
280293 String pathEnv = "/usr/bin:/bin" ;
281294
282- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
295+ // Use explicit macOS platform to test macOS-specific behavior
296+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
297+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
283298
284299 assertTrue (result );
285- // Now we write to both bash and zsh config files regardless of shell
300+ // On macOS, we write to bashrc, bash_profile, and zshrc
286301 File bashrc = new File (homeDir , ".bashrc" );
287302 assertTrue (bashrc .exists (), "bashrc should be created" );
288303 File bashProfile = new File (homeDir , ".bash_profile" );
289- assertTrue (bashProfile .exists (), "bash_profile should be created" );
304+ assertTrue (bashProfile .exists (), "bash_profile should be created on macOS " );
290305 File zshrc = new File (homeDir , ".zshrc" );
291306 assertTrue (zshrc .exists (), "zshrc should be created" );
292307 }
@@ -296,14 +311,16 @@ public void testAddToPathUnknownShell() {
296311 String shell = "/bin/unknown" ;
297312 String pathEnv = "/usr/bin:/bin" ;
298313
299- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
314+ // Use explicit macOS platform to test macOS-specific behavior
315+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
316+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
300317
301318 assertTrue (result );
302- // Now we write to both bash and zsh config files regardless of shell
319+ // On macOS, we write to bashrc, bash_profile, and zshrc
303320 File bashrc = new File (homeDir , ".bashrc" );
304321 assertTrue (bashrc .exists (), "bashrc should be created" );
305322 File bashProfile = new File (homeDir , ".bash_profile" );
306- assertTrue (bashProfile .exists (), "bash_profile should be created" );
323+ assertTrue (bashProfile .exists (), "bash_profile should be created on macOS " );
307324 File zshrc = new File (homeDir , ".zshrc" );
308325 assertTrue (zshrc .exists (), "zshrc should be created" );
309326 }
@@ -314,9 +331,15 @@ public void testAddToPathNullShell() {
314331 String pathEnv = "/usr/bin:/bin" ;
315332 File bashrc = new File (homeDir , ".bashrc" );
316333
317- boolean result = AbstractUnixCliCommandInstaller .addToPath (binDir , shell , pathEnv , homeDir );
334+ // Use explicit macOS platform to test macOS-specific behavior
335+ boolean result = UnixPathManager .addToPath (binDir , shell , pathEnv , homeDir ,
336+ new ca .weblite .tools .platform .Platform ("Mac OS X" , "x86_64" ));
318337
319338 assertTrue (result );
339+ assertTrue (bashrc .exists (), "bashrc should be created" );
340+ // On macOS, .bash_profile should also be created
341+ File bashProfile = new File (homeDir , ".bash_profile" );
342+ assertTrue (bashProfile .exists (), "bash_profile should be created on macOS" );
320343 }
321344
322345 @ Test
0 commit comments