55import tempfile
66import shutil
77from pathlib import Path
8+ import subprocess
89
910
1011class TestV8Unpack (unittest .TestCase ):
@@ -17,19 +18,21 @@ def setUp(self):
1718
1819 pathIb = path .join (path .curdir , ".git" , "hooks" , "ibService" )
1920 if (path .exists (pathIb )):
20- shutil .rmtree (pathIb )
21+ shutil .rmtree (pathIb )
2122 shutil .copytree (path .join (path .curdir , "ibService" ),
22- pathIb )
23- shutil .copy (path .join (path .curdir , "V8Reader.epf" ),
24- path .join (path .curdir , ".git" , "hooks" , "V8Reader.epf" ))
23+ pathIb )
24+ os .mkdir (path .join (path .curdir , ".git" , "hooks" , "v8Reader" ))
25+ shutil .copy (path .join (path .curdir , "v8Reader" , "V8Reader.epf" ),
26+ path .join (path .curdir , ".git" , "hooks" , "v8Reader" , "V8Reader.epf" ))
2527
2628 def tearDown (self ):
2729
2830 if os .path .exists (self .tfile ):
2931 os .remove (self .tfile )
3032 shutil .rmtree (self .tpath )
3133 shutil .rmtree (path .join (path .curdir , ".git" , "hooks" , "ibService" ))
32- os .remove (path .join (path .curdir , ".git" , "hooks" , "V8Reader.epf" ))
34+ os .remove (path .join (path .curdir , ".git" , "hooks" , "v8Reader" , "V8Reader.epf" ))
35+ shutil .rmtree (path .join (path .curdir , ".git" , "hooks" , "v8Reader" ))
3336
3437
3538 def test_compile_from_source (self ):
@@ -53,3 +56,58 @@ def test_decompile_checkfullpath(self):
5356 self .tpath = tempfile .mkdtemp ()
5457 file = path .join (path .curdir , "tests" , "Fixture.epf" )
5558 assert pyv8unpack .decompile ([file ], self .tpath );
59+
60+
61+ class TestGitInit (unittest .TestCase ):
62+
63+ def setUp (self ):
64+ unittest .TestCase .setUp (self )
65+ self .tpath = tempfile .mkdtemp ()
66+ self .curdir = os .path .abspath (os .curdir );
67+
68+ print ("cur dir {}, temp path {}" .format (self .curdir , self .tpath ))
69+
70+ os .chdir (self .tpath )
71+
72+ try :
73+ output = subprocess .check_output (['git' ,'init' , self .tpath ]
74+ ).decode ("utf-8" )
75+ except subprocess .CalledProcessError :
76+ print ("Error diff files get: trace %s" % subprocess .CalledProcessError .output )
77+
78+ pathIb = path .join (self .tpath , ".git" , "hooks" , "ibService" )
79+ if (path .exists (pathIb )):
80+ shutil .rmtree (pathIb )
81+ shutil .copytree (path .join (self .curdir , "ibService" ),
82+ pathIb )
83+ os .mkdir (path .join (self .tpath , ".git" , "hooks" , "v8Reader" ))
84+ shutil .copy (path .join (self .curdir , "v8Reader" , "V8Reader.epf" ),
85+ path .join (self .tpath , ".git" , "hooks" , "v8Reader" , "V8Reader.epf" ))
86+ shutil .copy (path .join (self .curdir ,"pre-commit" ),
87+ path .join (self .tpath , ".git" , "hooks" , "pre-commit" ))
88+ shutil .copy (path .join (self .curdir ,"pyv8unpack.py" ),
89+ path .join (self .tpath , ".git" , "hooks" , "pyv8unpack.py" ))
90+
91+
92+ def tearDown (self ):
93+
94+ #shutil.rmtree(self.tpath)
95+ os .chdir (self .curdir )
96+ print ("cur dir {}" .format (os .curdir ))
97+
98+ def test_firstadd (self ):
99+ file = path .join (self .curdir , "tests" , "Fixture.epf" )
100+ shutil .copy (file ,
101+ path .join (self .tpath , "Fixture.epf" ))
102+
103+
104+ output = subprocess .check_output (['git' ,'add' , "-A" , "." ]
105+ ).decode ("utf-8" )
106+ print ("output {}" .format (output ))
107+ output = subprocess .check_output (['git' ,'commit' , "-m" , "'init commit'" ]
108+ ).decode ("utf-8" )
109+ print ("output {}" .format (output ))
110+
111+
112+
113+
0 commit comments