diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index cbfb021..52377b0 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -366,7 +366,7 @@ class AutopkgtestPolicy(BasePolicy): self.logger.info('%s is uninstallable on arch %s, not running autopkgtest there', source_name, arch) excuse.addinfo("uninstallable on arch %s, not running autopkgtest there" % arch) else: - self.request_tests_for_source(item, arch, source_data_srcdist, pkg_arch_result) + self.request_tests_for_source(item, arch, source_data_srcdist, pkg_arch_result, excuse) # add test result details to Excuse cloud_url = self.options.adt_ci_url + "packages/%(h)s/%(s)s/%(r)s/%(a)s" @@ -479,7 +479,7 @@ class AutopkgtestPolicy(BasePolicy): return False - def request_tests_for_source(self, item, arch, source_data_srcdist, pkg_arch_result): + def request_tests_for_source(self, item, arch, source_data_srcdist, pkg_arch_result, excuse): pkg_universe = self.britney.pkg_universe target_suite = self.suite_info.target_suite source_suite = item.suite @@ -488,7 +488,7 @@ class AutopkgtestPolicy(BasePolicy): source_name = item.package source_version = source_data_srcdist.version # request tests (unless they were already requested earlier or have a result) - tests = self.tests_for_source(source_name, source_version, arch) + tests = self.tests_for_source(source_name, source_version, arch, excuse) is_huge = False try: is_huge = len(tests) > int(self.options.adt_huge) @@ -598,7 +598,7 @@ class AutopkgtestPolicy(BasePolicy): (result, real_ver, run_id, url) = self.pkg_test_result(testsrc, testver, arch, trigger) pkg_arch_result[(testsrc, real_ver)][arch] = (result, run_id, url) - def tests_for_source(self, src, ver, arch): + def tests_for_source(self, src, ver, arch, excuse): '''Iterate over all tests that should be run for given source and arch''' source_suite = self.suite_info.primary_source_suite @@ -642,8 +642,10 @@ class AutopkgtestPolicy(BasePolicy): return [] # we want to test the package itself, if it still has a test in unstable + # but only if the package actually exists on this arch srcinfo = source_suite.sources[src] - if 'autopkgtest' in srcinfo.testsuite or self.has_autodep8(srcinfo): + if ('autopkgtest' in srcinfo.testsuite or self.has_autodep8(srcinfo)) and \ + len(excuse.packages[arch]) > 0: reported_pkgs.add(src) tests.append((src, ver)) diff --git a/tests/test_policy.py b/tests/test_policy.py index 80bdd59..e6d4f80 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -68,8 +68,11 @@ def initialize_policy(test_name, policy_class, *args, **kwargs): return policy -def create_excuse(name): - return Excuse(name) +def create_excuse(name, pkgs): + excuse = Excuse(name) + for pkg_id in pkgs: + excuse.add_package(pkg_id) + return excuse def create_source_package(name, version, section='devel', binaries=None): @@ -100,11 +103,11 @@ def create_bin_package(pkg_id, source_name=None, depends=None, conflicts=None): ) -def create_policy_objects(source_name, target_version='1.0', source_version='2.0'): +def create_policy_objects(source_name, target_version='1.0', source_version='2.0', pkgs={}): return ( create_source_package(source_name, target_version), create_source_package(source_name, source_version), - create_excuse(source_name), + create_excuse(source_name, pkgs), ) @@ -113,7 +116,7 @@ def apply_src_policy(policy, expected_verdict, src_name, *, suite='unstable', ta if src_name in suite_info[suite].sources: src_u = suite_info[suite].sources[src_name] src_t = suite_info.target_suite.sources.get(src_name) - _, _, excuse = create_policy_objects(src_name) + _, _, excuse = create_policy_objects(src_name, pkgs=src_u.binaries) else: src_t, src_u, excuse = create_policy_objects(src_name, target_version, source_version) suite_info.target_suite.sources[src_name] = src_t