args.cache: remove (MR 2136)

Replace "args.cache" with a global variable in order to
avoid passing "args" to all functions. This is a step to get rid of this
args-passed-to-all-functions pattern in pmbootstrap.
This commit is contained in:
BO41 2021-10-30 14:20:57 +02:00 committed by Oliver Smith
parent f30b1cc3f2
commit ce0f1c2d4a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
23 changed files with 127 additions and 115 deletions

View file

@ -86,7 +86,7 @@ def test_helpers_package_depends_recurse(args):
"b": {False: {"pkgname": "b", "depends": []}},
"c": {False: {"pkgname": "c", "depends": ["d"]}},
"d": {False: {"pkgname": "d", "depends": ["b"]}}}
args.cache["pmb.helpers.package.get"]["armhf"] = cache
pmb.helpers.other.cache["pmb.helpers.package.get"]["armhf"] = cache
# Normal runs
func = pmb.helpers.package.depends_recurse
@ -94,7 +94,7 @@ def test_helpers_package_depends_recurse(args):
assert func(args, "d", "armhf") == ["b", "d"]
# Cached result
args.cache["pmb.helpers.package.get"]["armhf"] = {}
pmb.helpers.other.cache["pmb.helpers.package.get"]["armhf"] = {}
assert func(args, "d", "armhf") == ["b", "d"]
@ -103,7 +103,7 @@ def test_helpers_package_check_arch_package(args):
# Put fake data into the pmb.helpers.package.get() cache
func = pmb.helpers.package.check_arch
cache = {"a": {False: {"arch": []}}}
args.cache["pmb.helpers.package.get"]["armhf"] = cache
pmb.helpers.other.cache["pmb.helpers.package.get"]["armhf"] = cache
cache["a"][False]["arch"] = ["all !armhf"]
assert func(args, "a", "armhf") is False