Bug 13636

Summary: recipetool unbound variable when reproducible_build class is inherited
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Richard Purdie <richard.purdie>
Component: devtools / tool chainAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: High CC: meta.mr.watcher, meta.watcher, randy.macleod
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

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.