5
5
import tempfile
6
6
import shutil
7
7
from pathlib import Path
8
+ import subprocess
8
9
9
10
10
11
class TestV8Unpack (unittest .TestCase ):
@@ -17,19 +18,21 @@ def setUp(self):
17
18
18
19
pathIb = path .join (path .curdir , ".git" , "hooks" , "ibService" )
19
20
if (path .exists (pathIb )):
20
- shutil .rmtree (pathIb )
21
+ shutil .rmtree (pathIb )
21
22
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" ))
25
27
26
28
def tearDown (self ):
27
29
28
30
if os .path .exists (self .tfile ):
29
31
os .remove (self .tfile )
30
32
shutil .rmtree (self .tpath )
31
33
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" ))
33
36
34
37
35
38
def test_compile_from_source (self ):
@@ -53,3 +56,58 @@ def test_decompile_checkfullpath(self):
53
56
self .tpath = tempfile .mkdtemp ()
54
57
file = path .join (path .curdir , "tests" , "Fixture.epf" )
55
58
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