MCPcopy
hub / github.com/django/django / bisect_tests

Function bisect_tests

tests/runtests.py:444–490  ·  view source on GitHub ↗
(bisection_label, options, test_labels, start_at, start_after)

Source from the content-addressed store, hash-verified

442
443
444def bisect_tests(bisection_label, options, test_labels, start_at, start_after):
445 if not test_labels:
446 test_labels = collect_test_modules(start_at, start_after)
447
448 print("***** Bisecting test suite: %s" % " ".join(test_labels))
449
450 # Make sure the bisection point isn't in the test list
451 # Also remove tests that need to be run in specific combinations
452 for label in [bisection_label, "model_inheritance_same_model_name"]:
453 try:
454 test_labels.remove(label)
455 except ValueError:
456 pass
457
458 subprocess_args = get_subprocess_args(options)
459
460 iteration = 1
461 while len(test_labels) > 1:
462 midpoint = len(test_labels) // 2
463 test_labels_a = test_labels[:midpoint] + [bisection_label]
464 test_labels_b = test_labels[midpoint:] + [bisection_label]
465 print("***** Pass %da: Running the first half of the test suite" % iteration)
466 print("***** Test labels: %s" % " ".join(test_labels_a))
467 failures_a = subprocess.run(subprocess_args + test_labels_a)
468
469 print("***** Pass %db: Running the second half of the test suite" % iteration)
470 print("***** Test labels: %s" % " ".join(test_labels_b))
471 print("")
472 failures_b = subprocess.run(subprocess_args + test_labels_b)
473
474 if failures_a.returncode and not failures_b.returncode:
475 print("***** Problem found in first half. Bisecting again...")
476 iteration += 1
477 test_labels = test_labels_a[:-1]
478 elif failures_b.returncode and not failures_a.returncode:
479 print("***** Problem found in second half. Bisecting again...")
480 iteration += 1
481 test_labels = test_labels_b[:-1]
482 elif failures_a.returncode and failures_b.returncode:
483 print("***** Multiple sources of failure found")
484 break
485 else:
486 print("***** No source of failure found... try pair execution (--pair)")
487 break
488
489 if len(test_labels) == 1:
490 print("***** Source of error: %s" % test_labels[0])
491
492
493def paired_tests(paired_test, options, test_labels, start_at, start_after):

Callers 1

runtests.pyFile · 0.85

Calls 5

collect_test_modulesFunction · 0.85
get_subprocess_argsFunction · 0.85
joinMethod · 0.45
removeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected