[Python-modules-commits] r31078 - in packages/ply/trunk/debian (6 files)

arnau at users.alioth.debian.org arnau at users.alioth.debian.org
Thu Oct 16 05:29:18 UTC 2014


    Date: Thursday, October 16, 2014 @ 05:29:17
  Author: arnau
Revision: 31078

Enable tests during package build. Thanks to James Page. Closes: #734366.

Added:
  packages/ply/trunk/debian/patches/fixed-lexer-line-tracking.patch
  packages/ply/trunk/debian/patches/fixed-yacc-tests-to-account-for-dict-hash-key-random.patch
  packages/ply/trunk/debian/patches/more-test-fixes.patch
Modified:
  packages/ply/trunk/debian/changelog
  packages/ply/trunk/debian/patches/series
  packages/ply/trunk/debian/rules

Modified: packages/ply/trunk/debian/changelog
===================================================================
--- packages/ply/trunk/debian/changelog	2014-10-16 04:53:54 UTC (rev 31077)
+++ packages/ply/trunk/debian/changelog	2014-10-16 05:29:17 UTC (rev 31078)
@@ -5,6 +5,10 @@
 
   [ Arnaud Fontaine ]
   * Remove Gustavo Franco from Uploaders as he is retiring. Closes: #729398.
+  * Enable tests during package build. Thanks to James Page. Closes: #734366.
+    + d/rules: Execute lex and yacc tests for all python versions.
+    + d/p/*.patch: Cherry picked fixes from upstream VCS to resolve
+      compatibility issues with Python >= 3.3.
 
  -- Arnaud Fontaine <arnau at debian.org>  Fri, 13 Dec 2013 11:14:14 +0100
 

Added: packages/ply/trunk/debian/patches/fixed-lexer-line-tracking.patch
===================================================================
--- packages/ply/trunk/debian/patches/fixed-lexer-line-tracking.patch	                        (rev 0)
+++ packages/ply/trunk/debian/patches/fixed-lexer-line-tracking.patch	2014-10-16 05:29:17 UTC (rev 31078)
@@ -0,0 +1,25 @@
+From 0c0b575b529d4fe6dc0be179e701a302f27bc127 Mon Sep 17 00:00:00 2001
+From: David Beazley <dave at dabeaz.com>
+Date: Thu, 26 Apr 2012 10:15:09 -0500
+Subject: [PATCH 3/3] Fixed lexer line tracking.
+
+---
+ test/calclex.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/calclex.py b/test/calclex.py
+index 67d245f..302f0b0 100644
+--- a/test/calclex.py
++++ b/test/calclex.py
+@@ -36,7 +36,7 @@ t_ignore = " \t"
+ 
+ def t_newline(t):
+     r'\n+'
+-    t.lineno += t.value.count("\n")
++    t.lexer.lineno += t.value.count("\n")
+     
+ def t_error(t):
+     print("Illegal character '%s'" % t.value[0])
+-- 
+1.8.5.2
+

Added: packages/ply/trunk/debian/patches/fixed-yacc-tests-to-account-for-dict-hash-key-random.patch
===================================================================
--- packages/ply/trunk/debian/patches/fixed-yacc-tests-to-account-for-dict-hash-key-random.patch	                        (rev 0)
+++ packages/ply/trunk/debian/patches/fixed-yacc-tests-to-account-for-dict-hash-key-random.patch	2014-10-16 05:29:17 UTC (rev 31078)
@@ -0,0 +1,98 @@
+From 02030ad24d923f16f401744a608573365b2e5542 Mon Sep 17 00:00:00 2001
+From: David Beazley <dave at dabeaz.com>
+Date: Tue, 21 May 2013 20:14:04 -0500
+Subject: [PATCH 1/3] Fixed yacc tests to account for dict hash key
+ randomization
+
+---
+ test/testlex.py    |  3 +--
+ test/testyacc.py   | 24 +++++++++++++++++++++---
+ test/yacc_prec1.py |  4 ++--
+ 3 files changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/test/testlex.py b/test/testlex.py
+index 1f7dd1b..e436781 100755
+--- a/test/testlex.py
++++ b/test/testlex.py
+@@ -34,7 +34,7 @@ def pymodule_out_exists(filename):
+ def pymodule_out_remove(filename):
+     os.remove(make_pymodule_path(filename))
+ 
+-def check_expected(result,expected):
++def check_expected(result, expected):
+     if sys.version_info[0] >= 3:
+         if isinstance(result,str):
+             result = result.encode('ascii')
+@@ -43,7 +43,6 @@ def check_expected(result,expected):
+     resultlines = result.splitlines()
+     expectedlines = expected.splitlines()
+ 
+-
+     if len(resultlines) != len(expectedlines):
+         return False
+ 
+diff --git a/test/testyacc.py b/test/testyacc.py
+index 2b06b44..4462201 100644
+--- a/test/testyacc.py
++++ b/test/testyacc.py
+@@ -34,7 +34,7 @@ def pymodule_out_exists(filename):
+ def pymodule_out_remove(filename):
+     os.remove(make_pymodule_path(filename))
+ 
+-
++# Old implementation (not safe for Python 3.3)
+ def check_expected(result,expected):
+     resultlines = []
+     for line in result.splitlines():
+@@ -52,6 +52,26 @@ def check_expected(result,expected):
+             return False
+     return True
+ 
++# Check the output to see if it contains all of a set of expected output lines.
++# This alternate implementation looks weird, but is needed to properly handle
++# some variations in error message order that occurs due to dict hash table
++# randomization that was introduced in Python 3.3
++def check_expected(result, expected):
++    resultlines = set()
++    for line in result.splitlines():
++        if line.startswith("WARNING: "):
++            line = line[9:]
++        elif line.startswith("ERROR: "):
++            line = line[7:]
++        resultlines.add(line)
++
++    # Selectively remove expected lines from the output
++    for eline in expected.splitlines():
++        resultlines = set(line for line in resultlines if not line.endswith(eline))
++
++    # Return True if no result lines remain
++    return not bool(resultlines)
++
+ def run_import(module):
+     code = "import "+module
+     exec(code)
+@@ -342,6 +362,4 @@ class YaccErrorWarningTests(unittest.TestCase):
+                                     "Precedence rule 'left' defined for unknown symbol '/'\n"
+                                     ))
+ 
+-
+-            
+ unittest.main()
+diff --git a/test/yacc_prec1.py b/test/yacc_prec1.py
+index 2ca6afc..99fcd90 100644
+--- a/test/yacc_prec1.py
++++ b/test/yacc_prec1.py
+@@ -12,8 +12,8 @@ from calclex import tokens
+ 
+ # Parsing rules
+ precedence = (
+-    ('left','+','-'),
+-    ('left','*','/'),
++    ('left', '+', '-'),
++    ('left', '*', '/'),
+     ('right','UMINUS'),
+     )
+ 
+-- 
+1.8.5.2
+

Added: packages/ply/trunk/debian/patches/more-test-fixes.patch
===================================================================
--- packages/ply/trunk/debian/patches/more-test-fixes.patch	                        (rev 0)
+++ packages/ply/trunk/debian/patches/more-test-fixes.patch	2014-10-16 05:29:17 UTC (rev 31078)
@@ -0,0 +1,55 @@
+From 55ff3fb3608d6112b315c85acd5b4348aaa32e12 Mon Sep 17 00:00:00 2001
+From: David Beazley <dave at dabeaz.com>
+Date: Tue, 21 May 2013 21:26:59 -0500
+Subject: [PATCH 2/3] More test fixes
+
+---
+ ply/yacc.py      | 8 ++++++--
+ test/testyacc.py | 5 +++++
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/ply/yacc.py b/ply/yacc.py
+index e9f5c65..a29c645 100644
+--- a/ply/yacc.py
++++ b/ply/yacc.py
+@@ -195,8 +195,12 @@ class YaccProduction:
+         self.lexer = None
+         self.parser= None
+     def __getitem__(self,n):
+-        if n >= 0: return self.slice[n].value
+-        else: return self.stack[n].value
++        if isinstance(n, slice):
++            return [s.value for s in self.slice[n]]
++        elif n >= 0: 
++            return self.slice[n].value
++        else: 
++            return self.stack[n].value
+ 
+     def __setitem__(self,n,v):
+         self.slice[n].value = v
+diff --git a/test/testyacc.py b/test/testyacc.py
+index 4462201..86c991a 100644
+--- a/test/testyacc.py
++++ b/test/testyacc.py
+@@ -9,6 +9,7 @@ except ImportError:
+ import sys
+ import os
+ import warnings
++import re
+ 
+ sys.path.insert(0,"..")
+ sys.tracebacklimit = 0
+@@ -57,6 +58,10 @@ def check_expected(result,expected):
+ # some variations in error message order that occurs due to dict hash table
+ # randomization that was introduced in Python 3.3
+ def check_expected(result, expected):
++    # Normalize 'state n' text to account for randomization effects in Python 3.3
++    expected = re.sub(r' state \d+', 'state <n>', expected)
++    result = re.sub(r' state \d+', 'state <n>', result)
++
+     resultlines = set()
+     for line in result.splitlines():
+         if line.startswith("WARNING: "):
+-- 
+1.8.5.2
+

Modified: packages/ply/trunk/debian/patches/series
===================================================================
--- packages/ply/trunk/debian/patches/series	2014-10-16 04:53:54 UTC (rev 31077)
+++ packages/ply/trunk/debian/patches/series	2014-10-16 05:29:17 UTC (rev 31078)
@@ -1,2 +1,5 @@
 01_fix-lex-tabversion.patch
 02_relax-lex-tabversion-check.patch
+fixed-yacc-tests-to-account-for-dict-hash-key-random.patch
+more-test-fixes.patch
+fixed-lexer-line-tracking.patch

Modified: packages/ply/trunk/debian/rules
===================================================================
--- packages/ply/trunk/debian/rules	2014-10-16 04:53:54 UTC (rev 31077)
+++ packages/ply/trunk/debian/rules	2014-10-16 05:29:17 UTC (rev 31078)
@@ -10,6 +10,18 @@
 DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed \
 	--install-layout=deb
 
+PYVERSIONS := $(shell pyversions -s)
+PY3VERSIONS := $(shell py3versions -s)
+
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+build:
+	set -e; \
+	for pyver in $(PYVERSIONS) $(PY3VERSIONS); do \
+		echo "Testing with $$pyver"; \
+		(cd test && $$pyver testlex.py && $$pyver testyacc.py && ./cleanup.sh;)\
+	done
+endif
+
 binary-install/python-ply::
 	pod2man debian/dh_python-ply > dh_python-ply.1
 	dh_installman -p python-ply dh_python-ply.1




More information about the Python-modules-commits mailing list