mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
selftest/fetch: Avoid occasional selftest failure from poor temp file name choice
The temp file name may contain "_" characters. Switch to a temporary directory
and a fixed filename to avoid this to avoid errors like:
bb.data_smart.ExpansionError: Failure expanding variable PN, expression was
${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}
which triggered exception ParseError:
ParseError in /tmp/tmpd_f2__to.bb: Unable to generate default variables from
filename (too many underscores)
(From OE-Core rev: 8c2d92f855fe0d692228f7ebf7e7b116195ccf0c)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 086e2ae7b2b7496b4f3ae01436b4049d7f2ff8c4)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -55,25 +55,26 @@ MIRRORS_forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/so
|
|||||||
|
|
||||||
|
|
||||||
class Dependencies(OESelftestTestCase):
|
class Dependencies(OESelftestTestCase):
|
||||||
def write_recipe(self, content):
|
def write_recipe(self, content, tempdir):
|
||||||
f = tempfile.NamedTemporaryFile(mode="wt", suffix=".bb")
|
f = os.path.join(tempdir, "test.bb")
|
||||||
f.write(content)
|
with open(f, "w") as fd:
|
||||||
f.flush()
|
fd.write(content)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def test_dependencies(self):
|
def test_dependencies(self):
|
||||||
"""
|
"""
|
||||||
Verify that the correct dependencies are generated for specific SRC_URI entries.
|
Verify that the correct dependencies are generated for specific SRC_URI entries.
|
||||||
"""
|
"""
|
||||||
with bb.tinfoil.Tinfoil() as tinfoil:
|
|
||||||
|
with bb.tinfoil.Tinfoil() as tinfoil, tempfile.TemporaryDirectory(prefix="selftest-fetch") as tempdir:
|
||||||
tinfoil.prepare(config_only=False, quiet=2)
|
tinfoil.prepare(config_only=False, quiet=2)
|
||||||
|
|
||||||
r = """
|
r = """
|
||||||
LICENSE="CLOSED"
|
LICENSE="CLOSED"
|
||||||
SRC_URI="http://example.com/tarball.zip"
|
SRC_URI="http://example.com/tarball.zip"
|
||||||
"""
|
"""
|
||||||
f = self.write_recipe(textwrap.dedent(r))
|
f = self.write_recipe(textwrap.dedent(r), tempdir)
|
||||||
d = tinfoil.parse_recipe_file(f.name)
|
d = tinfoil.parse_recipe_file(f)
|
||||||
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
||||||
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends"))
|
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends"))
|
||||||
|
|
||||||
@@ -82,8 +83,8 @@ class Dependencies(OESelftestTestCase):
|
|||||||
LICENSE="CLOSED"
|
LICENSE="CLOSED"
|
||||||
SRC_URI="https://example.com/tarball;downloadfilename=something.zip"
|
SRC_URI="https://example.com/tarball;downloadfilename=something.zip"
|
||||||
"""
|
"""
|
||||||
f = self.write_recipe(textwrap.dedent(r))
|
f = self.write_recipe(textwrap.dedent(r), tempdir)
|
||||||
d = tinfoil.parse_recipe_file(f.name)
|
d = tinfoil.parse_recipe_file(f)
|
||||||
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
||||||
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "")
|
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "")
|
||||||
|
|
||||||
@@ -91,8 +92,8 @@ class Dependencies(OESelftestTestCase):
|
|||||||
LICENSE="CLOSED"
|
LICENSE="CLOSED"
|
||||||
SRC_URI="ftp://example.com/tarball.lz"
|
SRC_URI="ftp://example.com/tarball.lz"
|
||||||
"""
|
"""
|
||||||
f = self.write_recipe(textwrap.dedent(r))
|
f = self.write_recipe(textwrap.dedent(r), tempdir)
|
||||||
d = tinfoil.parse_recipe_file(f.name)
|
d = tinfoil.parse_recipe_file(f)
|
||||||
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
|
||||||
self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends"))
|
self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends"))
|
||||||
|
|
||||||
@@ -100,6 +101,6 @@ class Dependencies(OESelftestTestCase):
|
|||||||
LICENSE="CLOSED"
|
LICENSE="CLOSED"
|
||||||
SRC_URI="git://example.com/repo"
|
SRC_URI="git://example.com/repo"
|
||||||
"""
|
"""
|
||||||
f = self.write_recipe(textwrap.dedent(r))
|
f = self.write_recipe(textwrap.dedent(r), tempdir)
|
||||||
d = tinfoil.parse_recipe_file(f.name)
|
d = tinfoil.parse_recipe_file(f)
|
||||||
self.assertIn("git-native", d.getVarFlag("do_fetch", "depends"))
|
self.assertIn("git-native", d.getVarFlag("do_fetch", "depends"))
|
||||||
|
|||||||
Reference in New Issue
Block a user