mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
Make tree.walk() output deterministic
This commit is contained in:
@@ -296,6 +296,11 @@ def dvc_walk(top, dvcignore, topdown=True, onerror=None, followlinks=False):
|
||||
for root, dirs, files in os.walk(
|
||||
top, topdown=topdown, onerror=onerror, followlinks=followlinks
|
||||
):
|
||||
# Dirs are returned in arbitrary order on different platforms. Force a
|
||||
# specific order so that we can make deterministic assumptions on the
|
||||
# directory order.
|
||||
# https://stackoverflow.com/a/54773660/2966951
|
||||
dirs.sort()
|
||||
|
||||
if dvcignore:
|
||||
dirs[:], files[:] = dvcignore(root, dirs, files)
|
||||
|
||||
@@ -118,13 +118,13 @@ class TestWalkInNoSCM(AssertWalkEqualMixin, TestDir):
|
||||
["lib", "data_dir"],
|
||||
["code.py", "bar", "тест", "foo"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
(join(self._root_dir, "data_dir"), ["data_sub_dir"], ["data"]),
|
||||
(
|
||||
join(self._root_dir, "data_dir", "data_sub_dir"),
|
||||
[],
|
||||
["data_sub"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -155,13 +155,13 @@ class TestWalkInGit(AssertWalkEqualMixin, TestGit):
|
||||
["lib", "data_dir"],
|
||||
["bar", "тест", "code.py", "foo"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
(join(self._root_dir, "data_dir"), ["data_sub_dir"], ["data"]),
|
||||
(
|
||||
join(self._root_dir, "data_dir", "data_sub_dir"),
|
||||
[],
|
||||
["data_sub"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
],
|
||||
)
|
||||
self.assertWalkEqual(
|
||||
|
||||
Reference in New Issue
Block a user