def writeTestCollection(identifier, title, description, data, specLink=None, credits=[]): """ This function generates all of the files needed by a test case and registers the case with the suite. The arguments: identifier: The base identifier for the test case. The identifier must be a - separated sequence of group name (from the groupDefinitions listed above) and test case description (arbitrary length). title: A thorough, but not too long, title for the test case. description: A detailed statement about what the test case is proving. data: A list of the complete binary data for WOFF. specLink: The anchor in the WOFF spec that the test case is testing. credits: A list of dictionaries defining the credits for the test case. The dictionaries must have this form: title="Name of the autor or reviewer", role="author or reviewer", link="mailto:email or http://contactpage" """ assert description not in registeredDescriptions, "Duplicate description! %s" % description registeredDescriptions.add(description) specLink = expandSpecLinks(specLink) tag = identifier.split("-")[0] for i, d in enumerate(data): number = "%03d" % (i + 1) test_identifier = identifier + "-" + number test_title = title + " " + number print "Compiling %s..." % test_identifier assert test_title not in registeredTitles, "Duplicate title! %s" % test_title assert test_identifier not in registeredIdentifiers, "Duplicate identifier! %s" % test_identifier registeredIdentifiers.add(test_identifier) registeredTitles.add(test_title) woffPath = os.path.join(decoderTestDirectory, test_identifier) + ".woff2" f = open(woffPath, "wb") f.write(d) f.close() # register the test testRegistry[tag].append( dict(identifier=test_identifier, title=test_title, description=description, roundTrip=False, specLink=specLink))
def writeTestCollection(identifier, title, description, data, specLink=None, credits=[]): """ This function generates all of the files needed by a test case and registers the case with the suite. The arguments: identifier: The base identifier for the test case. The identifier must be a - separated sequence of group name (from the groupDefinitions listed above) and test case description (arbitrary length). title: A thorough, but not too long, title for the test case. description: A detailed statement about what the test case is proving. data: A list of the complete binary data for WOFF. specLink: The anchor in the WOFF spec that the test case is testing. credits: A list of dictionaries defining the credits for the test case. The dictionaries must have this form: title="Name of the autor or reviewer", role="author or reviewer", link="mailto:email or http://contactpage" """ assert description not in registeredDescriptions, "Duplicate description! %s" % description registeredDescriptions.add(description) specLink = expandSpecLinks(specLink) tag = identifier.split("-")[0] for i, d in enumerate(data): number = "%03d" % (i + 1) test_identifier = identifier + "-" + number test_title = title + " " + number print "Compiling %s..." % test_identifier assert test_title not in registeredTitles, "Duplicate title! %s" % test_title assert test_identifier not in registeredIdentifiers, "Duplicate identifier! %s" % test_identifier registeredIdentifiers.add(test_identifier) registeredTitles.add(test_title) woffPath = os.path.join(decoderTestDirectory, test_identifier) + ".woff2" f = open(woffPath, "wb") f.write(d) f.close() # register the test testRegistry[tag].append( dict( identifier=test_identifier, title=test_title, description=description, roundTrip=False, specLink=specLink ) )
def writeTest(identifier, title, description, data, specLink=None, credits=[], roundTrip=False, flavor="CFF"): """ This function generates all of the files needed by a test case and registers the case with the suite. The arguments: identifier: The identifier for the test case. The identifier must be a - separated sequence of group name (from the groupDefinitions listed above), test case description (arbitrary length) and a number to make the name unique. The number should be zero padded to a length of three characters (ie "001" instead of "1"). title: A thorough, but not too long, title for the test case. description: A detailed statement about what the test case is proving. data: The complete binary data for either the WOFF, or both WOFF and SFNT. specLink: The anchor in the WOFF spec that the test case is testing. credits: A list of dictionaries defining the credits for the test case. The dictionaries must have this form: title="Name of the autor or reviewer", role="author or reviewer", link="mailto:email or http://contactpage" roundTrip: A boolean indicating if this is a round-trip test. flavor: The flavor of the WOFF data. The options are CFF or TTF. """ print "Compiling %s..." % identifier assert identifier not in registeredIdentifiers, "Duplicate identifier! %s" % identifier assert title not in registeredTitles, "Duplicate title! %s" % title assert description not in registeredDescriptions, "Duplicate description! %s" % description registeredIdentifiers.add(identifier) registeredTitles.add(title) registeredDescriptions.add(description) specLink = expandSpecLinks(specLink) # generate the SFNT if roundTrip: sfntPath = os.path.join(decoderTestDirectory, identifier) if flavor == "CFF": sfntPath += ".otf" else: sfntPath += ".ttf" f = open(sfntPath, "wb") f.write(data[1]) f.close() data = data[0] woffPath = os.path.join(decoderTestDirectory, identifier) + ".woff2" f = open(woffPath, "wb") f.write(data) f.close() # register the test tag = identifier.split("-")[0] testRegistry[tag].append( dict(identifier=identifier, title=title, description=description, roundTrip=roundTrip, specLink=specLink))
def writeTest(identifier, title, description, data, specLink=None, credits=[], roundTrip=False, flavor="CFF"): """ This function generates all of the files needed by a test case and registers the case with the suite. The arguments: identifier: The identifier for the test case. The identifier must be a - separated sequence of group name (from the groupDefinitions listed above), test case description (arbitrary length) and a number to make the name unique. The number should be zero padded to a length of three characters (ie "001" instead of "1"). title: A thorough, but not too long, title for the test case. description: A detailed statement about what the test case is proving. data: The complete binary data for either the WOFF, or both WOFF and SFNT. specLink: The anchor in the WOFF spec that the test case is testing. credits: A list of dictionaries defining the credits for the test case. The dictionaries must have this form: title="Name of the autor or reviewer", role="author or reviewer", link="mailto:email or http://contactpage" roundTrip: A boolean indicating if this is a round-trip test. flavor: The flavor of the WOFF data. The options are CFF or TTF. """ print "Compiling %s..." % identifier assert identifier not in registeredIdentifiers, "Duplicate identifier! %s" % identifier assert title not in registeredTitles, "Duplicate title! %s" % title assert description not in registeredDescriptions, "Duplicate description! %s" % description registeredIdentifiers.add(identifier) registeredTitles.add(title) registeredDescriptions.add(description) specLink = expandSpecLinks(specLink) # generate the SFNT if roundTrip: sfntPath = os.path.join(decoderTestDirectory, identifier) if flavor == "CFF": sfntPath += ".otf" else: sfntPath += ".ttf" f = open(sfntPath, "wb") f.write(data[1]) f.close() data = data[0] woffPath = os.path.join(decoderTestDirectory, identifier) + ".woff2" f = open(woffPath, "wb") f.write(data) f.close() # register the test tag = identifier.split("-")[0] testRegistry[tag].append( dict( identifier=identifier, title=title, description=description, roundTrip=roundTrip, specLink=specLink ) )
""".strip() tableDirectoryNote = """ These files are valid SFNTs that excercise conversion of the table directory. """.strip() bitwiseNote = """ These files are provided as test cases for checking that the result of converting to WOFF and back to SFNT results in a file that is bitwise identical to the original SFNT. """.strip() groupDefinitions = [ # identifier, title, spec section, category note ("validsfnt", "Valid SFNTs", None, validNote), ("invalidsfnt", "Invalid SFNT Tests", expandSpecLinks("#conform-incorrect-reject"), invalidSFNTNote), ("tabledata", "SFNT Table Data Tests", expandSpecLinks("#DataTables"), tableDataNote), ("tabledirectory", "SFNT Table Directory Tests", expandSpecLinks("#DataTables"), tableDirectoryNote), ("bitwiseidentical", "SFNT Bitwise Identical Tests", expandSpecLinks("#conform-identical"), bitwiseNote), ] testRegistry = {} for group in groupDefinitions: tag = group[0] testRegistry[tag] = [] # ----------------- # Test Case Writing # ----------------- registeredIdentifiers = set()
tableDirectoryNote = """ These files are valid SFNTs that excercise conversion of the table directory. """.strip() bitwiseNote = """ These files are provided as test cases for checking that the result of converting to WOFF and back to SFNT results in a file that is bitwise identical to the original SFNT. """.strip() groupDefinitions = [ # identifier, title, spec section, category note ("validsfnt", "Valid SFNTs", None, validNote), ("invalidsfnt", "Invalid SFNT Tests", expandSpecLinks("#conform-incorrect-reject"), invalidSFNTNote), ("tabledata", "SFNT Table Data Tests", expandSpecLinks("#DataTables"), tableDataNote), ("tabledirectory", "SFNT Table Directory Tests", expandSpecLinks("#DataTables"), tableDirectoryNote), ("bitwiseidentical", "SFNT Bitwise Identical Tests", expandSpecLinks("#conform-identical"), bitwiseNote), ] testRegistry = {} for group in groupDefinitions: tag = group[0] testRegistry[tag] = [] # ----------------- # Test Case Writing
tableDataNote = """ These files are valid SFNTs that excercise conversion of the table data. """.strip() tableDirectoryNote = """ These files are valid SFNTs that excercise conversion of the table directory. """.strip() collectionNote = """ These files are valid SFNTs that excercise conversion of font collections. """.strip() groupDefinitions = [ # identifier, title, spec section, category note ("tabledirectory", "SFNT Table Directory Tests", expandSpecLinks("#DataTables"), tableDirectoryNote), ("tabledata", "SFNT Table Data Tests", expandSpecLinks("#DataTables"), tableDataNote), ("collection", "SFNT Collection Tests", expandSpecLinks("#DataTables"), collectionNote), ] testRegistry = {} for group in groupDefinitions: tag = group[0] testRegistry[tag] = [] # ----------------- # Test Case Writing # ----------------- registeredIdentifiers = set() registeredTitles = set()