Whitespaces [#CLICKHOUSE-2].

This commit is contained in:
Alexey Milovidov 2017-09-16 18:55:31 +03:00
parent bf5ef11933
commit 65ad717938

View File

@ -123,9 +123,9 @@ def main(args):
try: try:
print "{0:70}".format(name + ": "), print "{0:70}".format(name + ": "),
sys.stdout.flush() sys.stdout.flush()
print 1/0 print 1/0
if not args.zookeeper and 'zookeeper' in name: if not args.zookeeper and 'zookeeper' in name:
report_testcase.append(et.Element("skipped", attrib = {"message": "no zookeeper"})) report_testcase.append(et.Element("skipped", attrib = {"message": "no zookeeper"}))
print(MSG_SKIPPED + " - no zookeeper") print(MSG_SKIPPED + " - no zookeeper")
@ -136,27 +136,27 @@ def main(args):
reference_file = os.path.join(suite_dir, name) + '.reference' reference_file = os.path.join(suite_dir, name) + '.reference'
stdout_file = os.path.join(suite_dir, name) + '.stdout' stdout_file = os.path.join(suite_dir, name) + '.stdout'
stderr_file = os.path.join(suite_dir, name) + '.stderr' stderr_file = os.path.join(suite_dir, name) + '.stderr'
if ext == '.sql': if ext == '.sql':
command = "{0} --multiquery < {1} > {2} 2> {3}".format(args.client, case_file, stdout_file, stderr_file) command = "{0} --multiquery < {1} > {2} 2> {3}".format(args.client, case_file, stdout_file, stderr_file)
else: else:
command = "{0} > {1} 2> {2}".format(case_file, stdout_file, stderr_file) command = "{0} > {1} 2> {2}".format(case_file, stdout_file, stderr_file)
proc = Popen(command, shell = True) proc = Popen(command, shell = True)
start_time = datetime.now() start_time = datetime.now()
while (datetime.now() - start_time).total_seconds() < args.timeout and proc.poll() is None: while (datetime.now() - start_time).total_seconds() < args.timeout and proc.poll() is None:
sleep(0) sleep(0)
if proc.returncode is None: if proc.returncode is None:
try: try:
proc.kill() proc.kill()
except OSError as e: except OSError as e:
if e.errno != ESRCH: if e.errno != ESRCH:
raise raise
failure = et.Element("failure", attrib = {"message": "Timeout"}) failure = et.Element("failure", attrib = {"message": "Timeout"})
report_testcase.append(failure) report_testcase.append(failure)
failures = failures + 1 failures = failures + 1
print("{0} - Timeout!".format(MSG_FAIL)) print("{0} - Timeout!".format(MSG_FAIL))
else: else:
@ -164,45 +164,45 @@ def main(args):
stdout = unicode(stdout, errors='replace', encoding='utf-8') stdout = unicode(stdout, errors='replace', encoding='utf-8')
stderr = open(stderr_file, 'r').read() if os.path.exists(stderr_file) else '' stderr = open(stderr_file, 'r').read() if os.path.exists(stderr_file) else ''
stderr = unicode(stderr, errors='replace', encoding='utf-8') stderr = unicode(stderr, errors='replace', encoding='utf-8')
if proc.returncode != 0: if proc.returncode != 0:
failure = et.Element("failure", attrib = {"message": "return code {}".format(proc.returncode)}) failure = et.Element("failure", attrib = {"message": "return code {}".format(proc.returncode)})
report_testcase.append(failure) report_testcase.append(failure)
stdout_element = et.Element("system-out") stdout_element = et.Element("system-out")
stdout_element.text = et.CDATA(stdout) stdout_element.text = et.CDATA(stdout)
report_testcase.append(stdout_element) report_testcase.append(stdout_element)
failures = failures + 1 failures = failures + 1
print("{0} - return code {1}".format(MSG_FAIL, proc.returncode)) print("{0} - return code {1}".format(MSG_FAIL, proc.returncode))
if stderr: if stderr:
stderr_element = et.Element("system-err") stderr_element = et.Element("system-err")
stderr_element.text = et.CDATA(stderr) stderr_element.text = et.CDATA(stderr)
report_testcase.append(stderr_element) report_testcase.append(stderr_element)
print(stderr) print(stderr)
if args.stop and ('Connection refused' in stderr or 'Attempt to read after eof' in stderr) and not 'Received exception from server' in stderr: if args.stop and ('Connection refused' in stderr or 'Attempt to read after eof' in stderr) and not 'Received exception from server' in stderr:
SERVER_DIED = True SERVER_DIED = True
elif stderr: elif stderr:
failure = et.Element("failure", attrib = {"message": "having stderror"}) failure = et.Element("failure", attrib = {"message": "having stderror"})
report_testcase.append(failure) report_testcase.append(failure)
stderr_element = et.Element("system-err") stderr_element = et.Element("system-err")
stderr_element.text = et.CDATA(stderr) stderr_element.text = et.CDATA(stderr)
report_testcase.append(stderr_element) report_testcase.append(stderr_element)
failures = failures + 1 failures = failures + 1
print("{0} - having stderror:\n{1}".format(MSG_FAIL, stderr.encode('utf-8'))) print("{0} - having stderror:\n{1}".format(MSG_FAIL, stderr.encode('utf-8')))
elif 'Exception' in stdout: elif 'Exception' in stdout:
failure = et.Element("error", attrib = {"message": "having exception"}) failure = et.Element("error", attrib = {"message": "having exception"})
report_testcase.append(failure) report_testcase.append(failure)
stdout_element = et.Element("system-out") stdout_element = et.Element("system-out")
stdout_element.text = et.CDATA(stdout) stdout_element.text = et.CDATA(stdout)
report_testcase.append(stdout_element) report_testcase.append(stdout_element)
failures = failures + 1 failures = failures + 1
print("{0} - having exception:\n{1}".format(MSG_FAIL, stdout.encode('utf-8'))) print("{0} - having exception:\n{1}".format(MSG_FAIL, stdout.encode('utf-8')))
elif not os.path.isfile(reference_file): elif not os.path.isfile(reference_file):
@ -211,20 +211,20 @@ def main(args):
print("{0} - no reference file".format(MSG_UNKNOWN)) print("{0} - no reference file".format(MSG_UNKNOWN))
else: else:
result_is_different = subprocess.call(['cmp', '-s', reference_file, stdout_file], stdout = PIPE) result_is_different = subprocess.call(['cmp', '-s', reference_file, stdout_file], stdout = PIPE)
if result_is_different: if result_is_different:
(diff, _) = Popen(['diff', '--side-by-side', reference_file, stdout_file], stdout = PIPE).communicate() (diff, _) = Popen(['diff', '--side-by-side', reference_file, stdout_file], stdout = PIPE).communicate()
diff = unicode(diff, errors='replace', encoding='utf-8') diff = unicode(diff, errors='replace', encoding='utf-8')
failure = et.Element("failure", attrib = {"message": "result differs with reference"}) failure = et.Element("failure", attrib = {"message": "result differs with reference"})
report_testcase.append(failure) report_testcase.append(failure)
stdout_element = et.Element("system-out") stdout_element = et.Element("system-out")
try: try:
stdout_element.text = et.CDATA(diff) stdout_element.text = et.CDATA(diff)
except: except:
stdout_element.text = et.CDATA(remove_control_characters(diff)) stdout_element.text = et.CDATA(remove_control_characters(diff))
report_testcase.append(stdout_element) report_testcase.append(stdout_element)
failures = failures + 1 failures = failures + 1
print("{0} - result differs with reference:\n{1}".format(MSG_FAIL, diff.encode('utf-8'))) print("{0} - result differs with reference:\n{1}".format(MSG_FAIL, diff.encode('utf-8')))