MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Lib/test/bisect_cmd.py:115–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114
115def main():
116 args = parse_args()
117 for opt in ('-w', '--rerun', '--verbose2'):
118 if opt in args.test_args:
119 print(f"WARNING: {opt} option should not be used to bisect!")
120 print()
121
122 if args.input:
123 with open(args.input) as fp:
124 tests = [line.strip() for line in fp]
125 else:
126 tests = list_cases(args)
127
128 print("Start bisection with %s tests" % len(tests))
129 print("Test arguments: %s" % format_shell_args(args.test_args))
130 print("Bisection will stop when getting %s or less tests "
131 "(-n/--max-tests option), or after %s iterations "
132 "(-N/--max-iter option)"
133 % (args.max_tests, args.max_iter))
134 output = write_output(args.output, tests)
135 print()
136
137 start_time = time.monotonic()
138 iteration = 1
139 try:
140 while len(tests) > args.max_tests and iteration <= args.max_iter:
141 ntest = len(tests)
142 ntest = max(ntest // 2, 1)
143 subtests = random.sample(tests, ntest)
144
145 print(f"[+] Iteration {iteration}/{args.max_iter}: "
146 f"run {len(subtests)} tests/{len(tests)}")
147 print()
148
149 exitcode = run_tests(args, subtests)
150
151 print("ran %s tests/%s" % (ntest, len(tests)))
152 print("exit", exitcode)
153 if exitcode:
154 print("Tests failed: continuing with this subtest")
155 tests = subtests
156 output = write_output(args.output, tests)
157 else:
158 print("Tests succeeded: skipping this subtest, trying a new subset")
159 print()
160 iteration += 1
161 except KeyboardInterrupt:
162 print()
163 print("Bisection interrupted!")
164 print()
165
166 print("Tests (%s):" % len(tests))
167 for test in tests:
168 print("* %s" % test)
169 print()
170
171 if output:
172 print("Output written into %s" % output)

Calls 9

format_shell_argsFunction · 0.85
run_testsFunction · 0.85
parse_argsFunction · 0.70
list_casesFunction · 0.70
write_outputFunction · 0.70
openFunction · 0.50
stripMethod · 0.45
sampleMethod · 0.45
exitMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…