def test_non_standard_variable_substitution(self): pkgbuild = FileMock(""" _pkgname=Foobar sources=($_pkgname.tar.gz) """) target = parched.PKGBUILD(fileobj=pkgbuild) self.assertEqual(["Foobar.tar.gz"], target.sources)
def test_skip_function(self): pkgbuild = FileMock(""" pkgname=foo build() { pkgname=bar } """) target = parched.PKGBUILD(fileobj=pkgbuild) self.assertEqual("foo", target.name)
def test_quoted_value(self): """Right-hand side of assignment in quotes is parsed correctly.""" self.package.description = "Someone's package" self.package.url = "'http://domain.tld/foo'" target = parched.PKGBUILD(fileobj=self.package.as_file()) pkgbuild = self.package.as_file().read() self.assertTrue("pkgdesc=\"Someone's package\"" in pkgbuild) self.assertTrue("url='http://domain.tld/foo'" in pkgbuild) self.assertEqual(self.package.description, "Someone's package") self.assertEqual(self.package.url.strip("'"), target.url)
def test_substitution(self): self.package.sources = [ '$url/files/$pkgname-$pkgver.tar.gz', '${url}/files/${pkgname}_doc-$pkgver.tar.gz' ] target = parched.PKGBUILD(fileobj=self.package.as_file()) values = (self.package.url, self.package.name, self.package.version) parsed_sources = [ '%s/files/%s-%s.tar.gz' % values, '%s/files/%s_doc-%s.tar.gz' % values, ] self.assertEqual(parsed_sources, target.sources)
def test_multiline(self): pkgbuild = FileMock() pkgbuild.write(""" source=(foo \\ baz) depends=(eggs \\ spam\\ pancakes) makedepends(funky_town # got to get funky! pan) """) target = parched.PKGBUILD(fileobj=pkgbuild) self.assertEqual(['foo', 'baz'], target.sources) self.assertEqual(['eggs', 'spam', 'pancakes'], target.depends)
def test_sane_package(self): target = parched.PKGBUILD(fileobj=self.package.as_file()) self.assertEqual(self.package.name, target.name) self.assertEqual(self.package.version, target.version) self.assertEqual(self.package.release, target.release) self.assertEqual(self.package.description, target.description) self.assertEqual(self.package.url, target.url) self.assertEqual(self.package.groups, target.groups) self.assertEqual(self.package.licenses, target.licenses) self.assertEqual(self.package.architectures, target.architectures) self.assertEqual(self.package.replaces, target.replaces) self.assertEqual(self.package.conflicts, target.conflicts) self.assertEqual(self.package.provides, target.provides) self.assertEqual(self.package.backup, target.backup) self.assertEqual(self.package.options, target.options) self.assertEqual(self.package.noextract, target.noextract) self.assertEqual(self.package.makedepends, target.makedepends) self.assertEqual(self.package.sources, target.sources) self.assertEqual(self.package.optdepends, target.optdepends) self.assertEqual(self.package.checksums, target.checksums) self.assertEqual(self.package.install, target.install)