Skip to content

Possibly an incorrect value in a test in diff.DIFF_IDENT #2372

@GildedHonour

Description

@GildedHonour

A test at https://github.com/iterative/dvc/blob/master/tests/func/test_diff.py#L207 passes correctly. However, it seems that there's a bug in it:

# [............]
def setUp(self):
    # [............]


    self.a_ref = self.git.git.rev_parse(self.git.head.commit, short=True)
    self.old_checksum = _get_checksum(self.dvc, self.DATA_DIR)
    self.new_file_content = "new_test_file_bigger_content_123456789"
    self.diff_len = len(self.new_file_content)
    self.create(self.new_file, self.new_file_content)
    self.dvc.add(self.DATA_DIR)
    self.git.index.add([self.DATA_DIR + ".dvc"])
    self.git.index.commit(message="modify file in the data dir")
    self.new_checksum = _get_checksum(self.dvc, self.DATA_DIR)
    self.b_ref = self.git.git.rev_parse(self.git.head.commit, short=True)

def test(self):
    result = self.dvc.diff(self.a_ref, target=self.DATA_DIR)
    test_dct = {
        diff.DIFF_A_REF: self.git.git.rev_parse(self.a_ref, short=True),
        diff.DIFF_B_REF: self.git.git.rev_parse(self.b_ref, short=True),
        diff.DIFF_LIST: [
            {
                diff.DIFF_IDENT: 2,  # <------
                diff.DIFF_CHANGE: 1,
                diff.DIFF_DEL: 0,
                diff.DIFF_MOVE: 0,
                diff.DIFF_NEW: 0,
                # [.............]

            }
        ],
    }
    self.assertEqual(test_dct, result)

And

class TestDiffDir(TestDvcGit):
    def setUp(self):
        super(TestDiffDir, self).setUp()


        self.dvc.add(self.DATA_DIR)
        self.git.index.add([self.DATA_DIR + ".dvc"])
        self.git.index.commit("adds data_dir")
        self.a_ref = self.git.git.rev_parse(
            self.dvc.scm.git.head.commit, short=True
        )
        self.old_checksum = _get_checksum(self.dvc, self.DATA_DIR)
        self.new_file = os.path.join(self.DATA_SUB_DIR, diff.DIFF_NEW_FILE)
        self.create(self.new_file, self.new_file)
        self.dvc.add(self.DATA_DIR)
        self.git.index.add([self.DATA_DIR + ".dvc"])
        self.git.index.commit(message="adds data_dir with new_file")
        self.new_checksum = _get_checksum(self.dvc, self.DATA_DIR)

There're creating a directory, a file in it and changing a file. And there're 3 commits.

My understanding is that diff.DIFF_IDENT -- the number of untouched files -- is supposed to be equal to either 0 or 1, and not 2.

dvc --version
0.53.2+b78843

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDid we break something?good first issuep2-mediumMedium priority, should be done, but less important

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions