diff --git a/test/fixtures/sshfs/local_path-dir/dummy.txt b/test/fixtures/sshfs/local_path-dir/dummy.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git "a/test/fixtures/sshfs/local_path-file\\" "b/test/fixtures/sshfs/local_path-file\\" deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/t/test_scp.py b/test/t/test_scp.py index f47b1e9f05a..d28a0eb6ada 100644 --- a/test/t/test_scp.py +++ b/test/t/test_scp.py @@ -1,4 +1,5 @@ import os +import sys from itertools import chain import pytest @@ -158,6 +159,28 @@ def test_xfunc_remote_files(self, bash): "shared/default/foo.d/", ] + @pytest.fixture + def tmpdir_backslash(self, request, bash): + if sys.platform.startswith("win"): + pytest.skip("Filenames not allowed on Windows") + + tmpdir, _, _ = prepare_fixture_dir( + request, files=["local_path-file\\"], dirs=[] + ) + return tmpdir + + def test_local_path_ending_with_backslash(self, bash, tmpdir_backslash): + completion = assert_complete( + bash, "scp local_path-", cwd=tmpdir_backslash + ) + assert completion.output == r"file\\ " + + def test_remote_path_ending_with_backslash(self, bash): + assert_bash_exec(bash, "ssh() { echo 'hypothetical\\'; }") + completion = assert_complete(bash, "scp remote_host:hypo") + assert_bash_exec(bash, "unset -f ssh") + assert completion.output == r"thetical\\\\ " + @pytest.fixture def tmpdir_mkfifo(self, request, bash): tmpdir, _, _ = prepare_fixture_dir(request, files=[], dirs=[]) diff --git a/test/t/test_sshfs.py b/test/t/test_sshfs.py index 5b502461e57..a530ef477f3 100644 --- a/test/t/test_sshfs.py +++ b/test/t/test_sshfs.py @@ -1,6 +1,8 @@ +import sys + import pytest -from conftest import assert_bash_exec, assert_complete +from conftest import assert_bash_exec, assert_complete, prepare_fixture_dir @pytest.mark.bashcomp(ignore_env=r"^[+-]_comp_cmd_scp__path_esc=") @@ -9,8 +11,21 @@ class TestSshfs: def test_1(self, completion): assert completion - @pytest.mark.complete("sshfs local_path", cwd="sshfs") - def test_local_path_suffix_1(self, completion): + @pytest.fixture + def tmpdir_backslash(self, request, bash): + if sys.platform.startswith("win"): + pytest.skip("Filenames not allowed on Windows") + + tmpdir, _, _ = prepare_fixture_dir( + request, files=["local_path-file\\"], dirs=["local_path-dir"] + ) + return tmpdir + + def test_local_path_suffix_1(self, bash, tmpdir_backslash): + completion = assert_complete( + bash, "sshfs local_path", cwd=tmpdir_backslash + ) + assert completion == "-dir/" def test_remote_path_ending_with_backslash(self, bash):