From d77f50aab8f7727eebcfb122a10607f2f9f7d835 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 4 Jan 2024 14:30:01 +0000 Subject: Isolate tests from a local repodir This fixes the tests if a local /git/cygwin-packages happens to exist, and adds some test coverage of code which examines repodir. --- calm/calm.py | 2 ++ calm/package.py | 15 ++++++++------- calm/pkg2html.py | 9 +++++---- test/test_calm.py | 2 ++ test/testdata/htdocs.expected/summary/cygwin-src.html | 1 + test/testdata/process_arch/packages.json.expected | 1 + test/testdata/repodir/cygwin.git/cygwin.cygport | 0 7 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 test/testdata/repodir/cygwin.git/cygwin.cygport diff --git a/calm/calm.py b/calm/calm.py index c0926e0..69fb923 100755 --- a/calm/calm.py +++ b/calm/calm.py @@ -861,6 +861,7 @@ def main(): pidfile_default = '/sourceware/cygwin-staging/calm.pid' pkglist_default = common_constants.PKGMAINT relarea_default = common_constants.FTP + repodir_default = '/git/cygwin-packages' setupdir_default = common_constants.HTDOCS vault_default = common_constants.VAULT logdir_default = '/sourceware/cygwin-staging/logs' @@ -877,6 +878,7 @@ def main(): parser.add_argument('--pkglist', action='store', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", default=pkglist_default) parser.add_argument('--release', action='store', help='value for setup-release key (default: cygwin)', default='cygwin') parser.add_argument('--releasearea', action='store', metavar='DIR', help="release directory (default: " + relarea_default + ")", default=relarea_default, dest='rel_area') + parser.add_argument('--repodir', action='store', metavar='DIR', help="packaging repositories directory (default: " + repodir_default + ")", default=repodir_default) parser.add_argument('--setupdir', action='store', metavar='DIR', help="setup executable directory (default: " + setupdir_default + ")", default=setupdir_default) parser.add_argument('--stagingdir', action='store', metavar='DIR', help="automated build staging directory (default: " + stagingdir_default + ")", default=stagingdir_default) parser.add_argument('--no-stale', action='store_false', dest='stale', help="don't vault stale packages") diff --git a/calm/package.py b/calm/package.py index d135d80..f84d494 100755 --- a/calm/package.py +++ b/calm/package.py @@ -1396,12 +1396,13 @@ def upper_first_character(s): # # -def _find_build_recipe_file(pn): - repo = '/git/cygwin-packages/%s.git' % pn - if os.path.exists(repo): - # XXX: we might want to check contents of the repo to determine if this - # package has a cygport or g-b-s build script - return 'https://cygwin.com/cgit/cygwin-packages/%s/tree/%s.cygport' % (pn, pn) +def _find_build_recipe_file(args, pn): + if args.repodir: + repo = os.path.join(args.repodir, '%s.git' % pn) + if os.path.exists(repo): + # XXX: we might want to check contents of the repo to determine if this + # package has a cygport or g-b-s build script + return 'https://cygwin.com/cgit/cygwin-packages/%s/tree/%s.cygport' % (pn, pn) return None @@ -1457,7 +1458,7 @@ def write_repo_json(args, packages, f): if 'license' in po.version_hints[bv]: d['license'] = po.version_hints[bv]['license'] - build_recipe = _find_build_recipe_file(po.orig_name) + build_recipe = _find_build_recipe_file(args, po.orig_name) if build_recipe: d['build_recipe'] = build_recipe diff --git a/calm/pkg2html.py b/calm/pkg2html.py index 43591ff..5a3f4ac 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -293,10 +293,11 @@ def update_package_listings(args, packages): print('

', file=f) if po.kind == package.Kind.source: - repo = '/git/cygwin-packages/%s.git' % pn - if os.path.exists(repo): - repo_browse_url = '/cgit/cygwin-packages/%s/' % pn - print('packaging repository: %s.git' % (repo_browse_url, pn), file=f) + if args.repodir: + repo = os.path.join(args.repodir, '%s.git' % pn) + if os.path.exists(repo): + repo_browse_url = '/cgit/cygwin-packages/%s/' % pn + print('packaging repository: %s.git' % (repo_browse_url, pn), file=f) print('