outputs: validate that output is not ignored (#4386)

This commit is contained in:
Paweł Redzyński
2020-08-14 14:30:12 +03:00
committed by GitHub
parent 00925029b4
commit 35f125f3df
4 changed files with 35 additions and 5 deletions
+8
View File
@@ -5,6 +5,7 @@ import pytest
from dvc.exceptions import DvcIgnoreInCollectedDirError
from dvc.ignore import DvcIgnore, DvcIgnorePatterns
from dvc.output.base import OutputIsIgnoredError
from dvc.path_info import PathInfo
from dvc.pathspec_math import PatternInfo, merge_patterns
from dvc.repo import Repo
@@ -400,3 +401,10 @@ def test_ignore_in_added_dir(tmp_dir, dvc):
dvc.checkout()
assert not ignored_path.exists()
def test_ignored_output(tmp_dir, scm, dvc, run_copy):
tmp_dir.gen({".dvcignore": "*.log", "foo": "foo content"})
with pytest.raises(OutputIsIgnoredError):
run_copy("foo", "foo.log", name="copy")
+6
View File
@@ -5,6 +5,7 @@ from funcy import first
from voluptuous import MultipleInvalid, Schema
from dvc.cache import NamedCache
from dvc.ignore import _no_match
from dvc.output import CHECKSUM_SCHEMA, BaseOutput
@@ -72,6 +73,11 @@ def test_get_used_cache(exists, expected_message, mocker, caplog):
stage = mocker.MagicMock()
mocker.patch.object(stage, "__str__", return_value="stage: 'stage.dvc'")
mocker.patch.object(stage, "addressing", "stage.dvc")
mocker.patch.object(
stage.repo.tree.dvcignore,
"check_ignore",
return_value=_no_match("path"),
)
output = BaseOutput(stage, "path")