Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/func/experiments/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DVC_STUDIO_URL,
)
from dvc.exceptions import DvcException, ReproductionError
from dvc.repo import Repo
from dvc.repo.experiments.exceptions import ExperimentExistsError
from dvc.repo.experiments.queue.base import BaseStashQueue
from dvc.repo.experiments.refs import CELERY_STASH
Expand Down Expand Up @@ -808,3 +809,25 @@ def test_experiments_run_with_submodule_dependencies(dvc, scm, make_tmp_dir, dep
dvc.stage.add(cmd="echo foo", deps=[dep], name="foo")

assert dvc.experiments.run()


def test_experiments_run_in_linked_git_worktree(
dvc, scm, tmp_path_factory: pytest.TempPathFactory, monkeypatch
):
from dulwich.worktree import add_worktree

wt = tmp_path_factory.mktemp("worktrees") / "worktree"
add_worktree(scm.dulwich.repo, wt, branch="wt-main")

monkeypatch.chdir(wt)

wt_dvc = Repo(os.fspath(wt))
(wt / "foo").write_bytes(b"foo")
wt_dvc.stage.add(cmd="cp foo bar", deps=["foo"], outs=["bar"], name="cp")

results = wt_dvc.experiments.run(name="my-exp")
assert results
rev = first(results)
assert rev
# If `bar` exists, we know that the stage was run.
assert (wt / "bar").read_bytes() == b"foo"
Loading