sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.86k stars 128 forks source link

`test_sh` failing on alpine #593

Open eddsalkield opened 1 year ago

eddsalkield commented 1 year ago

Currently many test_sh tests fail on Alpine (x86_64, v2.10.1) with e.g.:

$ scons test
...
======================================================================
ERROR: test_sh.test_remove_empty_dirs('dash', True, {})
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib/python3.10/site-packages/parameterized/parameterized.py", line 404, in <lambda>
    nose_func = wraps(func)(lambda *args: func(*args[:-1], **args[-1]))
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/test_formatters/test_sh.py", line 207, in test_remove_empty_dirs
    _check_if_empty_dirs_deleted(shell, inverse_order, sh_path, data)
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/test_formatters/test_sh.py", line 166, in _check_if_empty_dirs_deleted
    run_shell_script(shell, sh_path, "-dc")
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/test_formatters/test_sh.py", line 12, in run_shell_script
    return subprocess.check_output([
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/dash'

This is because it's expecting the dash shell at /bin/dash, whereas alpine installs it at /usr/bin/dash. Maybe we could add a simple bit of logic to check /usr/bin as well, or alternatively find the binaries using $PATH?

cebtenzzre commented 1 year ago

My local repo falls back to searching PATH if a shell cannot be found in /bin, and failing that will simply skip the test for that shell. I'm working on getting those changes merged soon. For now, the workaround would be to replace os.path.join("/bin", shell) with just shell.