aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-02-10 15:23:48 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2023-02-21 04:46:55 +0200
commit5ceda81ab79a560c8dcccfab64733cc587c00d20 (patch)
tree01de2151a10a33eb050d9637be2ff117d967f3a8
parent8ea35ee2db5330955a048d11690850f97987f4f7 (diff)
Add tests for system_package_manager::system_package_version()
-rw-r--r--bpkg/system-package-manager.test.cxx28
-rw-r--r--bpkg/system-package-manager.test.testscript39
2 files changed, 67 insertions, 0 deletions
diff --git a/bpkg/system-package-manager.test.cxx b/bpkg/system-package-manager.test.cxx
index 1a669da..d2d02cb 100644
--- a/bpkg/system-package-manager.test.cxx
+++ b/bpkg/system-package-manager.test.cxx
@@ -25,6 +25,10 @@ namespace bpkg
//
// Where <pkg> is a package name, <file> is a package manifest file.
//
+ // system-package-version <name-id> <ver-id> [<like-id>...] -- <pkg> <file>
+ //
+ // Where <pkg> is a package name, <file> is a package manifest file.
+ //
// downstream-package-version <name-id> <ver-id> [<like-id>...] -- <ver> <pkg> <file>...
//
// Where <ver> is a system version to translate, <pkg> is a package
@@ -41,6 +45,7 @@ namespace bpkg
os_release osr;
if (cmd == "system-package-names" ||
+ cmd == "system-package-version" ||
cmd == "downstream-package-version")
{
assert (argc >= 4); // <name-id> <ver-id>
@@ -81,6 +86,29 @@ namespace bpkg
for (const string& n: ns)
cout << n << '\n';
}
+ else if (cmd == "system-package-version")
+ {
+ assert (argi != argc); // --
+ string a (argv[argi++]);
+ assert (a == "--");
+
+ assert (argi != argc); // <pkg>
+ string pn (argv[argi++]);
+
+ assert (argi != argc); // <file>
+ pair<shared_ptr<available_package>,
+ lazy_shared_ptr<repository_fragment>> apf (
+ make_available_from_manifest (pn, argv[argi++]));
+
+ assert (argi == argc); // No trailing junk.
+
+ if (optional<string> v =
+ system_package_manager::system_package_version (
+ apf.first, apf.second, osr.name_id, osr.version_id, osr.like_ids))
+ {
+ cout << *v << '\n';
+ }
+ }
else if (cmd == "downstream-package-version")
{
assert (argi != argc); // --
diff --git a/bpkg/system-package-manager.test.testscript b/bpkg/system-package-manager.test.testscript
index dc672f5..4744a82 100644
--- a/bpkg/system-package-manager.test.testscript
+++ b/bpkg/system-package-manager.test.testscript
@@ -45,6 +45,45 @@
EOO
}
+: system-package-version
+:
+{
+ test.arguments += system-package-version
+
+ : basics
+ :
+ cat <<EOI >=libssl1.1.1+19.manifest;
+ : 1
+ name: libssl
+ version: 1.1.1+19
+ fedora-name: openssl-libs
+ fedora-version: 1:1.1.1q-1
+ fedora_35-version: 1:1.1.1q-1.fc35
+ fedora_36-version: 1:1.1.1q-1.fc36
+ summary: openssl
+ license: openssl
+ EOI
+
+ $* fedora 34 -- libssl libssl1.1.1+19.manifest >>EOO;
+ 1:1.1.1q-1
+ EOO
+ $* fedora 35 -- libssl libssl1.1.1+19.manifest >>EOO;
+ 1:1.1.1q-1.fc35
+ EOO
+ $* fedora 36 -- libssl libssl1.1.1+19.manifest >>EOO;
+ 1:1.1.1q-1.fc36
+ EOO
+ $* fedora 37 -- libssl libssl1.1.1+19.manifest >>EOO;
+ 1:1.1.1q-1.fc36
+ EOO
+ $* fedora '' -- libssl libssl1.1.1+19.manifest >>EOO;
+ 1:1.1.1q-1
+ EOO
+ $* rhel 7.8 fedora -- libssl libssl1.1.1+19.manifest >>EOO
+ 1:1.1.1q-1
+ EOO
+}
+
: downstream-package-version
:
{