donate-cpu/test-my-pr: Minor fixes (PEP 8, old Python 2 code, ...) (#2499)

* donate-cpu/test-my-pr: Minor fixes (PEP 8, old Python 2 code, ...)

* test-my-pr.py: Add Python 3 shebang
This commit is contained in:
Sebastian 2020-01-21 14:27:39 +01:00 committed by GitHub
parent 9f26e8a356
commit d8e0f40663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 20 deletions

View File

@ -150,7 +150,7 @@ while True:
sys.exit(1)
for ver in cppcheck_versions:
if ver == 'head':
if not compile(cppcheck_path, jobs):
if not compile_cppcheck(cppcheck_path, jobs):
print('Failed to compile Cppcheck, retry later')
sys.exit(1)
elif not compile_version(work_path, jobs, ver):

View File

@ -13,7 +13,7 @@ import tarfile
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes)
CLIENT_VERSION = "1.1.41"
CLIENT_VERSION = "1.1.42"
def check_requirements():
@ -88,7 +88,7 @@ def compile_version(work_path, jobs, version):
return True
def compile(cppcheck_path, jobs):
def compile_cppcheck(cppcheck_path, jobs):
print('Compiling Cppcheck..')
try:
os.chdir(cppcheck_path)
@ -127,7 +127,7 @@ def get_packages_count(server_address):
return packages
def get_package(server_address, package_index = None):
def get_package(server_address, package_index=None):
print('Connecting to server to get assigned work..')
package = b''
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@ -237,12 +237,6 @@ def has_include(path, includes):
else:
f = open(filename, 'rt', errors='ignore')
filedata = f.read()
try:
# Python2 needs to decode the data first
filedata = filedata.decode(encoding='utf-8', errors='ignore')
except AttributeError:
# Python3 directly reads the data into a string object that has no decode()
pass
f.close()
if re.search(re_expr, filedata, re.MULTILINE):
return True
@ -291,7 +285,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries):
sig_num = int(stderr[sig_start_pos:stderr.find(' ', sig_start_pos)])
print('cppcheck finished with ' + str(returncode) + ('' if sig_num == -1 else ' (signal ' + str(sig_num) + ')'))
# generate stack trace for SIGSEGV, SIGABRT, SIGILL, SIGFPE, SIGBUS
if returncode in (-11,-6,-4,-8,-7) or sig_num in (11,6,4,8,7):
if returncode in (-11, -6, -4, -8, -7) or sig_num in (11, 6, 4, 8, 7):
print('Crash!')
stacktrace = ''
if cppcheck_path == 'cppcheck':
@ -393,13 +387,13 @@ def diff_results(work_path, ver1, results1, ver2, results2):
def send_all(connection, data):
bytes = data.encode('ascii', 'ignore')
while bytes:
num = connection.send(bytes)
if num < len(bytes):
bytes = bytes[num:]
bytes_ = data.encode('ascii', 'ignore')
while bytes_:
num = connection.send(bytes_)
if num < len(bytes_):
bytes_ = bytes_[num:]
else:
bytes = None
bytes_ = None
def upload_results(package, results, server_address):

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Run this script from your branch with proposed Cppcheck patch to verify your
# patch against current master. It will compare output of testing bunch of
@ -49,12 +50,12 @@ if __name__ == "__main__":
print('Failed to switch to common ancestor of your branch and master')
sys.exit(1)
if not lib.compile(master_dir, jobs):
if not lib.compile_cppcheck(master_dir, jobs):
print('Failed to compile master of Cppcheck')
sys.exit(1)
print('Testing your PR from directory: ' + your_repo_dir)
if not lib.compile(your_repo_dir, jobs):
if not lib.compile_cppcheck(your_repo_dir, jobs):
print('Failed to compile your version of Cppcheck')
sys.exit(1)
@ -118,7 +119,7 @@ if __name__ == "__main__":
who = 'Master'
else:
who = 'Your'
crashes.append(package + ' ' + who)
crashes.append(package + ' ' + who)
with open(result_file, 'a') as myfile:
myfile.write(package + '\n')