From da875fcb62c801b8d19b3d4d984ad963574fb356 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 2 Mar 2023 21:01:10 +0100 Subject: Adding upstream version 1.6.0. Signed-off-by: Daniel Baumann --- tests/ufo/test_10_psfbuildcomp.py | 37 ++++++++++++++ tests/ufo/test_16_psfchangettfglyphnames.py | 37 ++++++++++++++ tests/ufo/test_18_psfcheckbasicchars.py | 36 ++++++++++++++ tests/ufo/test_23_psfcopyglyphs.py | 41 ++++++++++++++++ tests/ufo/test_30_psfdeleteglyphs.py | 37 ++++++++++++++ tests/ufo/test_34_psfexportanchors.py | 36 ++++++++++++++ tests/ufo/test_36_psfexportunicodes.py | 36 ++++++++++++++ tests/ufo/test_38_psfgenftml.py | 75 +++++++++++++++++++++++++++++ tests/ufo/test_40_psfglyphs2ufo.py | 64 ++++++++++++++++++++++++ tests/ufo/test_42_psfmakefea.py | 37 ++++++++++++++ tests/ufo/test_44_psfmakewoffmetatdata.py | 37 ++++++++++++++ tests/ufo/test_46_psfrenameglyphs.py | 37 ++++++++++++++ tests/ufo/test_50_psfsetassocfeat.py | 37 ++++++++++++++ tests/ufo/test_52_psfsetassocuids.py | 37 ++++++++++++++ tests/ufo/test_54_psfsetglyphorder.py | 37 ++++++++++++++ tests/ufo/test_56_psfsetkeys.py | 37 ++++++++++++++ tests/ufo/test_60_psfsetpsnames.py | 37 ++++++++++++++ tests/ufo/test_62_psfsetunicodes.py | 37 ++++++++++++++ tests/ufo/test_80_psfsyncmasters.py | 73 ++++++++++++++++++++++++++++ tests/ufo/test_88_psfufo2ttf.py | 37 ++++++++++++++ tests/ufo/test_99_psfnormalize.py | 37 ++++++++++++++ 21 files changed, 879 insertions(+) create mode 100644 tests/ufo/test_10_psfbuildcomp.py create mode 100644 tests/ufo/test_16_psfchangettfglyphnames.py create mode 100644 tests/ufo/test_18_psfcheckbasicchars.py create mode 100644 tests/ufo/test_23_psfcopyglyphs.py create mode 100644 tests/ufo/test_30_psfdeleteglyphs.py create mode 100644 tests/ufo/test_34_psfexportanchors.py create mode 100644 tests/ufo/test_36_psfexportunicodes.py create mode 100644 tests/ufo/test_38_psfgenftml.py create mode 100644 tests/ufo/test_40_psfglyphs2ufo.py create mode 100644 tests/ufo/test_42_psfmakefea.py create mode 100644 tests/ufo/test_44_psfmakewoffmetatdata.py create mode 100644 tests/ufo/test_46_psfrenameglyphs.py create mode 100644 tests/ufo/test_50_psfsetassocfeat.py create mode 100644 tests/ufo/test_52_psfsetassocuids.py create mode 100644 tests/ufo/test_54_psfsetglyphorder.py create mode 100644 tests/ufo/test_56_psfsetkeys.py create mode 100644 tests/ufo/test_60_psfsetpsnames.py create mode 100644 tests/ufo/test_62_psfsetunicodes.py create mode 100644 tests/ufo/test_80_psfsyncmasters.py create mode 100644 tests/ufo/test_88_psfufo2ttf.py create mode 100644 tests/ufo/test_99_psfnormalize.py (limited to 'tests/ufo') diff --git a/tests/ufo/test_10_psfbuildcomp.py b/tests/ufo/test_10_psfbuildcomp.py new file mode 100644 index 0000000..d599c7e --- /dev/null +++ b/tests/ufo/test_10_psfbuildcomp.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_16_psfchangettfglyphnames.py b/tests/ufo/test_16_psfchangettfglyphnames.py new file mode 100644 index 0000000..72b7dc1 --- /dev/null +++ b/tests/ufo/test_16_psfchangettfglyphnames.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +'Test for psfchangettfglyphnames' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_18_psfcheckbasicchars.py b/tests/ufo/test_18_psfcheckbasicchars.py new file mode 100644 index 0000000..9e685ce --- /dev/null +++ b/tests/ufo/test_18_psfcheckbasicchars.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +'Test for psfcheckbasicchars' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_23_psfcopyglyphs.py b/tests/ufo/test_23_psfcopyglyphs.py new file mode 100644 index 0000000..b874cea --- /dev/null +++ b/tests/ufo/test_23_psfcopyglyphs.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_30_psfdeleteglyphs.py b/tests/ufo/test_30_psfdeleteglyphs.py new file mode 100644 index 0000000..c5c461a --- /dev/null +++ b/tests/ufo/test_30_psfdeleteglyphs.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_34_psfexportanchors.py b/tests/ufo/test_34_psfexportanchors.py new file mode 100644 index 0000000..fff85a7 --- /dev/null +++ b/tests/ufo/test_34_psfexportanchors.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +'Test for psfexportanchors' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_36_psfexportunicodes.py b/tests/ufo/test_36_psfexportunicodes.py new file mode 100644 index 0000000..6d5cad9 --- /dev/null +++ b/tests/ufo/test_36_psfexportunicodes.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +'Test for psfexportunicodes' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_38_psfgenftml.py b/tests/ufo/test_38_psfgenftml.py new file mode 100644 index 0000000..6c2483f --- /dev/null +++ b/tests/ufo/test_38_psfgenftml.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() diff --git a/tests/ufo/test_40_psfglyphs2ufo.py b/tests/ufo/test_40_psfglyphs2ufo.py new file mode 100644 index 0000000..a5a74ff --- /dev/null +++ b/tests/ufo/test_40_psfglyphs2ufo.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() diff --git a/tests/ufo/test_42_psfmakefea.py b/tests/ufo/test_42_psfmakefea.py new file mode 100644 index 0000000..4f4e069 --- /dev/null +++ b/tests/ufo/test_42_psfmakefea.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2019 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_44_psfmakewoffmetatdata.py b/tests/ufo/test_44_psfmakewoffmetatdata.py new file mode 100644 index 0000000..ff8325d --- /dev/null +++ b/tests/ufo/test_44_psfmakewoffmetatdata.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +'Test for psfmakewoffmetadata' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_46_psfrenameglyphs.py b/tests/ufo/test_46_psfrenameglyphs.py new file mode 100644 index 0000000..d040c25 --- /dev/null +++ b/tests/ufo/test_46_psfrenameglyphs.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_50_psfsetassocfeat.py b/tests/ufo/test_50_psfsetassocfeat.py new file mode 100644 index 0000000..060a25d --- /dev/null +++ b/tests/ufo/test_50_psfsetassocfeat.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_52_psfsetassocuids.py b/tests/ufo/test_52_psfsetassocuids.py new file mode 100644 index 0000000..adb35c7 --- /dev/null +++ b/tests/ufo/test_52_psfsetassocuids.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_54_psfsetglyphorder.py b/tests/ufo/test_54_psfsetglyphorder.py new file mode 100644 index 0000000..8d4181c --- /dev/null +++ b/tests/ufo/test_54_psfsetglyphorder.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_56_psfsetkeys.py b/tests/ufo/test_56_psfsetkeys.py new file mode 100644 index 0000000..ac5505c --- /dev/null +++ b/tests/ufo/test_56_psfsetkeys.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_60_psfsetpsnames.py b/tests/ufo/test_60_psfsetpsnames.py new file mode 100644 index 0000000..924a815 --- /dev/null +++ b/tests/ufo/test_60_psfsetpsnames.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_62_psfsetunicodes.py b/tests/ufo/test_62_psfsetunicodes.py new file mode 100644 index 0000000..c12f3d4 --- /dev/null +++ b/tests/ufo/test_62_psfsetunicodes.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_80_psfsyncmasters.py b/tests/ufo/test_80_psfsyncmasters.py new file mode 100644 index 0000000..128d7e6 --- /dev/null +++ b/tests/ufo/test_80_psfsyncmasters.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() == "openTypeHeadCreated" 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() \ No newline at end of file diff --git a/tests/ufo/test_88_psfufo2ttf.py b/tests/ufo/test_88_psfufo2ttf.py new file mode 100644 index 0000000..e90373d --- /dev/null +++ b/tests/ufo/test_88_psfufo2ttf.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +'Test for psfufo2ttf' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + diff --git a/tests/ufo/test_99_psfnormalize.py b/tests/ufo/test_99_psfnormalize.py new file mode 100644 index 0000000..0449d03 --- /dev/null +++ b/tests/ufo/test_99_psfnormalize.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +''' Test of script named in testname below +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2018 SIL International (http://www.sil.org)' +__license__ = 'Released under the MIT License (http://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() + + + + + -- cgit v1.2.3