##// END OF EJS Templates
tests: ignore test-storage when using Rust...
Raphaël Gomès -
r52123:f9a52a96 default
parent child Browse files
Show More
@@ -1,167 +1,178 b''
1 # This test verifies the conformance of various classes to various
1 # This test verifies the conformance of various classes to various
2 # storage interfaces.
2 # storage interfaces.
3
3
4 import silenttestrunner
4 import silenttestrunner
5
5
6 from mercurial import (
6 from mercurial import (
7 error,
7 error,
8 filelog,
8 filelog,
9 revlog,
9 revlog,
10 transaction,
10 transaction,
11 ui as uimod,
11 ui as uimod,
12 vfs as vfsmod,
12 vfs as vfsmod,
13 )
13 )
14
14
15 from mercurial.testing import storage as storagetesting
15 from mercurial.testing import storage as storagetesting
16
16
17 try:
17 try:
18 from mercurial import rustext
19
20 rustext.__name__
21 # Does not pass with pure Rust index
22 import sys
23
24 sys.exit(80)
25 except ImportError:
26 pass
27
28 try:
18 from hgext import sqlitestore
29 from hgext import sqlitestore
19 except ImportError:
30 except ImportError:
20 sqlitestore = None
31 sqlitestore = None
21
32
22 try:
33 try:
23 import sqlite3
34 import sqlite3
24
35
25 if sqlite3.sqlite_version_info < (3, 8, 3):
36 if sqlite3.sqlite_version_info < (3, 8, 3):
26 # WITH clause not supported
37 # WITH clause not supported
27 sqlitestore = None
38 sqlitestore = None
28 except ImportError:
39 except ImportError:
29 pass
40 pass
30
41
31 try:
42 try:
32 from mercurial import zstd
43 from mercurial import zstd
33
44
34 zstd.__version__
45 zstd.__version__
35 except ImportError:
46 except ImportError:
36 zstd = None
47 zstd = None
37
48
38 STATE = {
49 STATE = {
39 'lastindex': 0,
50 'lastindex': 0,
40 'ui': uimod.ui(),
51 'ui': uimod.ui(),
41 'vfs': vfsmod.vfs(b'.', realpath=True),
52 'vfs': vfsmod.vfs(b'.', realpath=True),
42 }
53 }
43
54
44
55
45 def makefilefn(self):
56 def makefilefn(self):
46 """Factory for filelog instances."""
57 """Factory for filelog instances."""
47 fl = filelog.filelog(STATE['vfs'], b'filelog-%d' % STATE['lastindex'])
58 fl = filelog.filelog(STATE['vfs'], b'filelog-%d' % STATE['lastindex'])
48 STATE['lastindex'] += 1
59 STATE['lastindex'] += 1
49 return fl
60 return fl
50
61
51
62
52 def maketransaction(self):
63 def maketransaction(self):
53 vfsmap = {b'plain': STATE['vfs'], b'store': STATE['vfs']}
64 vfsmap = {b'plain': STATE['vfs'], b'store': STATE['vfs']}
54
65
55 return transaction.transaction(
66 return transaction.transaction(
56 STATE['ui'].warn, STATE['vfs'], vfsmap, b'journal', b'undo'
67 STATE['ui'].warn, STATE['vfs'], vfsmap, b'journal', b'undo'
57 )
68 )
58
69
59
70
60 def addrawrevision(
71 def addrawrevision(
61 self,
72 self,
62 fl,
73 fl,
63 tr,
74 tr,
64 node,
75 node,
65 p1,
76 p1,
66 p2,
77 p2,
67 linkrev,
78 linkrev,
68 rawtext=None,
79 rawtext=None,
69 delta=None,
80 delta=None,
70 censored=False,
81 censored=False,
71 ellipsis=False,
82 ellipsis=False,
72 extstored=False,
83 extstored=False,
73 ):
84 ):
74 flags = 0
85 flags = 0
75
86
76 if censored:
87 if censored:
77 flags |= revlog.REVIDX_ISCENSORED
88 flags |= revlog.REVIDX_ISCENSORED
78 if ellipsis:
89 if ellipsis:
79 flags |= revlog.REVIDX_ELLIPSIS
90 flags |= revlog.REVIDX_ELLIPSIS
80 if extstored:
91 if extstored:
81 flags |= revlog.REVIDX_EXTSTORED
92 flags |= revlog.REVIDX_EXTSTORED
82
93
83 if rawtext is not None:
94 if rawtext is not None:
84 fl._revlog.addrawrevision(rawtext, tr, linkrev, p1, p2, node, flags)
95 fl._revlog.addrawrevision(rawtext, tr, linkrev, p1, p2, node, flags)
85 elif delta is not None:
96 elif delta is not None:
86 fl._revlog.addrawrevision(
97 fl._revlog.addrawrevision(
87 rawtext, tr, linkrev, p1, p2, node, flags, cachedelta=delta
98 rawtext, tr, linkrev, p1, p2, node, flags, cachedelta=delta
88 )
99 )
89 else:
100 else:
90 raise error.Abort('must supply rawtext or delta arguments')
101 raise error.Abort('must supply rawtext or delta arguments')
91
102
92 # We may insert bad data. Clear caches to prevent e.g. cache hits to
103 # We may insert bad data. Clear caches to prevent e.g. cache hits to
93 # bypass hash verification.
104 # bypass hash verification.
94 fl._revlog.clearcaches()
105 fl._revlog.clearcaches()
95
106
96
107
97 # Assigning module-level attributes that inherit from unittest.TestCase
108 # Assigning module-level attributes that inherit from unittest.TestCase
98 # is all that is needed to register tests.
109 # is all that is needed to register tests.
99 filelogindextests = storagetesting.makeifileindextests(
110 filelogindextests = storagetesting.makeifileindextests(
100 makefilefn, maketransaction, addrawrevision
111 makefilefn, maketransaction, addrawrevision
101 )
112 )
102 filelogdatatests = storagetesting.makeifiledatatests(
113 filelogdatatests = storagetesting.makeifiledatatests(
103 makefilefn, maketransaction, addrawrevision
114 makefilefn, maketransaction, addrawrevision
104 )
115 )
105 filelogmutationtests = storagetesting.makeifilemutationtests(
116 filelogmutationtests = storagetesting.makeifilemutationtests(
106 makefilefn, maketransaction, addrawrevision
117 makefilefn, maketransaction, addrawrevision
107 )
118 )
108
119
109
120
110 def makesqlitefile(self):
121 def makesqlitefile(self):
111 path = STATE['vfs'].join(b'db-%d.db' % STATE['lastindex'])
122 path = STATE['vfs'].join(b'db-%d.db' % STATE['lastindex'])
112 STATE['lastindex'] += 1
123 STATE['lastindex'] += 1
113
124
114 db = sqlitestore.makedb(path)
125 db = sqlitestore.makedb(path)
115
126
116 compression = b'zstd' if zstd else b'zlib'
127 compression = b'zstd' if zstd else b'zlib'
117
128
118 return sqlitestore.sqlitefilestore(db, b'dummy-path', compression)
129 return sqlitestore.sqlitefilestore(db, b'dummy-path', compression)
119
130
120
131
121 def addrawrevisionsqlite(
132 def addrawrevisionsqlite(
122 self,
133 self,
123 fl,
134 fl,
124 tr,
135 tr,
125 node,
136 node,
126 p1,
137 p1,
127 p2,
138 p2,
128 linkrev,
139 linkrev,
129 rawtext=None,
140 rawtext=None,
130 delta=None,
141 delta=None,
131 censored=False,
142 censored=False,
132 ellipsis=False,
143 ellipsis=False,
133 extstored=False,
144 extstored=False,
134 ):
145 ):
135 flags = 0
146 flags = 0
136
147
137 if censored:
148 if censored:
138 flags |= sqlitestore.FLAG_CENSORED
149 flags |= sqlitestore.FLAG_CENSORED
139
150
140 if ellipsis | extstored:
151 if ellipsis | extstored:
141 raise error.Abort(
152 raise error.Abort(
142 b'support for ellipsis and extstored flags not ' b'supported'
153 b'support for ellipsis and extstored flags not ' b'supported'
143 )
154 )
144
155
145 if rawtext is not None:
156 if rawtext is not None:
146 fl._addrawrevision(node, rawtext, tr, linkrev, p1, p2, flags=flags)
157 fl._addrawrevision(node, rawtext, tr, linkrev, p1, p2, flags=flags)
147 elif delta is not None:
158 elif delta is not None:
148 fl._addrawrevision(
159 fl._addrawrevision(
149 node, rawtext, tr, linkrev, p1, p2, storedelta=delta, flags=flags
160 node, rawtext, tr, linkrev, p1, p2, storedelta=delta, flags=flags
150 )
161 )
151 else:
162 else:
152 raise error.Abort(b'must supply rawtext or delta arguments')
163 raise error.Abort(b'must supply rawtext or delta arguments')
153
164
154
165
155 if sqlitestore is not None:
166 if sqlitestore is not None:
156 sqlitefileindextests = storagetesting.makeifileindextests(
167 sqlitefileindextests = storagetesting.makeifileindextests(
157 makesqlitefile, maketransaction, addrawrevisionsqlite
168 makesqlitefile, maketransaction, addrawrevisionsqlite
158 )
169 )
159 sqlitefiledatatests = storagetesting.makeifiledatatests(
170 sqlitefiledatatests = storagetesting.makeifiledatatests(
160 makesqlitefile, maketransaction, addrawrevisionsqlite
171 makesqlitefile, maketransaction, addrawrevisionsqlite
161 )
172 )
162 sqlitefilemutationtests = storagetesting.makeifilemutationtests(
173 sqlitefilemutationtests = storagetesting.makeifilemutationtests(
163 makesqlitefile, maketransaction, addrawrevisionsqlite
174 makesqlitefile, maketransaction, addrawrevisionsqlite
164 )
175 )
165
176
166 if __name__ == '__main__':
177 if __name__ == '__main__':
167 silenttestrunner.main(__name__)
178 silenttestrunner.main(__name__)
General Comments 0
You need to be logged in to leave comments. Login now