rename FileOption to FilenameOption
[tiramisu.git] / test / test_config_big_example.py
1 ##just a proof of concept with a lot of options and option groups
2 #import autopath
3 #from tiramisu.config import *
4 #from tiramisu.option import *
5
6 #all_modules = ['amon', 'sphynx', 'zephir']
7
8 #example__optiondescription = OptionDescription("objspace", "Object Space Options", [
9 #    ChoiceOption("name", "Object Space name",
10 #                 ["std", "flow", "thunk", "dump", "taint"],
11 #                 "std"),
12
13 #    OptionDescription("opcodes", "opcodes to enable in the interpreter", [
14 #        BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
15 #                   default=False,
16 #                   requires=[("translation.stackless", False)]),
17 #        BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
18 #                   default=False),
19 #        ]),
20
21 #    BoolOption("nofaking", "disallow faking in the object space",
22 #               default=False,
23 #               requires=[
24 #                   ("objspace.usemodules.posix", True),
25 #                   ("objspace.usemodules.time", True),
26 #                   ("objspace.usemodules.errno", True)],
27 #               ),
28
29 #    OptionDescription("usemodules", "Which Modules should be used", [
30 #        BoolOption(modname, "use module %s" % (modname, ),
31 #                   default=True,
32 #                   requires= [('amon', False)],
33 #                   )
34 #        for modname in all_modules]),
35
36 #    BoolOption("allworkingmodules", "use as many working modules as possible",
37 #               default=True,
38 #               ),
39
40 #    BoolOption("translationmodules",
41 #          "use only those modules that are needed to run translate.py on pypy",
42 #               default=False,
43 #               ),
44
45 #    BoolOption("geninterp", "specify whether geninterp should be used",
46 #               default=True),
47
48 #    BoolOption("logbytecodes",
49 #               "keep track of bytecode usage",
50 #               default=False),
51
52 #    BoolOption("usepycfiles", "Write and read pyc files when importing",
53 #               default=True),
54
55 #    BoolOption("lonepycfiles", "Import pyc files with no matching py file",
56 #               default=False,
57 #               requires=[("objspace.usepycfiles", True)]),
58
59 #    StrOption("soabi",
60 #              "Tag to differentiate extension modules built for different Python interpreters",
61 #              default=None),
62
63 #    BoolOption("honor__builtins__",
64 #               "Honor the __builtins__ key of a module dictionary",
65 #               default=False),
66
67 #    BoolOption("disable_call_speedhacks",
68 #               "make sure that all calls go through space.call_args",
69 #               default=False),
70
71 #    BoolOption("timing",
72 #               "timing of various parts of the interpreter (simple profiling)",
73 #               default=False),
74
75 #    OptionDescription("std", "Standard Object Space Options", [
76 #        BoolOption("withtproxy", "support transparent proxies",
77 #                   default=True),
78
79 #        BoolOption("withsmallint", "use tagged integers",
80 #                   default=False,
81 #                   requires=[("objspace.std.withprebuiltint", False),
82 #                             ("translation.taggedpointers", True)]),
83
84 #        BoolOption("withprebuiltint", "prebuild commonly used int objects",
85 #                   default=False),
86
87 #        IntOption("prebuiltintfrom", "lowest integer which is prebuilt",
88 #                  default=-5),
89
90 #        IntOption("prebuiltintto", "highest integer which is prebuilt",
91 #                  default=100),
92
93 #        BoolOption("withstrjoin", "use strings optimized for addition",
94 #                   default=False),
95
96 #        BoolOption("withstrslice", "use strings optimized for slicing",
97 #                   default=False),
98
99 #        BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
100 #                   default=False),
101
102 #        BoolOption("withprebuiltchar",
103 #                   "use prebuilt single-character string objects",
104 #                   default=False),
105
106 #        BoolOption("sharesmallstr",
107 #                   "always reuse the prebuilt string objects "
108 #                   "(the empty string and potentially single-char strings)",
109 #                   default=False),
110
111 #        BoolOption("withrope", "use ropes as the string implementation",
112 #                   default=False,
113 #                   requires=[("objspace.std.withstrslice", False),
114 #                             ("objspace.std.withstrjoin", False),
115 #                             ("objspace.std.withstrbuf", False)],
116 #                   ),
117
118 #        BoolOption("withropeunicode", "use ropes for the unicode implementation",
119 #                   default=False,
120 #                   requires=[("objspace.std.withrope", True)]),
121
122 #        BoolOption("withcelldict",
123 #                   "use dictionaries that are optimized for being used as module dicts",
124 #                   default=False,
125 #                   requires=[("objspace.opcodes.CALL_LIKELY_BUILTIN", False),
126 #                             ("objspace.honor__builtins__", False)]),
127
128 #        BoolOption("withdictmeasurement",
129 #                   "create huge files with masses of information "
130 #                   "about dictionaries",
131 #                   default=False),
132
133 #        BoolOption("withmapdict",
134 #                   "make instances really small but slow without the JIT",
135 #                   default=False,
136 #                   requires=[("objspace.std.getattributeshortcut", True),
137 #                             ("objspace.std.withtypeversion", True),
138 #                       ]),
139
140 #        BoolOption("withrangelist",
141 #                   "enable special range list implementation that does not "
142 #                   "actually create the full list until the resulting "
143 #                   "list is mutated",
144 #                   default=False),
145
146 #        BoolOption("withtypeversion",
147 #                   "version type objects when changing them",
148 #                   default=False,
149 #                   # weakrefs needed, because of get_subclasses()
150 #                   requires=[("translation.rweakref", True)]),
151
152 #        BoolOption("withmethodcache",
153 #                   "try to cache method lookups",
154 #                   default=False,
155 #                   requires=[("objspace.std.withtypeversion", True),
156 #                             ("translation.rweakref", True)]),
157 #        BoolOption("withmethodcachecounter",
158 #                   "try to cache methods and provide a counter in __pypy__. "
159 #                   "for testing purposes only.",
160 #                   default=False,
161 #                   requires=[("objspace.std.withmethodcache", True)]),
162 #        IntOption("methodcachesizeexp",
163 #                  " 2 ** methodcachesizeexp is the size of the of the method cache ",
164 #                  default=11),
165 #        BoolOption("optimized_int_add",
166 #                   "special case the addition of two integers in BINARY_ADD",
167 #                   default=False),
168 #        BoolOption("optimized_comparison_op",
169 #                   "special case the comparison of integers",
170 #                   default=False),
171 #        BoolOption("optimized_list_getitem",
172 #                   "special case the 'list[integer]' expressions",
173 #                   default=False),
174 #        BoolOption("builtinshortcut",
175 #                   "a shortcut for operations between built-in types",
176 #                   default=False),
177 #        BoolOption("getattributeshortcut",
178 #                   "track types that override __getattribute__",
179 #                   default=False),
180 #        BoolOption("newshortcut",
181 #                   "cache and shortcut calling __new__ from builtin types",
182 #                   default=False),        
183
184 #        BoolOption("logspaceoptypes",
185 #                   "a instrumentation option: before exit, print the types seen by "
186 #                   "certain simpler bytecodes",
187 #                   default=False),
188 #        ChoiceOption("multimethods", "the multimethod implementation to use",
189 #                     ["doubledispatch", "mrd"],
190 #                     default="mrd"),
191 #        BoolOption("immutable_builtintypes",
192 #                   "Forbid the changing of builtin types", default=True),
193 #     ]),
194 #])
195
196 ## ____________________________________________________________
197
198 #def get_combined_translation_config(other_optdescr=None,
199 #                                    existing_config=None,
200 #                                    overrides=None,
201 #                                    translating=False):
202 #    if overrides is None:
203 #        overrides = {}
204 #    d = BoolOption("translating",
205 #                   "indicates whether we are translating currently",
206 #                   default=False)
207 #    if other_optdescr is None:
208 #        children = []
209 #        newname = ""
210 #    else:
211 #        children = [other_optdescr]
212 #        newname = other_optdescr._name
213 #    descr = OptionDescription("eole", "all options", children)
214 #    config = Config(descr, **overrides)
215 #    if translating:
216 #        config.translating = True
217 #    if existing_config is not None:
218 #        for child in existing_config._cfgimpl_descr._children:
219 #            if child._name == newname:
220 #                continue
221 #            value = getattr(existing_config, child._name)
222 #            config._cfgimpl_values[child._name] = value
223 #    return config
224
225 #def get_example_config(overrides=None, translating=False):
226 #    return get_combined_translation_config(
227 #            example__optiondescription, overrides=overrides,
228 #            translating=translating)
229
230 ## ____________________________________________________________
231
232 #def test_example_option():
233 #    config = get_example_config()
234 #    result = ['objspace.name', 'objspace.opcodes.CALL_LIKELY_BUILTIN',
235 #    'objspace.opcodes.CALL_METHOD', 'objspace.nofaking',
236 #    'objspace.usemodules.amon', 'objspace.usemodules.sphynx',
237 #    'objspace.usemodules.zephir', 'objspace.allworkingmodules',
238 #    'objspace.translationmodules', 'objspace.geninterp',
239 #    'objspace.logbytecodes', 'objspace.usepycfiles', 'objspace.lonepycfiles',
240 #    'objspace.soabi', 'objspace.honor__builtins__',
241 #    'objspace.disable_call_speedhacks', 'objspace.timing',
242 #    'objspace.std.withtproxy', 'objspace.std.withsmallint',
243 #    'objspace.std.withprebuiltint', 'objspace.std.prebuiltintfrom',
244 #    'objspace.std.prebuiltintto', 'objspace.std.withstrjoin',
245 #    'objspace.std.withstrslice', 'objspace.std.withstrbuf',
246 #    'objspace.std.withprebuiltchar', 'objspace.std.sharesmallstr',
247 #    'objspace.std.withrope', 'objspace.std.withropeunicode',
248 #    'objspace.std.withcelldict', 'objspace.std.withdictmeasurement',
249 #    'objspace.std.withmapdict', 'objspace.std.withrangelist',
250 #    'objspace.std.withtypeversion', 'objspace.std.withmethodcache',
251 #    'objspace.std.withmethodcachecounter', 'objspace.std.methodcachesizeexp',
252 #    'objspace.std.optimized_int_add', 'objspace.std.optimized_comparison_op',
253 #    'objspace.std.optimized_list_getitem', 'objspace.std.builtinshortcut',
254 #    'objspace.std.getattributeshortcut', 'objspace.std.newshortcut',
255 #    'objspace.std.logspaceoptypes', 'objspace.std.multimethods',
256 #    'objspace.std.immutable_builtintypes']
257
258 #    assert config.getpaths(allpaths=True) == result