commit: make sure deps/outs exist (#4305)

Fixes #4266
This commit is contained in:
Ruslan Kuprieiev
2020-07-30 16:09:00 +03:00
committed by GitHub
parent 815444ffdc
commit 9592246746
4 changed files with 33 additions and 6 deletions
+20
View File
@@ -2,7 +2,9 @@ from os import fspath
import pytest
from dvc.dependency.base import DependencyDoesNotExistError
from dvc.dvcfile import PIPELINE_FILE
from dvc.output.base import OutputDoesNotExistError
from dvc.stage.exceptions import StageCommitError
from dvc.utils.yaml import dump_yaml, load_yaml
@@ -86,6 +88,24 @@ def test_commit_no_exec(tmp_dir, dvc):
assert dvc.status(stage.path) == {}
def test_commit_no_exec_missing_dep(tmp_dir, dvc):
stage = dvc.run(
name="my", cmd="mycmd", deps=["dep"], outs=["out"], no_exec=True
)
assert dvc.status(stage.path)
with pytest.raises(DependencyDoesNotExistError):
dvc.commit(stage.path, force=True)
def test_commit_no_exec_missing_out(tmp_dir, dvc):
stage = dvc.run(name="my", cmd="mycmd", outs=["out"], no_exec=True)
assert dvc.status(stage.path)
with pytest.raises(OutputDoesNotExistError):
dvc.commit(stage.path, force=True)
def test_commit_pipeline_stage(tmp_dir, dvc, run_copy):
tmp_dir.gen("foo", "foo")
stage = run_copy("foo", "bar", no_commit=True, name="copy-foo-bar")