libccd/libccd-2.1-py3.patch
2023-06-06 15:58:41 +08:00

159 lines
6.9 KiB
Diff

diff -up ./src/testsuites/cu/check-regressions.py3 ./src/testsuites/cu/check-regressions
--- ./src/testsuites/cu/check-regressions.py3 2020-04-18 14:23:18.757771743 -0400
+++ ./src/testsuites/cu/check-regressions 2020-04-18 14:23:56.070249408 -0400
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
##
# CU - C unit testing framework
# ---------------------------------
@@ -88,7 +88,7 @@ class Hunk:
if self.numLinesAdded() != self.numLinesDeleted():
return False
- for i in xrange(0, self.numLinesAdded()):
+ for i in range(0, self.numLinesAdded()):
# if any line does not contain number - return False because
# there must be more differences than in numbers
if not self.re_is_num.match(self.added[i]) \
@@ -102,8 +102,8 @@ class Hunk:
nums1 = self.re_num.findall(line1)
nums2 = self.re_num.findall(line2)
# and remove all empty strings
- nums1 = filter(lambda x: len(x) > 0, nums1)
- nums2 = filter(lambda x: len(x) > 0, nums2)
+ nums1 = [x for x in nums1 if len(x) > 0]
+ nums2 = [x for x in nums2 if len(x) > 0]
# if length of list nums1 does not equal to length of nums2
# return False
@@ -111,7 +111,7 @@ class Hunk:
return False
# iterate trough all numbers
- for j in xrange(0, len(nums1)):
+ for j in range(0, len(nums1)):
# if numbers do not equal to each other return False
if not self.__eq(float(nums1[j]), float(nums2[j])):
return False
@@ -177,7 +177,7 @@ class Parser:
self.re_deleted = re.compile(r"^< (.*)$")
def __readNextLine(self):
- self.line = self.fin.readline()
+ self.line = self.fin.readline().decode('utf-8')
if len(self.line) == 0:
return False
return True
@@ -210,7 +210,7 @@ class Parser:
num_lines += 1
if PROGRESS_ON and num_lines % 50 == 0:
- print MSG_BASE, "[ %08d ]" % num_lines, "\r",
+ print(MSG_BASE, "[ %08d ]" % num_lines, "\r", end=' ')
sys.stdout.flush()
# last push to list of hunks
@@ -218,7 +218,7 @@ class Parser:
self.diff.addHunk(self.cur_hunk)
if PROGRESS_ON:
- print MSG_BASE, " ", "\r",
+ print(MSG_BASE, " ", "\r", end=' ')
sys.stdout.flush()
def getDiff(self):
@@ -262,26 +262,26 @@ def regressionFilesInDir():
def MSG(str = "", wait = False):
if wait:
- print str,
+ print(str, end=' ')
else:
- print str
+ print(str)
def MSGOK(prestr = "", str = "", poststr = ""):
- print prestr, "\033[0;32m" + str + "\033[0;0m", poststr
+ print(prestr, "\033[0;32m" + str + "\033[0;0m", poststr)
def MSGFAIL(prestr = "", str = "", poststr = ""):
- print prestr, "\033[0;31m" + str + "\033[0;0m", poststr
+ print(prestr, "\033[0;31m" + str + "\033[0;0m", poststr)
def MSGINFO(prestr = "", str = "", poststr = ""):
- print prestr, "\033[0;33m" + str + "\033[0;0m", poststr
+ print(prestr, "\033[0;33m" + str + "\033[0;0m", poststr)
def dumpLines(lines, prefix = "", wait = False, max_lines = -1):
line_num = 0
if wait:
for line in lines:
- print prefix, line,
+ print(prefix, line, end=' ')
line_num += 1
if max_lines >= 0 and line_num > max_lines:
break
else:
for line in lines:
- print prefix, line
+ print(prefix, line)
line_num += 1
if max_lines >= 0 and line_num > max_lines:
break
@@ -308,7 +308,7 @@ def main(files):
MSG_BASE = "Comparing %s and %s" % \
(filenames[0].ljust(len1) ,filenames[1].ljust(len2))
if not PROGRESS_ON:
- print MSG_BASE,
+ print(MSG_BASE, end=' ')
sys.stdout.flush()
pipe = Popen(cmd, stdout=PIPE)
@@ -319,7 +319,7 @@ def main(files):
diff.checkFloats()
if PROGRESS_ON:
- print MSG_BASE,
+ print(MSG_BASE, end=' ')
if diff.numHunks() == 0:
MSGOK(" [", "OK", "]")
@@ -345,23 +345,23 @@ def main(files):
dumpLines(lines, " |", True, MAX_DIFF_LINES)
def usage():
- print "Usage: " + sys.argv[0] + " [ OPTIONS ] [ directory, [ directory, [ ... ] ] ]"
- print ""
- print " OPTIONS:"
- print " --help / -h none Print this help"
- print " --exact / -e none Switch do exact comparasion of files"
- print " --not-exact / -n none Switch do non exact comparasion of files (default behaviour)"
- print " --max-diff-lines int Maximum of lines of diff which can be printed (default " + str(MAX_DIFF_LINES) + ")"
- print " --eps float Precision of floating point numbers (epsilon) (default " + str(EPS) + ")"
- print " --no-progress none Turn off progress bar"
- print " --progress none Turn on progress bar (default)"
- print ""
- print " This program is able to compare files with regressions generated by CU testsuites."
- print " You can specify directories which are to be searched for regression files."
- print " In non exact copmarasion mode (which is default), this program tries to compare"
- print " floating point numbers in files with respect to specified precision (see --eps) and"
- print " those lines which differ only in precission of floating point numbers are omitted."
- print ""
+ print("Usage: " + sys.argv[0] + " [ OPTIONS ] [ directory, [ directory, [ ... ] ] ]")
+ print("")
+ print(" OPTIONS:")
+ print(" --help / -h none Print this help")
+ print(" --exact / -e none Switch do exact comparasion of files")
+ print(" --not-exact / -n none Switch do non exact comparasion of files (default behaviour)")
+ print(" --max-diff-lines int Maximum of lines of diff which can be printed (default " + str(MAX_DIFF_LINES) + ")")
+ print(" --eps float Precision of floating point numbers (epsilon) (default " + str(EPS) + ")")
+ print(" --no-progress none Turn off progress bar")
+ print(" --progress none Turn on progress bar (default)")
+ print("")
+ print(" This program is able to compare files with regressions generated by CU testsuites.")
+ print(" You can specify directories which are to be searched for regression files.")
+ print(" In non exact copmarasion mode (which is default), this program tries to compare")
+ print(" floating point numbers in files with respect to specified precision (see --eps) and")
+ print(" those lines which differ only in precission of floating point numbers are omitted.")
+ print("")
sys.exit(-1)