|
Packit |
20facb |
# !/usr/bin/python
|
|
Packit |
20facb |
# -*- coding: UTF-8 -i*-
|
|
Packit |
20facb |
# Copyright (C) 2013-14, Sneha Kore <skore@redhat.com>, Pravin Satpute <psatpute@redhat.com>
|
|
Packit |
20facb |
# This script requires hb-shape utility from available in harfbuzz-devel rpm
|
|
Packit |
20facb |
|
|
Packit |
20facb |
# This program is free software: you can redistribute it and/or modify
|
|
Packit |
20facb |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
20facb |
# the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
20facb |
# (at your option) any later version.
|
|
Packit |
20facb |
|
|
Packit |
20facb |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
20facb |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
20facb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
20facb |
# GNU General Public License for more details.
|
|
Packit |
20facb |
|
|
Packit |
20facb |
# You should have received a copy of the GNU General Public License
|
|
Packit |
20facb |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
20facb |
|
|
Packit |
20facb |
import os,sys,subprocess
|
|
Packit |
20facb |
|
|
Packit |
20facb |
def auto_test(txt_file,ttf_file):
|
|
Packit |
20facb |
inputfile=open(txt_file)
|
|
Packit |
20facb |
outputfile=open("failed_test_case.txt","w")
|
|
Packit |
20facb |
|
|
Packit |
20facb |
#Read the test-case input
|
|
Packit |
20facb |
flines=inputfile.readlines()
|
|
Packit |
20facb |
count=0
|
|
Packit |
20facb |
|
|
Packit |
20facb |
#Exceute hb-shape command for each test-case from output file
|
|
Packit |
20facb |
for string in flines:
|
|
Packit |
20facb |
words=string.split()
|
|
Packit |
20facb |
status, output = subprocess.getstatusoutput("hb-shape %s %s"%(ttf_file,words[0]))
|
|
Packit |
20facb |
# Test to check, wheather test-case from output file & the result, are matching
|
|
Packit |
20facb |
if words[1] != output:
|
|
Packit |
20facb |
print(words[0]+ " [FAILURE]\n")
|
|
Packit |
20facb |
outputfile.write(" * "+words[0]+"\t"+""+output+"\n")
|
|
Packit |
20facb |
count=count+1
|
|
Packit |
20facb |
|
|
Packit |
20facb |
#Count for failed test-cases
|
|
Packit |
20facb |
print("%d Test Cases Failed out of %d"%(count,len(flines)))
|
|
Packit |
20facb |
print("failed_test_case.txt file generated !!")
|
|
Packit |
20facb |
inputfile.close()
|
|
Packit |
20facb |
outputfile.close()
|
|
Packit |
20facb |
|
|
Packit |
20facb |
if __name__ == "__main__":
|
|
Packit |
20facb |
|
|
Packit |
20facb |
if len(sys.argv) < 3:
|
|
Packit |
20facb |
print(" USAGE: python test.py <test file> <font_file> ")
|
|
Packit |
20facb |
else:
|
|
Packit |
20facb |
txt_file = sys.argv[1]
|
|
Packit |
20facb |
font_file = sys.argv[2]
|
|
Packit |
20facb |
auto_test(txt_file,font_file)
|