<pre style='margin:0'>
Renee Otten (reneeotten) pushed a commit to branch master
in repository upt-macports.
</pre>
<p><a href="https://github.com/macports/upt-macports/commit/7f79c06d8bd8830b493105e370f8af78b2066d8a">https://github.com/macports/upt-macports/commit/7f79c06d8bd8830b493105e370f8af78b2066d8a</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 7f79c06 Perl portfile updated and add tests
</span>7f79c06 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 7f79c06d8bd8830b493105e370f8af78b2066d8a
</span>Author: Korusuke <karan.sheth@somaiya.edu>
AuthorDate: Thu May 30 00:58:43 2019 +0530
<span style='display:block; white-space:pre;color:#404040;'> Perl portfile updated and add tests
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Fixes #17
</span>---
setup.cfg | 3 +++
upt_macports/templates/perl.Portfile | 30 +++++++++++++++++++---
upt_macports/tests/test_perl_package.py | 45 +++++++++++++++++++++++++++++++++
upt_macports/upt_macports.py | 27 +++++++++++++++++++-
4 files changed, 101 insertions(+), 4 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/setup.cfg b/setup.cfg
</span><span style='display:block; white-space:pre;color:#808080;'>index 17c1183..0c7dc62 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/setup.cfg
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/setup.cfg
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -17,6 +17,7 @@ classifiers =
</span> [options]
packages = find:
install_requires =
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ requests
</span> upt
jinja2
include_package_data = true
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -27,3 +28,5 @@ upt.backends =
</span>
[options.extras_require]
test =
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ requests-mock
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>\ No newline at end of file
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/templates/perl.Portfile b/upt_macports/templates/perl.Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index c7d64e4..4dc3f3c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/upt_macports/templates/perl.Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/templates/perl.Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -5,16 +5,40 @@ PortGroup perl5 1.0
</span> {% endblock %}
{% block nameversion %}
perl5.branches 5.26 5.28
<span style='display:block; white-space:pre;background:#ffe0e0;'>-perl5.setup {{ pkg._pkgname() }} {{ pkg.upt_pkg.version }}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+perl5.setup {{ pkg._pkgname() }} {{ pkg.upt_pkg.version }}{{ pkg._cpandir() }}
</span> revision 0
{% endblock %}
{% block versions %}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+{%- if pkg.upt_pkg.requirements.run or pkg.upt_pkg.requirements.test or pkg.upt_pkg.requirements.build or pkg.upt_pkg.requirements.config %}
</span> if {${perl5.major} != ""} {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ {%- if pkg.upt_pkg.requirements.config or pkg.upt_pkg.requirements.build %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ depends_build-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% for i in (pkg.upt_pkg.requirements.build + pkg.upt_pkg.requirements.config)|sort(attribute='name')|unique(attribute='name') %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:p${perl5.major}-{{i.name|replace('::','-')|lower}}{% if not loop.last %} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endfor %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% if pkg.upt_pkg.requirements.run %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> depends_lib-append \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- {% for i in pkg.upt_pkg.requirements.run %}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- port:p${perl5.major}-{{i.name|replace('::','-')|lower}} {% if loop.index != pkg.upt_pkg.requirements.run|length %}\{% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% for i in pkg.upt_pkg.requirements.run|sort(attribute='name') %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:p${perl5.major}-{{i.name|replace('::','-')|lower}}{% if not loop.last %} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endfor %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% if pkg.upt_pkg.requirements.test %}
</span>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ depends_test-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% for i in pkg.upt_pkg.requirements.test|sort(attribute='name') %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ port:p${perl5.major}-{{i.name|replace('::','-')|lower}}{% if not loop.last %} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span> {% endfor %}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ {% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+{% endif %}
</span> {% endblock %}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/tests/test_perl_package.py b/upt_macports/tests/test_perl_package.py
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..bd7f891
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/tests/test_perl_package.py
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,45 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import unittest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import requests_mock
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import upt
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+from upt_macports.upt_macports import MacPortsPerlPackage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+class TestMacPortsPerlPackage(unittest.TestCase):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def setUp(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package = MacPortsPerlPackage()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg = upt.Package('Foo-Bar', '13.37')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.archives = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upt.Archive("https://democpan.org/authors/id/F/FO/FOOBAR/Foo-Bar-13.37.tar.gz")] # noqa
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.check_url = "https://cpan.metacpan.org/modules/by-module/Foo/Foo-Bar-13.37.tar.gz" # noqa
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_pkgname(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = ['Foo-bar', 'foo-bar', 'Foo-bar', 'foo-bar']
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ names = ['Foo::bar', 'foo::bar', 'Foo-bar', 'foo-bar']
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for (name, expected_name) in zip(names, expected):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg = upt.Package(name, '13.37')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package._pkgname(), expected_name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ @requests_mock.mock()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_missing_dist_pos1(self, requests):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = ' ../../authors/id/F/FO/FOOBAR/'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ requests.head(self.check_url, status_code=400)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package._cpandir(), expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ @requests_mock.mock()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_distfile_found(self, requests):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = ''
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ requests.head(self.check_url, status_code=200)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package._cpandir(), expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ @requests_mock.mock()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_missing_distfile(self, requests):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = ' # could not locate dist file'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.archives = []
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package._cpandir(), expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if __name__ == '__main__':
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unittest.main()
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;color:#808080;'>index 56c8ce3..d29df7f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3,6 +3,7 @@ import logging
</span> import jinja2
import pkg_resources
import json
<span style='display:block; white-space:pre;background:#e0ffe0;'>+import requests
</span>
class MacPortsPackage(object):
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -104,7 +105,31 @@ class MacPortsPerlPackage(MacPortsPackage):
</span>
@staticmethod
def _normalized_macports_name(name):
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return name.replace('::', '-')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def _cpandir(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pkg = self.upt_pkg
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # If no archives detected then we cannot locate dist file
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if not pkg.archives:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.logger.warning('No dist file was found')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ' # could not locate dist file'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # We start by checking at usual location
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ archive_name = pkg.archives[0].url.split('/')[-1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ part_name = pkg.name.replace('::', '-').split('-')[0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ check_url = f'https://cpan.metacpan.org/modules/by-module/{part_name}/{archive_name}' # noqa
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ r = requests.head(check_url)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if r.status_code == 200:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.logger.info('Dist file found at usual location')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ''
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ else:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Sometimes if it is not available,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # then we fallback to alternate location
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # to be verified by the maintainer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fallback_dist = '/'.join(pkg.archives[0].url.split('id/')[1].split('/')[:-1]) # noqa
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.logger.info('Dist file was not found at usual location')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.logger.info('Using fallback location for dist file')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return f' ../../authors/id/{fallback_dist}/'
</span>
class MacPortsRubyPackage(MacPortsPackage):
</pre><pre style='margin:0'>
</pre>