def METHOD_NAME(testargs, good, bad, commits_to_skip, custom_script):
    ###############################################################################
    logger.info("####################################################")
    logger.info("TESTING WITH ARGS '{}'".format(testargs))
    logger.info("####################################################")
    if os.path.exists("scripts/create_test"):
        create_test = os.path.join(os.getcwd(), "scripts", "create_test")
    else:
        create_test = os.path.join(os.getcwd(), "cime", "scripts", "create_test")
    expect(os.path.exists(create_test), "Please run the root of a CIME repo")
    # Basic setup
    run_cmd_no_fail("git bisect start")
    run_cmd_no_fail("git bisect good {}".format(good), verbose=True)
    run_cmd_no_fail("git bisect bad {}".format(bad), verbose=True)
    if commits_to_skip:
        run_cmd_no_fail("git bisect skip {}".format(" ".join(commits_to_skip)))
    # Formulate the create_test command, let create_test make the test-id, it will use
    # a timestamp that will allow us to avoid collisions
    thing_to_run = (
        custom_script if custom_script else "{} {}".format(create_test, testargs)
    )
    bisect_cmd = "git submodule update --recursive && {}".format(thing_to_run)
    if not custom_script:
        is_batch = False
        try:
            from CIME.XML.machines import Machines
            machine = Machines()
            is_batch = machine.has_batch_system()
        except:
            pass
        if (
            is_batch
            and "--no-run" not in testargs
            and "--no-build" not in testargs
            and "--no-setup" not in testargs
        ):
            expect(
                "--wait" in testargs,
                "Your create_test command likely needs --wait to work correctly with bisect",
            )
    try:
        cmd = "git bisect run sh -c '{}'".format(bisect_cmd)
        output = run_cmd(cmd, verbose=True)[1]
        # Get list of potentially bad commits from output
        lines = output.splitlines()
        regex = re.compile(r"^([a-f0-9]{40}).*$")
        bad_commits = set(
            [regex.match(line).groups()[0] for line in lines if regex.match(line)]
        )
        bad_commits_filtered = bad_commits - commits_to_skip
        expect(len(bad_commits_filtered) == 1, bad_commits_filtered)
        logger.info("####################################################")
        logger.info("BAD MERGE FOR ARGS '{}' IS:".format(testargs))
        logger.info("####################################################")
        logger.warning(
            run_cmd_no_fail("git show {}".format(bad_commits_filtered.pop()))
        )
    finally:
        run_cmd_no_fail("git bisect reset && git submodule update --recursive")