1
0
Fork 0

Adding upstream version 1.8.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-10 05:17:32 +01:00
parent c48d95b7fa
commit e40b3259c1
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
2403 changed files with 153656 additions and 0 deletions

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfbuildcomp as testcommand
testname = "psfbuildcomp"
cl = "psfbuildcomp tests/input/font-psf-test/source/PsfTest-Regular.ufo -i tests/input/psfbuildcomp.txt -l local/testresults/ufo/psfbuildcomp.log -p loglevel=i"
outfont = "local/testresults/ufo/psfbuildcomp.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 9 # These may need updating if the test ufo is updated
exp_warnings = 5 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
'Test for psfchangettfglyphnames'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfchangettfglyphnames as testcommand
testname = "psfchangettfglyphnames"
cl = "psfchangettfglyphnames tests/input/font-psf-test/source/PsfTest-Regular.ufo " \
"tests/input/PsfTest-R.ttf local/testresults/ufo/psfchangettfglyphnames.ttf -l local/testresults/ufo/psfchangettfglyphnames.log"
outfont = None
diffexts = [".ttf", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 0 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
'Test for psfcheckbasicchars'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfcheckbasicchars as testcommand
testname = "psfcheckbasicchars"
cl = "psfcheckbasicchars tests/input/font-psf-test/source/PsfTest-Regular.ufo -l local/testresults/ufo/psfcheckbasicchars.log"
outfont = None
diffexts = [".log"]
exp_errors = 1 # These may need updating if the test ufo is updated
exp_warnings = 192 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,41 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfcopyglyphs as testcommand
testname = "psfcopyglyphs"
cl = "psfcopyglyphs -s tests/input/font-psf-test/source/PsfTest-Regular.ufo " \
"tests/input/font-psf-test/source/PsfTest-Italic.ufo " \
"-i tests/input/psfcopyglyphs.csv " \
"-l local/testresults/ufo/psfcopyglyphs.log " \
"--rename newname --unicode usv"
outfont = "local/testresults/ufo/psfcopyglyphs.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 15 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfdeleteglyphs as testcommand
testname = "psfdeleteglyphs"
cl = "psfdeleteglyphs tests/input/font-psf-test/source/PsfTest-Regular.ufo -i tests/input/psfdeleteglyphs.txt -l local/testresults/ufo/psfdeleteglyphs.log -p loglevel=i -p scrlevel=w"
outfont = "local/testresults/ufo/psfdeleteglyphs.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 6 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
'Test for psfexportanchors'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfexportanchors as testcommand
testname = "psfexportanchors"
cl = "psfexportanchors tests/input/font-psf-test/source/PsfTest-Italic.ufo local/testresults/ufo/psfexportanchors.xml -l local/testresults/ufo/psfexportanchors.log"
outfont = None
diffexts = [".xml", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 10 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
'Test for psfexportunicodes'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfexportunicodes as testcommand
testname = "psfexportunicodes"
cl = "psfexportunicodes tests/input/font-psf-test/source/PsfTest-BoldItalic.ufo -o local/testresults/ufo/psfexportunicodes.csv -l local/testresults/ufo/psfexportunicodes.log"
outfont = None
diffexts = [".csv", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 7 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,75 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'Bob Hallissy'
import silfont.util
import silfont.ftml_builder as FB
# There is no one psfgenftml script -- each project will have its own. So here is what we'll use for testing:
class testcommand(object):
argspec = [
('ifont',{'help': 'Input UFO'}, {'type': 'infont'}),
('output',{'help': 'Output file ftml in XML format', 'nargs': '?'}, {'type': 'outfile', 'def': '_out.ftml'}),
('-i','--input',{'help': 'Glyph info csv file'}, {'type': 'incsv', 'def': 'glyph_data.csv'}),
('-l','--log',{'help': 'Set log file name'}, {'type': 'outfile', 'def': '_ftml.log'}),
]
@staticmethod
def doit(args):
logger = args.logger
# Read input csv
builder = FB.FTMLBuilder(logger, incsv = args.input, font = args.ifont)
# Initialize FTML document:
test = "ftml_builder test"
ftml = FB.FTML(test, logger)
# all chars that should be in the font:
ftml.startTestGroup('Encoded characters')
for uid in sorted(builder.uids()):
if uid < 32: continue
c = builder.char(uid)
# iterate over all permutations of feature settings that might affect this character:
for featlist in builder.permuteFeatures(uids = (uid,)):
ftml.setFeatures(featlist)
builder.render((uid,), ftml)
# Test one character with RTL enabled:
if uid == 67:
builder.render((uid,), ftml, rtl = True)
# Don't close test -- collect consecutive encoded chars in a single row
ftml.clearFeatures()
for langID in sorted(c.langs):
ftml.setLang(langID)
builder.render((uid,), ftml)
ftml.clearLang()
# Write the output ftml file
ftml.writeFile(args.output)
testname = "psfgenftml"
cl = testname + " -i tests/input/psfgenftml.csv -l local/testresults/ufo/psfgenftml.log " \
"tests/input/font-psf-test/source/PsfTest-Italic.ufo local/testresults/ufo/psfgenftml.ftml"
outfont = None
diffexts = [".ftml", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 11 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,64 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
import sys
from silfont.core import execute
import silfont.scripts.psfglyphs2ufo as psfglyphs2ufo
import silfont.scripts.psfnormalize as psfnormalize
def test_run():
cl = "psfglyphs2ufo --nofea tests/input/font-psf-test/source/PsfTestRoman.glyphs " \
"local/testresults/ufo/psfglyphs2ufo -l local/testresults/ufo/psfglyphs2ufo.log"
sys.argv = cl.split(" ")
(args, font) = execute("UFO", psfglyphs2ufo.doit, psfglyphs2ufo.argspec, chain="first")
args.logger.logfile.close()
exp_counts = (1, 0)
actual_counts = (args.logger.errorcount, args.logger.warningcount)
# Now normalize the output ufos
for weight in ("Regular", "Bold"):
fontname = "local/testresults/ufo/psfglyphs2ufo/PsfTest-" + weight + ".ufo"
cl = "psfnormalize " + fontname
sys.argv = cl.split(" ")
(args, font) = execute("UFO", psfnormalize.doit, psfnormalize.argspec, chain="first")
font.write(fontname)
if exp_counts == actual_counts:
assert True
else:
print("Mis-match of logger errors/warnings: " + str(exp_counts) + " vs " + str(actual_counts))
assert False
def test_diffs(): # Do a diff on all output files
result = True
refdir = "tests/reference/ufo/"
resdir = "local/testresults/ufo/"
ufodiff = False
diff = silfont.util.ufo_diff(resdir + "psfglyphs2ufo/PsfTest-Regular.ufo", refdir + "psfglyphs2ufo/PsfTest-Regular.ufo")
if diff.returncode:
ufodiff = True
diff.print_text()
result = False
diff = silfont.util.ufo_diff(resdir + "psfglyphs2ufo/PsfTest-Bold.ufo", refdir + "psfglyphs2ufo/PsfTest-Bold.ufo")
if diff.returncode:
diff.print_text()
result = False
diff = silfont.util.text_diff(resdir + "psfglyphs2ufo.log", refdir + "psfglyphs2ufo.log", ignore_chars=20)
if diff.returncode:
diff.print_text()
result = False
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2019 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfmakefea as testcommand
testname = "psfmakefea"
cl = "psfmakefea -i tests/input/psfmakefea.feax -o local/testresults/ufo/psfmakefea.fea -l local/testresults/ufo/psfmakefea.log tests/input/font-psf-test/source/PsfTest-Regular.ufo"
outfont = None # Set to None for commands which don't output a font
diffexts = [".fea", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 0 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
'Test for psfmakewoffmetadata'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfmakewoffmetadata as testcommand
testname = "psfmakewoffmetadata"
cl = "psfmakewoffmetadata tests/input/font-psf-test/source/PsfTest-Regular.ufo -n Test -i SIL -f tests/input/psfmakewoffmetadata.txt" \
+ " -o local/testresults/ufo/psfmakewoffmetadata.xml -l local/testresults/ufo/psfmakewoffmetadata.log"
outfont = None
diffexts = [".xml", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 6 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfrenameglyphs as testcommand
testname = "psfrenameglyphs"
cl = "psfrenameglyphs tests/input/font-psf-test/source/PsfTest-Bold.ufo -i tests/input/psfrenameglyphs.csv -l local/testresults/ufo/psfrenameglyphs.log -p loglevel=i -p checkfix=fix"
outfont = "local/testresults/ufo/psfrenameglyphs.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 5 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetassocfeat as testcommand
testname = "psfsetassocfeat"
cl = "psfsetassocfeat tests/input/font-psf-test/source/PsfTest-Italic.ufo -i tests/input/psfsetassocfeat.csv -l local/testresults/ufo/psfsetassocfeat.log -p loglevel=i"
outfont = "local/testresults/ufo/psfsetassocfeat.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 9 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetassocuids as testcommand
testname = "psfsetassocuids"
cl = "psfsetassocuids tests/input/font-psf-test/source/PsfTest-Bold.ufo -i tests/input/psfsetassocuids.csv -l local/testresults/ufo/psfsetassocuids.log -p loglevel=i"
outfont = "local/testresults/ufo/psfsetassocuids.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 1 # These may need updating if the test ufo is updated
exp_warnings = 5 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetglyphorder as testcommand
testname = "psfsetglyphorder"
cl = "psfsetglyphorder tests/input/font-psf-test/source/PsfTest-Italic.ufo -i tests/input/glyph_data.csv -l local/testresults/ufo/psfsetglyphorder.log -p loglevel=i"
outfont = "local/testresults/ufo/psfsetglyphorder.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 9 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetkeys as testcommand
testname = "psfsetkeys"
cl = "psfsetkeys tests/input/font-psf-test/source/PsfTest-BoldItalic.ufo -k org.sil.newkey -v newvalue -l local/testresults/ufo/psfsetkeys.log -p loglevel=i -p checkfix=fix"
outfont = "local/testresults/ufo/psfsetkeys.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 7 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetpsnames as testcommand
testname = "psfsetpsnames"
cl = "psfsetpsnames tests/input/font-psf-test/source/PsfTest-BoldItalic.ufo -i tests/input/glyph_data.csv -l local/testresults/ufo/psfsetpsnames.log -p loglevel=i"
outfont = "local/testresults/ufo/psfsetpsnames.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 7 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfsetunicodes as testcommand
testname = "psfsetunicodes"
cl = "psfsetunicodes tests/input/font-psf-test/source/PsfTest-Italic.ufo -i tests/input/psfsetunicodes.csv -l local/testresults/ufo/psfsetunicodes.log -p loglevel=v -p checkfix=fix"
outfont = "local/testresults/ufo/psfsetunicodes.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 9 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,73 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
import sys, os, glob, subprocess
from silfont.core import execute
import silfont.scripts.psfsyncmasters as psfsyncmasters
def test_run():
cl = "psfsyncmasters -n tests/input/font-psf-test/source/PsfTestRoman.designspace " \
"tests/input/font-psf-test/source/PsfTestItalic.designspace -l local/testresults/ufo/psfsyncmasters.log"
sys.argv = cl.split(" ")
(args, font) = execute("UFO", psfsyncmasters.doit, psfsyncmasters.argspec, chain="first")
args.logger.logfile.close()
exp_counts = (0, 6)
actual_counts = (args.logger.errorcount, args.logger.warningcount)
if exp_counts == actual_counts:
assert True
else:
print("Mis-match of logger errors/warnings: " + str(exp_counts) + " vs " + str(actual_counts))
assert False
def test_diffs(): # Do a diff on all output files
result = True
sourcedir = "tests/input/font-psf-test/source/"
refdir = "tests/reference/ufo/"
resdir = "local/testresults/ufo/"
# -n in commands will have created _new versions of changed files in the source directory,
# so move them to results prior to running diff commands
for f in glob.glob(resdir + "psfsyncmasters*.plist"): os.remove(f) # Delete any old results
filelist = []
for style in ("Regular", "Italic", "Bold", "BoldItalic"):
ufodir = sourcedir + "PsfTest-" + style + ".ufo/"
for f in glob.glob(ufodir + "*_new.plist"):
(dir,filen) = os.path.split(f)
filen = "fontinfo.plist" if filen[0] == "f" else "lib.plist"
filen = style + "-" + filen
filelist.append(filen)
os.rename(f, resdir + "psfsyncmasters-" + filen )
filelist.sort()
expectedlist = ['Bold-fontinfo.plist', 'Bold-lib.plist', 'BoldItalic-fontinfo.plist', 'Italic-fontinfo.plist']
if filelist != expectedlist:
print("None-standard output files: \n" + str(filelist))
print("Expected: \n" + str(expectedlist))
result = False
for f in filelist:
# Need to diff the plists with subprocess("diff") to be able handle openTypeHeadCreated issue
filen = "psfsyncmasters-" + f
diff = subprocess.Popen(["diff", resdir + filen, refdir + filen, "-c1"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
text = diff.communicate()
if diff.returncode == 1:
difftext = text[0].decode("utf-8").split("\n")
# Need to rule out only change being openTypeHeadCreated (which should be the case for fontinfo)
if not(difftext[4].strip() == "<key>openTypeHeadCreated</key>" and len(difftext) == 12):
print(filen + " different from reference")
for line in difftext: print(line)
result = False
diff = silfont.util.text_diff(resdir + "psfsyncmasters.log", refdir + "psfsyncmasters.log", ignore_chars=20)
if diff.returncode:
diff.print_text()
result = False
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
'Test for psfufo2ttf'
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 5 lines of code are test-specific
import silfont.scripts.psfufo2ttf as testcommand
testname = "psfufo2ttf"
cl = "psfufo2ttf tests/input/font-psf-test/source/PsfTest-Regular.ufo " \
"local/testresults/ufo/psfufo2ttf.ttf -l local/testresults/ufo/psfufo2ttf.log"
outfont = None
diffexts = [".ttf", ".log"]
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 0 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Generic function for all UFO tests
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()

View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
''' Test of script named in testname below
'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2018 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'
import silfont.util
# Next 7 lines of code may be test-specific
import silfont.scripts.psfnormalize as testcommand
testname = "psfnormalize"
cl = "psfnormalize tests/input/font-psf-test/source/PsfTest-Italic.ufo -l local/testresults/ufo/psfnormalize.log -p checkfix=fix"
outfont = "local/testresults/ufo/psfnormalize.ufo" # Set to None for commands which don't output a font
diffexts = [".ufo", ".log"] # List of extensions of all output files
exp_errors = 0 # These may need updating if the test ufo is updated
exp_warnings = 9 # The test ufo should have some errors/warnings to test the code!
# Code after this can be the same for most/all tests; if needed to be different for a test remove this comment!
def test_run():
result = silfont.util.test_run("UFO", cl, testcommand, outfont, exp_errors, exp_warnings)
assert result
def test_diffs(): # Do a diff on all output files
result = silfont.util.test_diffs("ufo", testname, diffexts)
assert result
if __name__ == "__main__":
test_run()
test_diffs()