Debian Codegraph @

auto_test.py

raw
1 # !/usr/bin/python
2 # -*- coding: UTF-8 -i*-
3 # Copyright (C) 2013-14, Sneha Kore <[email protected]>, Pravin Satpute <[email protected]>
4 # This script requires hb-shape utility from available in harfbuzz-devel rpm
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 import os,sys,subprocess
20
21 def auto_test(txt_file,ttf_file):
22 inputfile=open(txt_file)
23 outputfile=open("failed_test_case.txt","w")
24
25 #Read the test-case input
26 flines=inputfile.readlines()
27 count=0
28
29 #Exceute hb-shape command for each test-case from output file
30 for string in flines:
31 words=string.split()
32 status, output = subprocess.getstatusoutput("hb-shape %s %s"%(ttf_file,words[0]))
33 # Test to check, wheather test-case from output file & the result, are matching
34 if words[1] != output:
35 print(words[0]+ " [FAILURE]\n")
36 outputfile.write(" * "+words[0]+"\t"+""+output+"\n")
37 count=count+1
38
39 #Count for failed test-cases
40 print("%d Test Cases Failed out of %d"%(count,len(flines)))
41 print("failed_test_case.txt file generated !!")
42 inputfile.close()
43 outputfile.close()
44
45 if __name__ == "__main__":
46
47 if len(sys.argv) < 3:
48 print(" USAGE: python test.py <test file> <font_file> ")
49 else:
50 txt_file = sys.argv[1]
51 font_file = sys.argv[2]
52 auto_test(txt_file,font_file)