diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:22:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:22:56 +0000 |
commit | dcf7f37a77e03d9c44f34fd2a5bd88eed6c09cad (patch) | |
tree | 759977c3a6a9a01b0d9c1bae0b81b7e0c1543a01 /tests | |
parent | Adding upstream version 0.1.45. (diff) | |
download | debputy-dcf7f37a77e03d9c44f34fd2a5bd88eed6c09cad.tar.xz debputy-dcf7f37a77e03d9c44f34fd2a5bd88eed6c09cad.zip |
Adding upstream version 0.1.46.upstream/0.1.46
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/test_install_rules.py | 37 | ||||
-rw-r--r-- | tests/test_utils.py | 20 |
2 files changed, 45 insertions, 12 deletions
diff --git a/tests/test_install_rules.py b/tests/test_install_rules.py index e94e8bc..ecc49fd 100644 --- a/tests/test_install_rules.py +++ b/tests/test_install_rules.py @@ -9,6 +9,7 @@ from debputy.installations import ( SearchDir, ) from debputy.plugin.api import virtual_path_def +from debputy.plugin.api.spec import INTEGRATION_MODE_DH_DEBPUTY from debputy.plugin.api.test_api import build_virtual_file_system @@ -118,13 +119,14 @@ def test_install_rules(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -207,12 +209,13 @@ def test_multi_dest_install_rules(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_source_root_dir, all_pkgs), ], [], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -300,13 +303,14 @@ def test_install_rules_with_glob(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -365,13 +369,14 @@ def test_install_rules_auto_discard_rules_dir(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -424,13 +429,14 @@ def test_install_rules_auto_discard_rules_glob(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -490,13 +496,14 @@ def test_install_rules_auto_discard_rules_overruled_by_explicit_install_rule( all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -559,13 +566,14 @@ def test_install_rules_install_as_with_var(manifest_parser_pkg_foo) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root @@ -610,13 +618,14 @@ def test_install_rules_no_matches(manifest_parser_pkg_foo) -> None: with pytest.raises(NoMatchForInstallPatternError) as e_info: manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_dir, all_pkgs), SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_dir], - ) + ), ) expected_msg = ( "There were no matches for build/private-arch-tool in /nowhere/debian/tmp, /nowhere" @@ -719,6 +728,7 @@ def test_install_rules_per_package_search_dirs(manifest_parser_pkg_foo_w_udeb) - all_udeb_pkgs = frozenset({p for p in all_pkgs if p.is_udeb}) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_tmp_deb_dir, all_deb_pkgs), @@ -726,7 +736,7 @@ def test_install_rules_per_package_search_dirs(manifest_parser_pkg_foo_w_udeb) - SearchDir(debian_source_root_dir, all_pkgs), ], [debian_tmp_deb_dir], - ) + ), ) for pkg, ptype in [ ("foo", "deb"), @@ -820,12 +830,13 @@ def test_install_rules_multi_into(manifest_parser_pkg_foo_w_udeb) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_source_root_dir, all_pkgs), ], [], - ) + ), ) for pkg in ["foo", "foo-udeb"]: assert pkg in result @@ -939,6 +950,7 @@ def test_auto_install_d_pkg(manifest_parser_pkg_foo_w_udeb) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_source_root_dir, all_pkgs), @@ -948,7 +960,7 @@ def test_auto_install_d_pkg(manifest_parser_pkg_foo_w_udeb) -> None: "foo": debian_foo_dir, "foo-udeb": debian_foo_udeb_dir, }, - ) + ), ) for pkg in ["foo", "foo-udeb"]: assert pkg in result @@ -1024,12 +1036,13 @@ def test_install_doc_rules_ignore_udeb(manifest_parser_pkg_foo_w_udeb) -> None: all_pkgs = frozenset(manifest.all_packages) result = manifest.perform_installations( + INTEGRATION_MODE_DH_DEBPUTY, install_request_context=InstallSearchDirContext( [ SearchDir(debian_source_root_dir, all_pkgs), ], [], - ) + ), ) assert "foo" in result foo_fs_root = result["foo"].fs_root diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..e1dc87e --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,20 @@ +from typing import Sequence, Union + +import pytest + +from debputy.util import escape_shell + + +@pytest.mark.parametrize( + "arg,expected", + [ + ("foo bar", '"foo bar"'), + ("a'b", r"""a\'b"""), + ("foo=bar and baz", 'foo="bar and baz"'), + ("--foo=bar and baz", '--foo="bar and baz"'), + ("--foo with spaces=bar and baz", '"--foo with spaces=bar and baz"'), + ], +) +def test_symlink_normalization(arg: Union[str, Sequence[str]], expected: str) -> None: + actual = escape_shell(arg) if isinstance(arg, str) else escape_shell(*arg) + assert actual == expected |