18400 pkglint output is still not deterministic
authorTim Foster <tim.s.foster@oracle.com>
Fri, 27 May 2011 12:00:45 +1200
changeset 2383 cfc3e2182a1d
parent 2382 b91a97e46434
child 2384 c1e983ee5f4c
18400 pkglint output is still not deterministic
src/modules/lint/engine.py
src/pkg/Makefile
src/pkg/pkglint_whitelist.txt
src/tests/cli/t_pkglint.py
--- a/src/modules/lint/engine.py	Thu May 26 16:25:57 2011 -0700
+++ b/src/modules/lint/engine.py	Fri May 27 12:00:45 2011 +1200
@@ -155,7 +155,7 @@
                         raise LintException("Cache has not been seeded")
 
                 if api_inst in self.latest_cache:
-                        for item in self.latest_cache[api_inst]:
+                        for item in sorted(self.latest_cache[api_inst]):
                                 mf = self.latest_cache[api_inst][item]
                                 if pattern and pkg.fmri.glob_match(
                                     str(mf.fmri), pattern):
@@ -506,7 +506,7 @@
                 self.ref_uris = ref_uris
                 self.lint_uris = lint_uris
                 self.lint_manifests = lint_manifests
-                self.lint_manifests.sort()
+                self.lint_manifests.sort(key=_manifest_sort_key)
                 self.pattern = pattern
                 self.release = release
                 self.in_setup = True
@@ -1075,3 +1075,11 @@
 
         # everything is equal, or old has no version and we'll favour new
         return True
+
+def _manifest_sort_key(mf):
+        """The lint engine uses the FMRI of a package to deterine the order in
+        which to iterate over manifests.  This is done using the 'key' attribute
+        to the Python sort() and sorted() methods."""
+        if mf.fmri:
+                return mf.fmri
+        return mf.get("pkg.fmri")
--- a/src/pkg/Makefile	Thu May 26 16:25:57 2011 -0700
+++ b/src/pkg/Makefile	Fri May 27 12:00:45 2011 +1200
@@ -178,7 +178,7 @@
 	@rm -rf $(PDIR)/pkglint-cache
 	@rm -f $(PDIR)/pkglint-out*
 	@if [ -n "$(PKGLINT_REF_REPO)" ]; then				\
-		$(PKGLINT) -f $(PDIR)/pkglintrc -c $(PDIR)/pkglint-cache\
+		env LC_ALL=C $(PKGLINT) -f $(PDIR)/pkglintrc -c $(PDIR)/pkglint-cache\
 			-r $(PKGLINT_REF_REPO) -l file://$(PKGDEST)/repo; \
 	fi
 	-@if [ -z "$(PKGLINT_REF_REPO)" ]; then 			\
--- a/src/pkg/pkglint_whitelist.txt	Thu May 26 16:25:57 2011 -0700
+++ b/src/pkg/pkglint_whitelist.txt	Fri May 27 12:00:45 2011 +1200
@@ -1,11 +1,3 @@
-ERROR opensolaris.manifest001.2   Missing attribute 'pkg.summary' in pkg://pkg5-nightly/auto_install
-ERROR opensolaris.manifest001.2   Missing attribute 'pkg.summary' in pkg://pkg5-nightly/babel_install
-ERROR opensolaris.manifest001.2   Missing attribute 'pkg.summary' in pkg://pkg5-nightly/server_install
-ERROR opensolaris.manifest001.2   Missing attribute 'pkg.summary' in pkg://pkg5-nightly/slim_install
-WARNING opensolaris.manifest001.1 Missing attribute 'info.classification' in pkg://pkg5-nightly/auto_install
-WARNING opensolaris.manifest001.1 Missing attribute 'info.classification' in pkg://pkg5-nightly/babel_install
-WARNING opensolaris.manifest001.1 Missing attribute 'info.classification' in pkg://pkg5-nightly/server_install
-WARNING opensolaris.manifest001.1 Missing attribute 'info.classification' in pkg://pkg5-nightly/slim_install
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/SUNWcs for pkg://pkg5-nightly/package/pkg
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/SUNWcs for pkg://pkg5-nightly/package/pkg/update-manager
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/SUNWcs for pkg://pkg5-nightly/system/zones/brand/ipkg
@@ -41,11 +33,11 @@
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/library/zlib for pkg://pkg5-nightly/library/python-2/pycurl
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/package/svr4 for pkg://pkg5-nightly/developer/opensolaris/pkg5
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/runtime/perl-584/extra for pkg://pkg5-nightly/developer/opensolaris/pkg5
-WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/runtime/python-26 for pkg://pkg5-nightly/library/python-2/coverage
+WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/runtime/python-26 for pkg://pkg5-nightly/library/python-2/cherrypy
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/service/network/dns/mdns for pkg://pkg5-nightly/library/python-2/pybonjour
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/extended-system-utilities for pkg://pkg5-nightly/system/zones/brand/ipkg
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/font/xorg/xorg-core for pkg://pkg5-nightly/package/pkg/package-manager
-WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/library for pkg://pkg5-nightly/library/python-2/pycurl
+WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/library for pkg://pkg5-nightly/library/python-2/m2crypto
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/library for pkg://pkg5-nightly/system/desktop/ldtp
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/library for pkg://pkg5-nightly/system/zones/brand/ipkg
 WARNING pkglint.action005.1       obsolete dependency check skipped: unable to find dependency pkg:/system/library/dbus for pkg://pkg5-nightly/package/pkg/package-manager
--- a/src/tests/cli/t_pkglint.py	Thu May 26 16:25:57 2011 -0700
+++ b/src/tests/cli/t_pkglint.py	Fri May 27 12:00:45 2011 +1200
@@ -78,6 +78,20 @@
 set name=variant.arch value=i386 value=sparc
 """
 
+        # a basic manifest with a given fmri, used to test ordering
+        # - when linting 'manifest' and 'manifest_ordered' together,
+        # we should always visit this one first, regardless of the
+        # order used on the command line.
+        manifest_ordered = """
+set name=pkg.fmri value=pkg://opensolaris.org/system/[email protected],5.11-0.141:20100603T215050Z
+set name=pkg.description value="core kernel software for a specific instruction-set architecture"
+set name=info.classification value=org.opensolaris.category.2008:System/Core
+set name=pkg.summary value="Core Solaris Kernel"
+set name=org.opensolaris.consolidation value=ON
+set name=variant.arch value=i386 value=sparc
+set name=test value=i386 variant.arch=sparc
+"""
+
         # for the rcfiles below, we also need to point the
         # info_classification_path field to the sections file we deliver in the
         # proto area
@@ -231,6 +245,17 @@
                     "verbose output detected in non-verbose mode")
                 self.assert_("duplicate set actions" in err)
 
+        def test_9_order(self):
+                """Checks that we always visit manifests in the same order."""
+                mpath = self.make_manifest(self.manifest)
+                mpath1 = self.make_manifest(self.manifest_ordered)
+                ret, out, err = self.pkglint("-v %s %s" % (mpath, mpath1))
+                ret, out2, err2 = self.pkglint("-v %s %s" % (mpath1, mpath))
+
+                self.assert_(out == out2,
+                    "different stdout with different cli order")
+                self.assert_(err == err2,
+                    "different stderr with different cli order")
 
 class TestPkglintCliDepot(pkg5unittest.ManyDepotTestCase):
         """Tests that exercise the CLI aspect of dealing with repositories"""