Skip to content

Commit 63cb630

Browse files
tools: Rename -p to --max-packages and fix skipped package counter (cppcheck-opensource#8518)
-p was unclear and was in the mutually exclusive group with --packages-path, preventing combined use. This commit renames to -n/--max-packages and move it outside the exclusive group so a package limit can be specified alongside a packages path. Also, this commit fixes incrementing packages_processed when a package was skipped due to a download failure or missing source files. Signed-off-by: Francois Berder <fberder@outlook.fr>
1 parent cf2edfd commit 63cb630

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tools/test-my-pr.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def getpackages():
124124

125125
parser = argparse.ArgumentParser(description='Run this script from your branch with proposed Cppcheck patch to verify your patch against current main. It will compare output of testing bunch of opensource packages')
126126
parser.add_argument('-j', default=1, type=int, help='Concurency execution threads')
127+
parser.add_argument('-n', '--max-packages', default=256, type=int, help='Maximum number of packages to test')
127128
package_group = parser.add_mutually_exclusive_group()
128-
package_group.add_argument('-p', default=256, type=int, help='Count of packages to check')
129129
package_group.add_argument('--packages', nargs='+', help='Check specific packages and then stop.')
130130
package_group.add_argument('--packages-path', default=None, type=str, help='Check packages in path.')
131131
parser.add_argument('-o', default='my_check_diff.log', help='Filename of result inside a working path dir')
@@ -146,6 +146,8 @@ def getpackages():
146146
args.packages = getpackages()
147147
random.shuffle(args.packages)
148148

149+
packages_to_process = min(args.max_packages, len(args.packages))
150+
149151
print('\n'.join(args.packages[:20]))
150152

151153
if not lib.check_requirements():
@@ -212,8 +214,11 @@ def getpackages():
212214
crashes = []
213215
timeouts = []
214216

215-
while packages_processed < args.p and args.packages:
217+
while packages_processed < packages_to_process and args.packages:
216218
package = args.packages.pop()
219+
packages_processed += 1
220+
print('Processing package {} of {}'.format(packages_processed, packages_to_process))
221+
217222

218223
if package.startswith('ftp://') or package.startswith('https://'):
219224
tgz = lib.download_package(work_path, package, None)
@@ -298,9 +303,6 @@ def getpackages():
298303
format_float(time_your), format_float(time_your, time_main),
299304
package_width=package_width, timing_width=timing_width))
300305

301-
packages_processed += 1
302-
print(str(packages_processed) + ' of ' + str(args.p) + ' packages processed\n')
303-
304306
with open(result_file, 'a') as myfile:
305307
myfile.write('\n\ncrashes\n')
306308
myfile.write('\n'.join(crashes))

0 commit comments

Comments
 (0)