| 1 | import py |
| 2 | from pypy.config.pypyoption import get_pypy_config, set_pypy_opt_level |
| 3 | from rpython.config.config import Config, ConfigError |
| 4 | from rpython.config.translationoption import set_opt_level |
| 5 | |
| 6 | thisdir = py.path.local(__file__).dirpath() |
| 7 | |
| 8 | def test_required(): |
| 9 | conf = get_pypy_config() |
| 10 | assert not conf.translating |
| 11 | assert conf.objspace.usemodules.gc |
| 12 | |
| 13 | def test_conflicting_gcrootfinder(): |
| 14 | conf = get_pypy_config() |
| 15 | conf.translation.gc = "boehm" |
| 16 | with py.test.raises(ConfigError): |
| 17 | conf.translation.gcrootfinder = 'shadowstack' |
| 18 | |
| 19 | def test_frameworkgc(): |
| 20 | for name in ["minimark", "semispace"]: |
| 21 | conf = get_pypy_config() |
| 22 | assert conf.translation.gctransformer != "framework" |
| 23 | conf.translation.gc = name |
| 24 | assert conf.translation.gctransformer == "framework" |
| 25 | |
| 26 | def test_set_opt_level(): |
| 27 | conf = get_pypy_config() |
| 28 | set_opt_level(conf, '0') |
| 29 | assert conf.translation.gc == 'boehm' |
| 30 | assert conf.translation.backendopt.none == True |
| 31 | conf = get_pypy_config() |
| 32 | set_opt_level(conf, '2') |
| 33 | assert conf.translation.gc != 'boehm' |
| 34 | assert not conf.translation.backendopt.none |
| 35 | conf = get_pypy_config() |
| 36 | set_opt_level(conf, 'mem') |
| 37 | assert conf.translation.gcremovetypeptr |
| 38 | assert not conf.translation.backendopt.none |
| 39 | |
| 40 | def test_set_pypy_opt_level(): |
| 41 | conf = get_pypy_config() |
| 42 | set_pypy_opt_level(conf, '2') |
| 43 | assert conf.objspace.std.intshortcut |
| 44 | conf = get_pypy_config() |
| 45 | set_pypy_opt_level(conf, '0') |
| 46 | assert not conf.objspace.std.intshortcut |
| 47 | |
| 48 | def test_check_documentation(): |
| 49 | def check_file_exists(fn): |
| 50 | assert configdocdir.join(fn).check() |
| 51 | |
| 52 | from pypy.doc.config.generate import all_optiondescrs |
| 53 | configdocdir = thisdir.dirpath().dirpath().join("doc", "config") |
| 54 | for descr in all_optiondescrs: |
| 55 | prefix = descr._name |
| 56 | c = Config(descr) |
| 57 | for path in c.getpaths(include_groups=True): |
| 58 | fn = prefix + "." + path + ".txt" |
| 59 | yield fn, check_file_exists, fn |