Bug 13636 - recipetool unbound variable when reproducible_build class is inherited
Summary: recipetool unbound variable when reproducible_build class is inherited
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 3.0
Hardware: x86 Multiple
: High normal
Target Milestone: 3.1 M1
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-11-18 12:27 UTC by Richard Purdie
Modified: 2019-11-23 14:44 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Purdie 2019-11-18 12:27:14 UTC
https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/481

There were a ton of failures when:

INHERIT += "reproducible_build"

was added. This bug covers the recipetool unbound variable selftest failures

2019-11-16 23:04:29,884 - oe-selftest - INFO - ======================================================================
2019-11-16 23:04:29,884 - oe-selftest - INFO - ERROR: recipetool.RecipetoolTests.test_recipetool_create_git_http (subunit.RemotedTestCase)
2019-11-16 23:04:29,884 - oe-selftest - INFO - ----------------------------------------------------------------------
2019-11-16 23:04:29,884 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/recipetool.py", line 503, in test_recipetool_create_git_http
    self._test_recipe_contents(recipefile, checkvars, inherits)
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/devtool.py", line 182, in _test_recipe_contents
    self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit)
UnboundLocalError: local variable 'inherits' referenced before assignment


2019-11-16 23:04:29,884 - oe-selftest - INFO - ======================================================================
2019-11-16 23:04:29,884 - oe-selftest - INFO - ERROR: recipetool.RecipetoolTests.test_recipetool_create_github_tarball (subunit.RemotedTestCase)
2019-11-16 23:04:29,884 - oe-selftest - INFO - ----------------------------------------------------------------------
2019-11-16 23:04:29,885 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/recipetool.py", line 489, in test_recipetool_create_github_tarball
    self._test_recipe_contents(recipefile, checkvars, inherits)
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/devtool.py", line 182, in _test_recipe_contents
    self.assertIn(inherit, inherits, 'Missing inherit of %s' % inherit)
UnboundLocalError: local variable 'inherits' referenced before assignment
Comment 1 Richard Purdie 2019-11-18 15:19:39 UTC
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index 3a25da2033b..365a57c4f53 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -137,6 +137,7 @@ class DevtoolBase(OESelftestTestCase):
         with open(recipefile, 'r') as f:
             invar = None
             invalue = None
+            inherits = set()
             for line in f:
                 var = None
                 if invar:
@@ -158,7 +159,7 @@ class DevtoolBase(OESelftestTestCase):
                         invar = var
                         continue
                 elif line.startswith('inherit '):
-                    inherits = line.split()[1:]
+                    inherits.add(line.split()[1:])
 
                 if var and var in checkvars:
                     needvalue = checkvars.pop(var)

then the error becomes:

AssertionError: 'pkgconfig' not found in set() : Missing inherit of pkgconfig
Comment 2 Richard Purdie 2019-11-18 16:29:34 UTC
Patches on the mailing list for this issue.
Comment 3 Randy MacLeod 2019-11-21 15:44:53 UTC
There is a patch in review.