Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08a819c

Browse files
author
Ethan
committed
fix: add treeNotSorted test
1 parent6978325 commit08a819c

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

‎test/test_tree.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
fromgit.objectsimportTree,Blob
99
fromtest.libimportTestBase
1010

11+
importos
1112
importos.pathasosp
13+
importsubprocess
1214

1315

1416
classTestTree(TestBase):
@@ -40,6 +42,62 @@ def test_serializable(self):
4042
testtree._deserialize(stream)
4143
# END for each item in tree
4244

45+
deftest_tree_modifier_ordering(self):
46+
defsetup_git_repository_and_get_ordered_files():
47+
os.mkdir("tmp")
48+
os.chdir("tmp")
49+
subprocess.run(["git","init","-q"],check=True)
50+
os.mkdir("file")
51+
forfilenamein [
52+
"bin",
53+
"bin.d",
54+
"file.to",
55+
"file.toml",
56+
"file.toml.bin",
57+
"file0",
58+
"file/a",
59+
]:
60+
open(filename,"a").close()
61+
62+
subprocess.run(["git","add","."],check=True)
63+
subprocess.run(["git","commit","-m","c1"],check=True)
64+
tree_hash=subprocess.check_output(["git","rev-parse","HEAD^{tree}"]).decode().strip()
65+
cat_file_output=subprocess.check_output(["git","cat-file","-p",tree_hash]).decode()
66+
return [line.split()[-1]forlineincat_file_output.split("\n")ifline]
67+
68+
hexsha="6c1faef799095f3990e9970bc2cb10aa0221cf9c"
69+
roottree=self.rorepo.tree(hexsha)
70+
blob_mode=Tree.blob_id<<12
71+
tree_mode=Tree.tree_id<<12
72+
73+
files_in_desired_order= [
74+
(blob_mode,"bin"),
75+
(blob_mode,"bin.d"),
76+
(blob_mode,"file.to"),
77+
(blob_mode,"file.toml"),
78+
(blob_mode,"file.toml.bin"),
79+
(blob_mode,"file0"),
80+
(tree_mode,"file"),
81+
]
82+
mod=roottree.cache
83+
forfile_mode,file_nameinfiles_in_desired_order:
84+
mod.add(hexsha,file_mode,file_name)
85+
# end for each file
86+
87+
deffile_names_in_order():
88+
return [t[1]fortinfiles_in_desired_order]
89+
90+
defnames_in_mod_cache():
91+
a= [t[2]fortinmod._cache]
92+
here=file_names_in_order()
93+
return [eforeinaifeinhere]
94+
95+
git_file_names_in_order=setup_git_repository_and_get_ordered_files()
96+
os.chdir("..")
97+
98+
mod.set_done()
99+
assertnames_in_mod_cache()==git_file_names_in_order,"set_done() performs git-sorting"
100+
43101
deftest_traverse(self):
44102
root=self.rorepo.tree("0.1.6")
45103
num_recursive=0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp