diff options
author | Daniel Baumann <daniel@debian.org> | 2024-11-21 15:00:40 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-11-21 15:00:40 +0100 |
commit | 012d9cb5faed22cb9b4151569d30cc08563b02d1 (patch) | |
tree | fd901b9c231aeb8afa713851f23369fa4a1af2b3 /tests/ufo | |
parent | Initial commit. (diff) | |
download | pysilfont-012d9cb5faed22cb9b4151569d30cc08563b02d1.tar.xz pysilfont-012d9cb5faed22cb9b4151569d30cc08563b02d1.zip |
Adding upstream version 1.8.0.upstream/1.8.0upstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'tests/ufo')
21 files changed, 879 insertions, 0 deletions
diff --git a/tests/ufo/test_10_psfbuildcomp.py b/tests/ufo/test_10_psfbuildcomp.py new file mode 100644 index 0000000..79e4960 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_16_psfchangettfglyphnames.py b/tests/ufo/test_16_psfchangettfglyphnames.py new file mode 100644 index 0000000..f8be56c --- /dev/null +++ b/tests/ufo/test_16_psfchangettfglyphnames.py @@ -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() + + + + + diff --git a/tests/ufo/test_18_psfcheckbasicchars.py b/tests/ufo/test_18_psfcheckbasicchars.py new file mode 100644 index 0000000..3891405 --- /dev/null +++ b/tests/ufo/test_18_psfcheckbasicchars.py @@ -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() + + + + + diff --git a/tests/ufo/test_23_psfcopyglyphs.py b/tests/ufo/test_23_psfcopyglyphs.py new file mode 100644 index 0000000..2279c47 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_30_psfdeleteglyphs.py b/tests/ufo/test_30_psfdeleteglyphs.py new file mode 100644 index 0000000..415f722 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_34_psfexportanchors.py b/tests/ufo/test_34_psfexportanchors.py new file mode 100644 index 0000000..10a2b9c --- /dev/null +++ b/tests/ufo/test_34_psfexportanchors.py @@ -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() + + + + + diff --git a/tests/ufo/test_36_psfexportunicodes.py b/tests/ufo/test_36_psfexportunicodes.py new file mode 100644 index 0000000..631d180 --- /dev/null +++ b/tests/ufo/test_36_psfexportunicodes.py @@ -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() + + + + + diff --git a/tests/ufo/test_38_psfgenftml.py b/tests/ufo/test_38_psfgenftml.py new file mode 100644 index 0000000..ddcdb6c --- /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__ = '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() diff --git a/tests/ufo/test_40_psfglyphs2ufo.py b/tests/ufo/test_40_psfglyphs2ufo.py new file mode 100644 index 0000000..8fb4ee9 --- /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__ = '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() diff --git a/tests/ufo/test_42_psfmakefea.py b/tests/ufo/test_42_psfmakefea.py new file mode 100644 index 0000000..6e1b0c8 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_44_psfmakewoffmetatdata.py b/tests/ufo/test_44_psfmakewoffmetatdata.py new file mode 100644 index 0000000..6568c1d --- /dev/null +++ b/tests/ufo/test_44_psfmakewoffmetatdata.py @@ -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() + + + + + diff --git a/tests/ufo/test_46_psfrenameglyphs.py b/tests/ufo/test_46_psfrenameglyphs.py new file mode 100644 index 0000000..2300bf0 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_50_psfsetassocfeat.py b/tests/ufo/test_50_psfsetassocfeat.py new file mode 100644 index 0000000..96e8626 --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_52_psfsetassocuids.py b/tests/ufo/test_52_psfsetassocuids.py new file mode 100644 index 0000000..4f1d2cf --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_54_psfsetglyphorder.py b/tests/ufo/test_54_psfsetglyphorder.py new file mode 100644 index 0000000..becb8af --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_56_psfsetkeys.py b/tests/ufo/test_56_psfsetkeys.py new file mode 100644 index 0000000..491c39d --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_60_psfsetpsnames.py b/tests/ufo/test_60_psfsetpsnames.py new file mode 100644 index 0000000..8d1684a --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_62_psfsetunicodes.py b/tests/ufo/test_62_psfsetunicodes.py new file mode 100644 index 0000000..4cb306c --- /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__ = '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() + + + + + diff --git a/tests/ufo/test_80_psfsyncmasters.py b/tests/ufo/test_80_psfsyncmasters.py new file mode 100644 index 0000000..595ef77 --- /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__ = '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()
\ 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..29d475c --- /dev/null +++ b/tests/ufo/test_88_psfufo2ttf.py @@ -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() + + + + + diff --git a/tests/ufo/test_99_psfnormalize.py b/tests/ufo/test_99_psfnormalize.py new file mode 100644 index 0000000..3249e92 --- /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__ = '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() + + + + + |