Hash :
4e3cf91a
Author :
Date :
2018-01-01T11:17:51
[cmake] Run rest of the tests on Windows (#668)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#!/usr/bin/env python
from __future__ import print_function
import sys, os, subprocess
try:
input = raw_input
except NameError:
pass
def cmd(command):
p = subprocess.Popen (
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait ()
print (p.stderr.read (), file=sys.stderr)
return p.stdout.read ().decode ("utf-8"), p.returncode
srcdir = os.environ.get ("srcdir", ".")
builddir = os.environ.get ("builddir", ".")
top_builddir = os.environ.get ("top_builddir",
os.path.normpath (os.path.join (os.getcwd (), "..", "..")))
utildir = os.environ.get ("utildir", "util")
EXEEXT = os.environ.get ("EXEEXT", "")
extra_options = "--verify"
hb_shape = os.path.join (top_builddir, utildir, "hb-shape" + EXEEXT)
args = sys.argv[1:]
if not os.path.exists (hb_shape):
hb_shape = args[0]
args = args[1:]
fails = 0
reference = False
if len (args) and args[0] == "--reference":
reference = True
args = args[1:]
if not reference:
print ('hb_shape:', hb_shape)
if not len (args):
args = [sys.stdin]
for f in args:
if not reference:
if f == sys.stdin:
print ("Running tests from standard input")
else:
print ("Running tests in " + f)
if f == sys.stdin:
def f():
while True:
try:
line = input ()
except EOFError:
break
if len (line):
yield line
else:
break
f = f()
else:
f = open (f)
for line in f:
fontfile, options, unicodes, glyphs_expected = line.split (":")
if line.startswith ("#"):
if not reference:
print ("# hb-shape %s --unicodes %s" % (fontfile, unicodes))
continue
if not reference:
print ("hb-shape %s %s %s --unicodes %s" %
(fontfile, extra_options, options, unicodes))
glyphs1, returncode = cmd ([hb_shape, "--font-funcs=ft",
os.path.join (srcdir, fontfile), extra_options, "--unicodes",
unicodes] + (options.split (' ') if len(options) else []))
if returncode:
print ("hb-shape --font-funcs=ft failed.", file=sys.stderr)
fails = fails + 1
#continue
glyphs2, returncode = cmd ([hb_shape, "--font-funcs=ot",
os.path.join (srcdir, fontfile), extra_options, "--unicodes",
unicodes] + (options.split (' ') if len(options) else []))
if returncode:
print ("hb-shape --font-funcs=ot failed.", file=sys.stderr)
fails = fails + 1
#continue
if glyphs1 != glyphs2:
print ("FT funcs: " + glyphs1, file=sys.stderr)
print ("OT funcs: " + glyphs2, file=sys.stderr)
fails = fails + 1
if reference:
print (":".join ([fontfile, options, unicodes, glyphs1]))
continue
if glyphs1.strip() != glyphs_expected.strip():
print ("Actual: " + glyphs1, file=sys.stderr)
print ("Expected: " + glyphs_expected, file=sys.stderr)
fails = fails + 1
if fails != 0:
if not reference:
print (str (fails) + " tests failed.")
sys.exit (1)
else:
if not reference:
print ("All tests passed.")