File: test_pypyoption.py

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (60 lines) | stat: -rw-r--r-- 1,991 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import py
from pypy.config.pypyoption import get_pypy_config, set_pypy_opt_level
from rpython.config.config import Config, ConfigError
from rpython.config.translationoption import set_opt_level

thisdir = py.path.local(__file__).dirpath()

def test_required():
    conf = get_pypy_config()
    assert not conf.translating

    assert conf.objspace.usemodules.gc

def test_conflicting_gcrootfinder():
    conf = get_pypy_config()
    conf.translation.gc = "boehm"
    py.test.raises(ConfigError, "conf.translation.gcrootfinder = 'asmgcc'")


def test_frameworkgc():
    for name in ["minimark", "semispace"]:
        conf = get_pypy_config()
        assert conf.translation.gctransformer != "framework"
        conf.translation.gc = name
        assert conf.translation.gctransformer == "framework"

def test_set_opt_level():
    conf = get_pypy_config()
    set_opt_level(conf, '0')
    assert conf.translation.gc == 'boehm'
    assert conf.translation.backendopt.none == True
    conf = get_pypy_config()
    set_opt_level(conf, '2')
    assert conf.translation.gc != 'boehm'
    assert not conf.translation.backendopt.none
    conf = get_pypy_config()
    set_opt_level(conf, 'mem')
    assert conf.translation.gcremovetypeptr
    assert not conf.translation.backendopt.none

def test_set_pypy_opt_level():
    conf = get_pypy_config()
    set_pypy_opt_level(conf, '2')
    assert conf.objspace.std.intshortcut
    conf = get_pypy_config()
    set_pypy_opt_level(conf, '0')
    assert not conf.objspace.std.intshortcut

def test_check_documentation():
    def check_file_exists(fn):
        assert configdocdir.join(fn).check()

    from pypy.doc.config.generate import all_optiondescrs
    configdocdir = thisdir.dirpath().dirpath().join("doc", "config")
    for descr in all_optiondescrs:
        prefix = descr._name
        c = Config(descr)
        for path in c.getpaths(include_groups=True):
            fn = prefix + "." + path + ".txt"
            yield fn, check_file_exists, fn