1.1 --- a/tests/test.py Mon Jun 10 00:46:29 2013 +0100
1.2 +++ b/tests/test.py Mon Jun 10 01:04:43 2013 +0100
1.3 @@ -1,64 +1,64 @@
1.4 -# vim: set ts=2 sw=4 tw=99 ft=python et:
1.5 -import os
1.6 -import os.path
1.7 -
1.8 -class Result:
1.9 - def __init__(self, ok, out, err, code, timeout, message):
1.10 - self.ok = ok
1.11 - self.out = out
1.12 - self.err = err
1.13 - self.code = code
1.14 - self.timeout = timeout
1.15 - self.message = message
1.16 -
1.17 -class Test:
1.18 - def __init__(self, path, name, type):
1.19 - self.path = path
1.20 - self.name = name
1.21 - self.type = type
1.22 -
1.23 - def cmd(self):
1.24 - return os.path.join(self.path, self.name + '.sp')
1.25 -
1.26 - def compare(self, text):
1.27 - ok = True
1.28 - message = None
1.29 - with open(os.path.join(self.path, self.name + '.' + self.type), 'rt') as f:
1.30 - text = str.replace(text, '\r', '')
1.31 - lines = text.split('\n')
1.32 - i = 0
1.33 - for line in f:
1.34 - line = line.rstrip('\r\n')
1.35 - if "Displaying compilation errors for" in lines[i]:
1.36 - i += 1
1.37 - continue
1.38 - if line != lines[i]:
1.39 - message = 'Got "' + lines[i] + '", expected "' + line + '"'
1.40 - ok = False
1.41 - break
1.42 - i += 1
1.43 - return (ok, message)
1.44 -
1.45 - def check(self, out, err, code, timeout):
1.46 - if not out:
1.47 - out = ''
1.48 - if not err:
1.49 - err = ''
1.50 - if self.type == 'err':
1.51 - if code == 0:
1.52 - message = 'Expected failure, got success'
1.53 - ok = False
1.54 - else:
1.55 - (ok, message) = self.compare(err)
1.56 - elif self.type == 'out':
1.57 - if code != 0:
1.58 - message = 'Expected success, got failure (code: ' + str(code) + ')'
1.59 - ok = False
1.60 - else:
1.61 - (ok, message) = self.compare(out)
1.62 -
1.63 - if timeout:
1.64 - ok = False
1.65 - message = 'timeout'
1.66 -
1.67 - return Result(ok, out, err, code, timeout, message)
1.68 +# vim: set ts=2 sw=4 tw=99 ft=python et:
1.69 +import os
1.70 +import os.path
1.71 +
1.72 +class Result:
1.73 + def __init__(self, ok, out, err, code, timeout, message):
1.74 + self.ok = ok
1.75 + self.out = out
1.76 + self.err = err
1.77 + self.code = code
1.78 + self.timeout = timeout
1.79 + self.message = message
1.80 +
1.81 +class Test:
1.82 + def __init__(self, path, name, type):
1.83 + self.path = path
1.84 + self.name = name
1.85 + self.type = type
1.86 +
1.87 + def cmd(self):
1.88 + return os.path.join(self.path, self.name + '.sp')
1.89 +
1.90 + def compare(self, text):
1.91 + ok = True
1.92 + message = None
1.93 + with open(os.path.join(self.path, self.name + '.' + self.type), 'rt') as f:
1.94 + text = str.replace(text, '\r', '')
1.95 + lines = text.split('\n')
1.96 + i = 0
1.97 + for line in f:
1.98 + line = line.rstrip('\r\n')
1.99 + if "Displaying compilation errors for" in lines[i]:
1.100 + i += 1
1.101 + continue
1.102 + if line != lines[i]:
1.103 + message = 'Got "' + lines[i] + '", expected "' + line + '"'
1.104 + ok = False
1.105 + break
1.106 + i += 1
1.107 + return (ok, message)
1.108 +
1.109 + def check(self, out, err, code, timeout):
1.110 + if not out:
1.111 + out = ''
1.112 + if not err:
1.113 + err = ''
1.114 + if self.type == 'err':
1.115 + if code == 0:
1.116 + message = 'Expected failure, got success'
1.117 + ok = False
1.118 + else:
1.119 + (ok, message) = self.compare(err)
1.120 + elif self.type == 'out':
1.121 + if code != 0:
1.122 + message = 'Expected success, got failure (code: ' + str(code) + ')'
1.123 + ok = False
1.124 + else:
1.125 + (ok, message) = self.compare(out)
1.126 +
1.127 + if timeout:
1.128 + ok = False
1.129 + message = 'timeout'
1.130 +
1.131 + return Result(ok, out, err, code, timeout, message)