I continued working on packaging the “Hyphenation-dictionary” for reftests. Instead of creating a new directory and store the dictionaru files, we can pick up the files which already exists in this directory tree. Previously, packaging the hyphenation dictionary was designed exactly like how we package the fonts for reftests. We had all the fonts in a single directory and appended this directory path to the “extraProfileFiles” in mach_commands.py. Now we have the hyphenation dictionaries in same directory tree but in different directories, classified based on the language. We cannot append the “extraProfileFile” with the directory name. Instead we can add (append) it as separate files to the list “extraProfileFiles”.
The base path of the dictionaries is /intl/hyphenation/. A simple directory walk is performed and dictionary’s path is identified by the extension of the file “.dic”. We add all the 36 dictionary files to the list.
hyphenation_path = os.path.join(self.topsrcdir, "intl", "locales")
for (dirpath, dirnames, filenames) in os.walk(hyphenation_path):
for filename in filenames:
if filename.endswith('.dic'):
kwargs["extraProfileFiles"].append(os.path.join(dirpath, filename))
After adding the hyphenation dictionary files to the “extraProfileFiles” list in mach_commands.py. We get the list of file path and create a new temporary directory “hyphenation” under the “Profile Directory” and copy the dictionaries from the “extraProfileFiles” list to the Profile Directory. This is done in runreftest.py.
def copyExtraFilesToProfile(self, options, profile):
"Copy extra files or dirs specified on the command line to the testing profile."
profileDir = profile.profile
if not os.path.exists(os.path.join(profileDir, "hyphenation")):
os.makedirs(os.path.join(profileDir, "hyphenation"))
for f in options.extraProfileFiles:
abspath = self.getFullPath(f)
if os.path.isfile(abspath):
if os.path.basename(abspath) == 'user.js':
extra_prefs = mozprofile.Preferences.read_prefs(abspath)
profile.set_preferences(extra_prefs)
elif os.path.basename(abspath).endswith('.dic'):
shutil.copy2(abspath, os.path.join(profileDir, "hyphenation"))
else:
shutil.copy2(abspath, profileDir)
elif os.path.isdir(abspath):
dest = os.path.join(profileDir, os.path.basename(abspath))
shutil.copytree(abspath, dest)
else:
self.log.warning(
"runreftest.py | Failed to copy %s to profile" % abspath)
continue
By modifying the above files now we are able to package the hyphenation-dictionaries separately for reftests without creating new directory and introducing a redundancy.