[graphite2] 01/06: Fix the tests so they can run with python3

Mattia Rizzolo mattia at debian.org
Thu Sep 28 15:28:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch master
in repository graphite2.

commit d7a6b5950aa39b267eaf153d932b283a73878ec8
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Thu Sep 28 16:45:28 2017 +0200

    Fix the tests so they can run with python3
    
    Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
 debian/patches/fnttxtrender-python3.diff |  49 --------------
 debian/patches/series                    |   2 +-
 debian/patches/testsuite-python3.diff    | 109 +++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 50 deletions(-)

diff --git a/debian/patches/fnttxtrender-python3.diff b/debian/patches/fnttxtrender-python3.diff
deleted file mode 100644
index 2581d57..0000000
--- a/debian/patches/fnttxtrender-python3.diff
+++ /dev/null
@@ -1,49 +0,0 @@
-Description: make fnttxtrender use python3 explicitly
- seems fonttools doesn't ship the module for python2 anymore and so:
- .
-   File "/<<PKGBUILDDIR>>/tests/fnttxtrender", line 6, in <module>
-     from fontTools.ttLib import TTFont
- ImportError: No module named fontTools.ttLib
- .
- happens.
-Last-Update: 2017-09-19
-
---- graphite2-1.3.10.orig/tests/fnttxtrender
-+++ graphite2-1.3.10/tests/fnttxtrender
-@@ -1,4 +1,4 @@
--#!/usr/bin/python
-+#!/usr/bin/python3
- 
- import codecs
- from optparse import OptionParser
-@@ -242,7 +242,7 @@ for label, words in reader :
-         l = makelabel(label, count, wcount)
-         if cjson is not None and cmpgls(gls[0], cjson[l][0], opts.epsilon) :
-             errors += 1
--            print l + " Failed"
-+            print (l + " Failed")
-         if opts.quiet : continue
-         if log is None :
-             log = JsonLog(outfile, fpaths, opts, args)
---- graphite2-1.3.10.orig/Graphite.cmake
-+++ graphite2-1.3.10/Graphite.cmake
-@@ -113,7 +113,7 @@ function(cmptest TESTNAME FONTFILE TEXTF
-         set(PLATFORM_TEST_SUFFIX ${CMAKE_SYSTEM_NAME})
-     endif (EXISTS ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${CMAKE_SYSTEM_NAME}.json)
-     if ((NOT GRAPHITE2_NFILEFACE) AND ((NOT GRAPHITE2_ASAN) OR CMAKE_COMPILER_IS_GNUCXX))
--        add_test(NAME ${TESTNAME} COMMAND python ${PROJECT_SOURCE_DIR}/fnttxtrender --graphite_library=$<TARGET_FILE:graphite2> -t ${PROJECT_SOURCE_DIR}/texts/${TEXTFILE} -o ${PROJECT_BINARY_DIR}/${TESTNAME}.json -c ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${PLATFORM_TEST_SUFFIX}.json ${ARGN} ${PROJECT_SOURCE_DIR}/fonts/${FONTFILE})
-+        add_test(NAME ${TESTNAME} COMMAND python3 ${PROJECT_SOURCE_DIR}/fnttxtrender --graphite_library=$<TARGET_FILE:graphite2> -t ${PROJECT_SOURCE_DIR}/texts/${TEXTFILE} -o ${PROJECT_BINARY_DIR}/${TESTNAME}.json -c ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${PLATFORM_TEST_SUFFIX}.json ${ARGN} ${PROJECT_SOURCE_DIR}/fonts/${FONTFILE})
-         if (GRAPHITE2_ASAN)
-             set_property(TEST ${TESTNAME} APPEND 
-                     PROPERTY ENVIRONMENT "ASAN_SYMBOLIZER_PATH=${ASAN_SYMBOLIZER}"
---- graphite2-1.3.10.orig/tests/graphite.py
-+++ graphite2-1.3.10/tests/graphite.py
-@@ -126,7 +126,7 @@ def tag_to_str(num) :
-     gr2.gr_tag_to_str(num, s)
-     return str(s.value)
- 
--class Label(unicode) :
-+class Label(str) :
-     def __new__(typename, ref, size) :
-         return super(Label, typename).__new__(typename, string_at(ref, size))
- 
diff --git a/debian/patches/series b/debian/patches/series
index 705b6ad..c92835d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,5 +4,5 @@ non-linux.diff
 no-icons.diff
 test-timeout.diff
 reproducible-build.diff
-#fnttxtrender-python3.diff
+#testsuite-python3.diff
 temporarily-disable-fnttxtrender-tests.diff
diff --git a/debian/patches/testsuite-python3.diff b/debian/patches/testsuite-python3.diff
new file mode 100644
index 0000000..87b0fbd
--- /dev/null
+++ b/debian/patches/testsuite-python3.diff
@@ -0,0 +1,109 @@
+Description: Make the tests run with python3
+ These patches most probably drops python2 supports.
+ We need to switch to python3 as apparentl fonttools is not shipping the
+ python2 modules anymore (#876439).
+Author: Rene Engelhard <rene at debian.org>
+Author: Mattia Rizzolo <mattia at debian.org>
+Last-Update: 2017-09-28
+
+--- a/tests/fnttxtrender
++++ b/tests/fnttxtrender
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+ 
+ import codecs
+ from optparse import OptionParser
+@@ -202,7 +202,7 @@
+ #  if --graphite_library is used.
+ import graphite as gr
+ 
+-outfile = codecs.getwriter("utf_8")(open(opts.output, mode="wt") if opts.output else sys.stdout)
++outfile = open(opts.output, mode="wt", encoding="utf_8") if opts.output else sys.stdout
+ 
+ if opts.compare :
+     with open(opts.compare) as f :
+@@ -221,7 +221,7 @@
+         feats[k.strip()] = int(v.strip())
+ 
+ origargs = []
+-fpaths = map(lambda x:os.path.relpath(x, start=(os.path.dirname(opts.output) if opts.output else '.')), args)
++fpaths = list(map(lambda x:os.path.relpath(x, start=(os.path.dirname(opts.output) if opts.output else '.')), args))
+ 
+ font = GrFont(args[0], 0, opts.rtl, feats, opts.script, opts.lang, segcache=opts.cache)
+ tt = TTFont(args[0])
+@@ -237,16 +237,16 @@
+     wcount = 0
+     for s in words :
+         wcount += 1
+-        gls = [map(lambda x: name(tt, x, rounding), font.glyphs(s, includewidth = True))]
++        gls = [list(map(lambda x: name(tt, x, rounding), font.glyphs(s, includewidth = True)))]
+         if gls[-1][-1][0] is None : gls[-1] = ('_adv_', gls[-1][-1][1], gls[-1][-1][2])
+         l = makelabel(label, count, wcount)
+         if cjson is not None and cmpgls(gls[0], cjson[l][0], opts.epsilon) :
+             errors += 1
+-            print l + " Failed"
++            print (l + " Failed")
+         if opts.quiet : continue
+         if log is None :
+             log = JsonLog(outfile, fpaths, opts, args)
+-        bases = map(lambda x: (cmaplookup(tt, x), (0,0)), s)
++        bases = list(map(lambda x: (cmaplookup(tt, x), (0,0)), s))
+         log.logentry(label, count, wcount, s, gls, bases)
+ if log is not None : log.logend()
+ outfile.close()
+--- a/Graphite.cmake
++++ b/Graphite.cmake
+@@ -113,7 +113,7 @@
+         set(PLATFORM_TEST_SUFFIX ${CMAKE_SYSTEM_NAME})
+     endif (EXISTS ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${CMAKE_SYSTEM_NAME}.json)
+     if ((NOT GRAPHITE2_NFILEFACE) AND ((NOT GRAPHITE2_ASAN) OR CMAKE_COMPILER_IS_GNUCXX))
+-        add_test(NAME ${TESTNAME} COMMAND python ${PROJECT_SOURCE_DIR}/fnttxtrender --graphite_library=$<TARGET_FILE:graphite2> -t ${PROJECT_SOURCE_DIR}/texts/${TEXTFILE} -o ${PROJECT_BINARY_DIR}/${TESTNAME}.json -c ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${PLATFORM_TEST_SUFFIX}.json ${ARGN} ${PROJECT_SOURCE_DIR}/fonts/${FONTFILE})
++        add_test(NAME ${TESTNAME} COMMAND python3 ${PROJECT_SOURCE_DIR}/fnttxtrender --graphite_library=$<TARGET_FILE:graphite2> -t ${PROJECT_SOURCE_DIR}/texts/${TEXTFILE} -o ${PROJECT_BINARY_DIR}/${TESTNAME}.json -c ${PROJECT_SOURCE_DIR}/standards/${TESTNAME}${PLATFORM_TEST_SUFFIX}.json ${ARGN} ${PROJECT_SOURCE_DIR}/fonts/${FONTFILE})
+         if (GRAPHITE2_ASAN)
+             set_property(TEST ${TESTNAME} APPEND 
+                     PROPERTY ENVIRONMENT "ASAN_SYMBOLIZER_PATH=${ASAN_SYMBOLIZER}"
+--- a/tests/graphite.py
++++ b/tests/graphite.py
+@@ -126,7 +126,7 @@
+     gr2.gr_tag_to_str(num, s)
+     return str(s.value)
+ 
+-class Label(unicode) :
++class Label(str) :
+     def __new__(typename, ref, size) :
+         return super(Label, typename).__new__(typename, string_at(ref, size))
+ 
+@@ -181,6 +181,8 @@
+ 
+ class Face(object) :
+     def __init__(self, data, options = 0, fn=None, segcache=0) :
++        if isinstance(data, str):
++            data = data.encode('utf-8')
+         if fn :
+             if segcache :
+                 self.face = gr2.gr_make_face_with_seg_cache(data, fn, segcache, options)
+@@ -202,12 +204,12 @@
+         return gr2.fr_face_n_glyphs(self.face)
+ 
+     def get_featureval(self, lang) :
+-        if isinstance(lang, basestring) :
++        if isinstance(lang, str) :
+             lang = gr_str_to_tag(lang)
+         return FeatureVal(gr2.gr_face_featureval_for_lang(self.face, lang))
+ 
+     def get_featureref(self, featid) :
+-        if isinstance(featid, basestring) :
++        if isinstance(featid, str) :
+             featid = gr_str_to_tag(featid)
+         return FeatureRef(gr2.gr_face_find_fref(self.face, featid))
+ 
+@@ -320,7 +322,7 @@
+     def __init__(self, font, face, scriptid, string, rtl, length = None, feats = None) :
+         if not length :
+             length = len(string)
+-        if isinstance(scriptid, basestring) :
++        if isinstance(scriptid, str) :
+             scriptid = gr2.gr_str_to_tag(scriptid)
+         self.seg = gr2.gr_make_seg(font.font if font is not None else 0, face.face, scriptid, (feats.fval if feats else 0), 1, string.encode('utf_8'), length, rtl)
+ 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openoffice/graphite2.git



More information about the Pkg-openoffice-commits mailing list