test-my-pr: add option --c-only

This commit is contained in:
Daniel Marjamäki 2022-09-05 11:32:17 +02:00
parent 363dd309fd
commit 7bb2bd3ca0
2 changed files with 11 additions and 6 deletions

View File

@ -15,7 +15,7 @@ import shlex
# 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.3.33"
CLIENT_VERSION = "1.3.34"
# Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 30 * 60
@ -303,18 +303,22 @@ def download_package(work_path, package, bandwidth_limit):
return destfile
def unpack_package(work_path, tgz, cpp_only=False, skip_files=None):
def unpack_package(work_path, tgz, cpp_only=False, c_only=False, skip_files=None):
print('Unpacking..')
temp_path = os.path.join(work_path, 'temp')
__remove_tree(temp_path)
os.mkdir(temp_path)
header_endings = ('.hpp', '.h++', '.hxx', '.hh', '.h')
source_endings = ('.cpp', '.c++', '.cxx', '.cc', '.tpp', '.txx', '.ipp', '.ixx', '.qml')
cpp_source_endings = ('.cpp', '.c++', '.cxx', '.cc', '.tpp', '.txx', '.ipp', '.ixx', '.qml')
c_source_endings = ('.c',)
if not cpp_only:
source_endings = source_endings + c_source_endings
if cpp_only:
source_endings = cpp_source_endings
elif c_only:
source_endings = c_source_endings
else:
source_endings = cpp_source_endings + c_source_endings
source_found = False
if tarfile.is_tarfile(tgz):

View File

@ -26,6 +26,7 @@ if __name__ == "__main__":
group.add_argument('-p', default=256, type=int, help='Count of packages to check')
group.add_argument('--packages', nargs='+', help='Check specific packages and then stop.')
parser.add_argument('-o', default='my_check_diff.log', help='Filename of result inside a working path dir')
parser.add_argument('--c-only', dest='c_only', help='Only process c packages', action='store_true')
parser.add_argument('--cpp-only', dest='cpp_only', help='Only process c++ packages', action='store_true')
parser.add_argument('--work-path', '--work-path=', default=lib.work_path, type=str, help='Working directory for reference repo')
args = parser.parse_args()
@ -123,7 +124,7 @@ if __name__ == "__main__":
print("No package downloaded")
continue
source_path, source_found = lib.unpack_package(work_path, tgz, args.cpp_only)
source_path, source_found = lib.unpack_package(work_path, tgz, c_only=args.c_only, cpp_only=args.cpp_only)
if not source_found:
print("No files to process")
continue