Skip to content

Commit 956bb3c

Browse files
authored
test-my-pr: use --packages-path if you want to check packages in a path (#5077)
1 parent 6d2662b commit 956bb3c

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

tools/test-my-pr.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import donate_cpu_lib as lib
99
import argparse
10+
import glob
1011
import os
1112
import sys
1213
import random
@@ -28,6 +29,7 @@ def format_float(a, b=1):
2829
package_group = parser.add_mutually_exclusive_group()
2930
package_group.add_argument('-p', default=256, type=int, help='Count of packages to check')
3031
package_group.add_argument('--packages', nargs='+', help='Check specific packages and then stop.')
32+
package_group.add_argument('--packages-path', default=None, type=str, help='Check packages in path.')
3133
parser.add_argument('-o', default='my_check_diff.log', help='Filename of result inside a working path dir')
3234

3335
language_group = parser.add_mutually_exclusive_group()
@@ -102,7 +104,13 @@ def format_float(a, b=1):
102104
print('Failed to compile your version of Cppcheck')
103105
sys.exit(1)
104106

105-
if args.packages:
107+
if args.packages_path:
108+
# You can download packages using daca2-download.py
109+
args.packages = glob.glob(os.path.join(args.packages_path, '*.tar.xz'))
110+
args.p = len(args.packages)
111+
packages_idxs = list(range(args.p))
112+
random.shuffle(packages_idxs)
113+
elif args.packages:
106114
args.p = len(args.packages)
107115
packages_idxs = []
108116
else:
@@ -124,10 +132,13 @@ def format_float(a, b=1):
124132
else:
125133
package = lib.get_package(packages_idxs.pop())
126134

127-
tgz = lib.download_package(work_path, package, None)
128-
if tgz is None:
129-
print("No package downloaded")
130-
continue
135+
if package.startswith('ftp://') or package.startswith('http://'):
136+
tgz = lib.download_package(work_path, package, None)
137+
if tgz is None:
138+
print("No package downloaded")
139+
continue
140+
else:
141+
tgz = package
131142

132143
source_path, source_found = lib.unpack_package(work_path, tgz, c_only=args.c_only, cpp_only=args.cpp_only)
133144
if not source_found:

0 commit comments

Comments
 (0)