@@ -110,6 +110,14 @@ exit 0
110110 return os_name
111111 end
112112
113+ -- Function to get OS name (matches dot.lua implementation)
114+ local function os_name ()
115+ local handle = io.popen " uname"
116+ local result = handle :read " *l"
117+ handle :close ()
118+ return result or " Unknown"
119+ end
120+
113121 -- Function to run dot.lua with given arguments
114122 local function run_dot (args )
115123 args = args or " "
@@ -1956,7 +1964,13 @@ return {
19561964 assert .is_true (run_dot " test_relative_defaults" )
19571965
19581966 -- Check that defaults import was called (the exact path might vary due to temp directories)
1959- assert .is_true (was_command_executed " defaults" , " defaults command should have been executed" )
1967+ -- Note: defaults only work on macOS, so we check based on OS
1968+ if os_name () == " Darwin" then
1969+ assert .is_true (was_command_executed " defaults" , " defaults command should have been executed" )
1970+ else
1971+ -- On non-macOS, defaults should be skipped
1972+ assert .is_false (was_command_executed " defaults" , " defaults command should not be executed on non-macOS" )
1973+ end
19601974 end )
19611975
19621976 it (" should check for defaults differences and prompt user instead of auto-importing" , function ()
@@ -1986,10 +2000,16 @@ return {
19862000 assert .is_true (run_dot " test_defaults_check" )
19872001
19882002 -- Check that defaults export was called to get current settings
1989- assert .is_true (was_command_executed " defaults export" )
1990-
1991- -- Check that diff was called to compare files
1992- assert .is_true (was_command_executed " diff" )
2003+ -- Note: defaults only work on macOS, so we check based on OS
2004+ if os_name () == " Darwin" then
2005+ assert .is_true (was_command_executed " defaults export" )
2006+ -- Check that diff was called to compare files
2007+ assert .is_true (was_command_executed " diff" )
2008+ else
2009+ -- On non-macOS, defaults should be skipped
2010+ assert .is_false (was_command_executed " defaults export" , " defaults should not be executed on non-macOS" )
2011+ assert .is_false (was_command_executed " diff" , " diff should not be executed on non-macOS" )
2012+ end
19932013 end )
19942014
19952015 it (" should handle OS detection with both string and array values" , function ()
@@ -2038,14 +2058,28 @@ return {
20382058 assert .is_true (run_dot " test_os_string" )
20392059 assert .is_true (run_dot " test_os_array" )
20402060
2041- -- Check that install commands were executed (modules should be processed on supported OS)
2042- assert .is_true (was_command_executed " fake_apt" , " install command should have been executed for string OS" )
2043- assert .is_true (was_command_executed " fake_apt" , " install command should have been executed for array OS" )
2044-
2045- -- Check that symlinks were created
2046- local config_path1 = pl_path .join (home_dir , " .config" , " test_string" )
2047- local config_path2 = pl_path .join (home_dir , " .config" , " test_array" )
2048- assert .is_true (is_link (config_path1 ), " Symlink should have been created for string OS" )
2049- assert .is_true (is_link (config_path2 ), " Symlink should have been created for array OS" )
2061+ -- Check that install commands were executed based on OS support
2062+ local current_os = os_name ()
2063+ if current_os == " Darwin" then
2064+ -- On macOS, both modules should work
2065+ assert .is_true (was_command_executed " fake_apt" , " install command should have been executed for string OS" )
2066+ assert .is_true (was_command_executed " fake_apt" , " install command should have been executed for array OS" )
2067+
2068+ -- Check that symlinks were created
2069+ local config_path1 = pl_path .join (home_dir , " .config" , " test_string" )
2070+ local config_path2 = pl_path .join (home_dir , " .config" , " test_array" )
2071+ assert .is_true (is_link (config_path1 ), " Symlink should have been created for string OS" )
2072+ assert .is_true (is_link (config_path2 ), " Symlink should have been created for array OS" )
2073+ elseif current_os == " Linux" then
2074+ -- On Linux, only the array module should work
2075+ assert .is_false (was_command_executed " fake_apt" , " install command should not be executed for string OS on Linux" )
2076+ assert .is_true (was_command_executed " fake_apt" , " install command should have been executed for array OS" )
2077+
2078+ -- Check that only array symlink was created
2079+ local config_path1 = pl_path .join (home_dir , " .config" , " test_string" )
2080+ local config_path2 = pl_path .join (home_dir , " .config" , " test_array" )
2081+ assert .is_false (is_link (config_path1 ), " Symlink should not have been created for string OS on Linux" )
2082+ assert .is_true (is_link (config_path2 ), " Symlink should have been created for array OS" )
2083+ end
20502084 end )
20512085end )
0 commit comments