Update CI setup
[dotbot.git] / tests / test_bin_dotbot.py
blob4914c9a565fd808b0d8096d3f376e2db380b7fe0
1 import os
2 import shutil
3 import subprocess
5 import pytest
8 @pytest.mark.skipif(
9 "sys.platform[:5] == 'win32'",
10 reason="The hybrid sh/Python dotbot script doesn't run on Windows platforms",
12 @pytest.mark.parametrize("python_name", (None, "python", "python3"))
13 def test_find_python_executable(python_name, home, dotfiles):
14 """Verify that the sh/Python hybrid dotbot executable can find Python."""
16 dotfiles.write_config([])
17 dotbot_executable = os.path.join(
18 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "bin", "dotbot"
21 # Create a link to sh.
22 tmp_bin = os.path.join(home, "tmp_bin")
23 os.makedirs(tmp_bin)
24 sh_path = shutil.which("sh")
25 os.symlink(sh_path, os.path.join(tmp_bin, "sh"))
27 if python_name:
28 with open(os.path.join(tmp_bin, python_name), "w") as file:
29 file.write("#!" + tmp_bin + "/sh\n")
30 file.write("exit 0\n")
31 os.chmod(os.path.join(tmp_bin, python_name), 0o777)
32 env = dict(os.environ)
33 env["PATH"] = tmp_bin
35 if python_name:
36 subprocess.check_call(
37 [dotbot_executable, "-c", dotfiles.config_filename],
38 env=env,
40 else:
41 with pytest.raises(subprocess.CalledProcessError):
42 subprocess.check_call(
43 [dotbot_executable, "-c", dotfiles.config_filename],
44 env=env,