threads / discuss / 63356

Workflow for bisecting with test in a branch

Subject: Workflow for bisecting with test in a branch

## tl;dr

2 messages between Apr 27, 2025 and Apr 28, 2025.

replies: 1people: 2as markdown or json

Victor Engmark· Apr 27, 2025, 08:18 UTC · lore

I'd like to bisect using a test I've written in a different branch from the one I'm bisecting. But to do `git bisect run ./test.bash` I have to keep the new test file and an old test suite file the same during the whole `bisect` process. This turned out pretty cumbersome:

test.bash:

``` #!/usr/bin/env bash

set -o errexit

git show my-test-branch:test-suite-path > test-suite-path mkdir -p test-dir git show my-test-branch:test-dir/test-file > test-dir/test-file

run_test || exit_code=$? git checkout . exit "${exit_code-0}" ```

Console session:

``` git bisect start my-test-branch known-good-ancestor git bisect run ./test.bash ```

Is there a more streamlined way to achieve the same thing, that is, forcing some checked-in files to not change while bisecting?

Kind regards Victor Engmark

Christian Couder· Apr 28, 2025, 07:41 UTC · re: Victor Engmark · lore

Re: Workflow for bisecting with test in a branch

On Sun, Apr 27, 2025 at 10:18 AM Victor Engmark <victor@engmark.name> wrote:
Show 5 quoted lines
>
> I'd like to bisect using a test I've written in a different branch from
> the one I'm bisecting. But to do `git bisect run ./test.bash` I have to
> keep the new test file and an old test suite file the same during the
> whole `bisect` process. This turned out pretty cumbersome:
[...]
> Is there a more streamlined way to achieve the same thing, that is,
> forcing some checked-in files to not change while bisecting?

You could perhaps use worktrees (see https://git-scm.com/docs/git-worktree) to have a separate worktree with the checked-in files that shouldn't change, while performing the bisection and building in the main worktree. If all the needed files and directories are properly set up on the separate worktree, you could copy them over using a single `cp -a ...` command.

Also I think that conceptually it's more the responsibility of your build and test system, rather than the SCM, to provide you with clean, out of source builds and tests.

Best, Christian.

← back to recent threads