The test `test_run_cwd_in_combination_with_runas` fails in some test
environments (like Debian autopkgtest):
```
======================================================================
ERROR: test_run_cwd_in_combination_with_runas (unit.modules.test_cmdmod.CMDMODTestCase)
[CPU:0.0%|MEM:6.5%] cmd.run executes command in the cwd directory
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/unit/modules/test_cmdmod.py", line 449, in test_run_cwd_in_combination_with_runas
runas = os.getlogin()
OSError: [Errno 6] No such device or address
----------------------------------------------------------------------
```
Therefore replace `os.getlogin` by `getpass.getuser` as recommended by
upstream: "For most purposes, it is more useful to use
`getpass.getuser()` since the latter checks the environment variables
`LOGNAME` or `USERNAME` to find out who the user is, and falls back to
`pwd.getpwuid(os.getuid())[0]` to get the login name of the current real
user id."
Bug-Debian: https://bugs.debian.org/964270
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
When the home directory points to a directory that does not exist (e.g.
when building salt with sbuild), some test cases will fail:
```
_____________________________ test_run_with_tuple ______________________________
def test_run_with_tuple():
"""
Tests return when cmd is a tuple
"""
mock_true = MagicMock(return_value=True)
with patch("salt.modules.cmdmod._is_valid_shell", mock_true):
with patch("salt.utils.platform.is_windows", MagicMock(return_value=False)):
with patch("os.path.isfile", mock_true):
with patch("os.access", mock_true):
> cmdmod._run(("echo", "foo"), python_shell=True)
tests/pytests/unit/modules/test_cmdmod.py:159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
if not os.path.isabs(cwd) or not os.path.isdir(cwd):
> raise CommandExecutionError(
"Specified cwd '{}' either not absolute or does not exist".format(cwd)
)
E salt.exceptions.CommandExecutionError: Specified cwd '/sbuild-nonexistent' either not absolute or does not exist
salt/modules/cmdmod.py:665: CommandExecutionError
```
So change to `/`, because this directory exists on every system.
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>