File: auto_test.py

package info (click to toggle)
fonts-lohit-beng-assamese 2.91.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,132 kB
  • ctags: 5
  • sloc: makefile: 54; xml: 54; python: 39
file content (52 lines) | stat: -rw-r--r-- 1,836 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# !/usr/bin/python
# -*- coding: UTF-8 -i*-
# Copyright (C) 2013-14, Sneha Kore <skore@redhat.com>, Pravin Satpute <psatpute@redhat.com>
# This script requires hb-shape utility from available in harfbuzz-devel rpm

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os,sys,subprocess

def auto_test(txt_file,ttf_file):
	inputfile=open(txt_file)
	outputfile=open("failed_test_case.txt","w")

	#Read the test-case input
	flines=inputfile.readlines()
	count=0

	#Exceute hb-shape command for each test-case from output file
	for string in flines:
		words=string.split()
		status, output = subprocess.getstatusoutput("hb-shape %s %s"%(ttf_file,words[0]))
		# Test to check, wheather test-case from output file & the result, are matching
		if words[1] != output:
			print(words[0]+ " [FAILURE]\n")
			outputfile.write("  *  "+words[0]+"\t"+""+output+"\n")
			count=count+1

	#Count for failed test-cases
	print("%d Test Cases Failed out of %d"%(count,len(flines)))
	print("failed_test_case.txt file generated !!")
	inputfile.close()
	outputfile.close()

if __name__ == "__main__":

	if len(sys.argv) < 3:
		print(" USAGE: python test.py <test file> <font_file> ")
	else:
		txt_file = sys.argv[1]
		font_file = sys.argv[2]
		auto_test(txt_file,font_file)