예제 #1
0
파일: test_util.py 프로젝트: fhalde/pypy
 def __init__(self, cpu):
     self.cpu = cpu
     self.profiler = EmptyProfiler()
     self.options = Fake()
     self.globaldata = Fake()
     self.config = get_combined_translation_config(translating=True)
     self.jitlog = jl.JitLogger()
예제 #2
0
파일: test_util.py 프로젝트: mozillazg/pypy
 def __init__(self, cpu):
     self.cpu = cpu
     self.profiler = EmptyProfiler()
     self.options = Fake()
     self.globaldata = Fake()
     self.config = get_combined_translation_config(translating=True)
     self.jitlog = jl.JitLogger()
예제 #3
0
 def setup_class(cls):
     py.test.skip("TestMaemo: tests skipped for now")
     from rpython.translator.platform.maemo import check_scratchbox
     check_scratchbox()
     config = get_combined_translation_config(translating=True)
     config.translation.platform = 'maemo'
     cls.config = config
예제 #4
0
 def setup_class(cls):
     py.test.skip("TestMaemo: tests skipped for now")
     from rpython.translator.platform.maemo import check_scratchbox
     check_scratchbox()
     config = get_combined_translation_config(translating=True)
     config.translation.platform = 'maemo'
     cls.config = config
예제 #5
0
def compile(f, gc, **kwds):
    from rpython.annotator.listdef import s_list_of_strings
    from rpython.translator.translator import TranslationContext
    from rpython.jit.metainterp.warmspot import apply_jit
    from rpython.translator.c import genc
    #
    config = get_combined_translation_config(translating=True)
    config.translation.gc = gc
    if gc != 'boehm':
        config.translation.gcremovetypeptr = True
    for name, value in kwds.items():
        setattr(config.translation, name, value)
    t = TranslationContext(config)
    ann = t.buildannotator()
    ann.build_types(f, [s_list_of_strings], main_entry_point=True)
    t.buildrtyper().specialize()

    if kwds['jit']:
        patch = get_functions_to_patch()
        old_value = {}
        try:
            for (obj, attr), value in patch.items():
                old_value[obj, attr] = getattr(obj, attr)
                setattr(obj, attr, value)
            #
            apply_jit(t)
            #
        finally:
            for (obj, attr), oldvalue in old_value.items():
                setattr(obj, attr, oldvalue)

    cbuilder = genc.CStandaloneBuilder(t, f, t.config)
    cbuilder.generate_source(defines=cbuilder.DEBUG_DEFINES)
    cbuilder.compile()
    return cbuilder
예제 #6
0
파일: genoo.py 프로젝트: sota/pypy-old
    def __init__(self,
                 tmpdir,
                 translator,
                 entrypoint,
                 config=None,
                 exctrans=False):
        self.tmpdir = tmpdir
        self.translator = translator
        self.entrypoint = entrypoint
        self.db = self.Database(self)
        if config is None:
            from rpython.config.translationoption import get_combined_translation_config
            config = get_combined_translation_config(translating=True)
        self.config = config

        # XXX: move this option out of the 'cli' section
        exctrans = exctrans or translator.config.translation.cli.exception_transformer
        if exctrans:
            self.db.exceptiontransformer = translator.getexceptiontransformer()

        self.append_prebuilt_nodes()

        if exctrans:
            etrafo = self.db.exceptiontransformer
            for graph in translator.graphs:
                etrafo.create_exception_handling(graph)

        if translator.config.translation.backendopt.stack_optimization:
            self.stack_optimization()
예제 #7
0
def main():
    assert not we_are_translated()
    driver = TranslationDriver()
    optiondescr = get_additional_config_options()
    config = get_combined_translation_config(
                optiondescr,
                existing_config=driver.config,
                translating=True)
    driver.config = config
    tgt = target(driver, [])
    try:
        f, _1, _2  = tgt
    except TypeError:
        f = tgt
    except ValueError:
        f, _ =  tgt

    try:
        sys.exit(f(sys.argv))
    except SystemExit:
        raise
    except:
        _type, value, tb = sys.exc_info()
        traceback.print_exception(_type, value, tb)
        pdb.post_mortem(tb)
예제 #8
0
    def test_full_translation(self):
        class State:
            pass
        state = State()
        state.seen = []
        def dealloc_trigger():
            state.seen.append(1)
        w_marker = W_Root(-1)

        def make_p():
            p = W_Root(42)
            ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
            rawrefcount.create_link_pypy(p, ob)
            ob.c_ob_refcnt += REFCNT_FROM_PYPY
            assert rawrefcount.from_obj(PyObject, p) == ob
            assert rawrefcount.to_obj(W_Root, ob) == p
            return ob, p

        FTYPE = rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER

        def entry_point(argv):
            ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
            rawrefcount.init(ll_dealloc_trigger_callback)
            ob, p = make_p()
            if state.seen != []:
                print "OB COLLECTED REALLY TOO SOON"
                return 1
            rgc.collect()
            if state.seen != []:
                print "OB COLLECTED TOO SOON"
                return 1
            objectmodel.keepalive_until_here(p)
            p = None
            rgc.collect()
            if state.seen != [1]:
                print "OB NOT COLLECTED"
                return 1
            if rawrefcount.next_dead(PyObject) != ob:
                print "NEXT_DEAD != OB"
                return 1
            if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
                print "NEXT_DEAD second time != NULL"
                return 1
            if rawrefcount.to_obj(W_Root, ob) is not None:
                print "to_obj(dead) is not None?"
                return 1
            rawrefcount.mark_deallocating(w_marker, ob)
            if rawrefcount.to_obj(W_Root, ob) is not w_marker:
                print "to_obj(marked-dead) is not w_marker"
                return 1
            print "OK!"
            lltype.free(ob, flavor='raw')
            return 0

        self.config = get_combined_translation_config(translating=True)
        self.config.translation.gc = "incminimark"
        t, cbuilder = self.compile(entry_point)
        data = cbuilder.cmdexec('hi there')
        assert data.startswith('OK!\n')
예제 #9
0
 def make_config(cls):
     if _MSVC:
         py.test.skip("all asmgcroot tests disabled for MSVC")
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True)
     config.translation.gc = cls.gcpolicy
     config.translation.gcrootfinder = "asmgcc"
     config.translation.taggedpointers = getattr(cls, "taggedpointers", False)
     return config
예제 #10
0
 def make_config(cls):
     if _MSVC:
         py.test.skip("all asmgcroot tests disabled for MSVC")
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True)
     config.translation.gc = cls.gcpolicy
     config.translation.gcrootfinder = "asmgcc"
     config.translation.taggedpointers = getattr(cls, "taggedpointers", False)
     return config
예제 #11
0
파일: test_compile.py 프로젝트: bukzor/pypy
class FakeMetaInterpStaticData(object):

    logger_noopt = FakeLogger()
    logger_ops = FakeLogger()
    config = get_combined_translation_config(translating=True)

    stats = Stats()
    profiler = jitprof.EmptyProfiler()
    warmrunnerdesc = None
    def log(self, msg, event_kind=None):
        pass
예제 #12
0
 def setup_class(cls):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True)
     config.translation.gc = cls.gc
     if cls.gcrootfinder is not None:
         config.translation.continuation = True
         config.translation.gcrootfinder = cls.gcrootfinder
         GCROOTFINDER = cls.gcrootfinder
     cls.config = config
     cls.old_status_max = Runner.STATUSMAX
     Runner.STATUSMAX = 25000
예제 #13
0
    def test_full_translation(self):
        class State:
            pass

        state = State()
        state.seen = []

        def dealloc_trigger():
            state.seen.append(1)

        def make_p():
            p = W_Root(42)
            ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
            rawrefcount.create_link_pypy(p, ob)
            ob.c_ob_refcnt += REFCNT_FROM_PYPY
            assert rawrefcount.from_obj(PyObject, p) == ob
            assert rawrefcount.to_obj(W_Root, ob) == p
            return ob, p

        FTYPE = rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER

        def entry_point(argv):
            ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
            rawrefcount.init(ll_dealloc_trigger_callback)
            ob, p = make_p()
            if state.seen != []:
                print "OB COLLECTED REALLY TOO SOON"
                return 1
            rgc.collect()
            if state.seen != []:
                print "OB COLLECTED TOO SOON"
                return 1
            objectmodel.keepalive_until_here(p)
            p = None
            rgc.collect()
            if state.seen != [1]:
                print "OB NOT COLLECTED"
                return 1
            if rawrefcount.next_dead(PyObject) != ob:
                print "NEXT_DEAD != OB"
                return 1
            if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
                print "NEXT_DEAD second time != NULL"
                return 1
            print "OK!"
            lltype.free(ob, flavor='raw')
            return 0

        self.config = get_combined_translation_config(translating=True)
        self.config.translation.gc = "incminimark"
        t, cbuilder = self.compile(entry_point)
        data = cbuilder.cmdexec('hi there')
        assert data.startswith('OK!\n')
예제 #14
0
    def setup_class(cls):
        if cls.gcrootfinder == "asmgcc" and DEFL_ROOTFINDER_WITHJIT != "asmgcc":
            py.test.skip("asmgcc is disabled on the current platform")

        from rpython.config.translationoption import get_combined_translation_config
        config = get_combined_translation_config(translating=True)
        config.translation.gc = cls.gc
        if cls.gcrootfinder is not None:
            config.translation.continuation = True
            config.translation.gcrootfinder = cls.gcrootfinder
            GCROOTFINDER = cls.gcrootfinder
        cls.config = config
        cls.old_status_max = Runner.STATUSMAX
        Runner.STATUSMAX = 25000
예제 #15
0
 def setup_class(cls):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True)
     config.translation.gc = cls.gc
     if cls.gcrootfinder is not None:
         config.translation.continuation = True
         config.translation.gcrootfinder = cls.gcrootfinder
         GCROOTFINDER = cls.gcrootfinder
     cls.config = config
     cls.old_values = Runner.config, Runner.STATUSMAX
     Runner.config = config
     Runner.STATUSMAX = 25000
     if cls.gcrootfinder == "asmgcc" and sys.platform == "win32":
         py.test.skip("fails with asmgcc on win32")
예제 #16
0
 def setup_class(cls):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True)
     config.translation.gc = cls.gc
     if cls.gcrootfinder is not None:
         config.translation.continuation = True
         config.translation.gcrootfinder = cls.gcrootfinder
         GCROOTFINDER = cls.gcrootfinder
     cls.config = config
     cls.old_values = Runner.config, Runner.STATUSMAX
     Runner.config = config
     Runner.STATUSMAX = 25000
     if cls.gcrootfinder == "asmgcc" and sys.platform == "win32":
         py.test.skip("fails with asmgcc on win32")
예제 #17
0
    def test_full_translation(self):

        def make_ob():
            p = W_Root(42)
            ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
            rawrefcount.create_link_pypy(p, ob)
            ob.c_ob_refcnt += REFCNT_FROM_PYPY
            assert rawrefcount.from_obj(PyObject, p) == ob
            assert rawrefcount.to_obj(W_Root, ob) == p
            return ob

        prebuilt_p = W_Root(-42)
        prebuilt_ob = lltype.malloc(PyObjectS, flavor='raw', zero=True,
                                    immortal=True)

        def entry_point(argv):
            rawrefcount.create_link_pypy(prebuilt_p, prebuilt_ob)
            prebuilt_ob.c_ob_refcnt += REFCNT_FROM_PYPY
            oblist = [make_ob() for i in range(50)]
            rgc.collect()
            deadlist = []
            while True:
                ob = rawrefcount.next_dead(PyObject)
                if not ob: break
                if ob.c_ob_refcnt != 1:
                    print "next_dead().ob_refcnt != 1"
                    return 1
                deadlist.append(ob)
            if len(deadlist) == 0:
                print "no dead object"
                return 1
            if len(deadlist) < 30:
                print "not enough dead objects"
                return 1
            for ob in deadlist:
                if ob not in oblist:
                    print "unexpected value for dead pointer"
                    return 1
                oblist.remove(ob)
            print "OK!"
            lltype.free(ob, flavor='raw')
            return 0

        self.config = get_combined_translation_config(translating=True)
        self.config.translation.gc = "boehm"
        t, cbuilder = self.compile(entry_point)
        data = cbuilder.cmdexec('hi there')
        assert data.startswith('OK!\n')
예제 #18
0
 def setup_method(self, meth):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True).translation
     self.stackroots = []
     GC_PARAMS = self.GC_PARAMS.copy()
     if hasattr(meth, 'GC_PARAMS'):
         GC_PARAMS.update(meth.GC_PARAMS)
     GC_PARAMS['translated_to_c'] = False
     self.gc = self.GCClass(config, **GC_PARAMS)
     self.gc.DEBUG = True
     self.rootwalker = DirectRootWalker(self)
     self.gc.set_root_walker(self.rootwalker)
     self.layoutbuilder = TypeLayoutBuilder(self.GCClass)
     self.get_type_id = self.layoutbuilder.get_type_id
     self.layoutbuilder.initialize_gc_query_function(self.gc)
     self.gc.setup()
예제 #19
0
파일: translator.py 프로젝트: sota/pypy-old
 def __init__(self, config=None, **flowing_flags):
     if config is None:
         from rpython.config.translationoption import get_combined_translation_config
         config = get_combined_translation_config(translating=True)
     # ZZZ should go away in the end
     for attr in ['verbose', 'list_comprehension_operations']:
         if attr in flowing_flags:
             setattr(config.translation, attr, flowing_flags[attr])
     self.config = config
     self.platform = get_platform(config)
     self.annotator = None
     self.rtyper = None
     self.exceptiontransformer = None
     self.graphs = []      # [graph]
     self.callgraph = {}   # {opaque_tag: (caller-graph, callee-graph)}
     self._prebuilt_graphs = {}   # only used by the pygame viewer
예제 #20
0
파일: test_direct.py 프로젝트: juokaz/pypy
 def setup_method(self, meth):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True).translation
     self.stackroots = []
     GC_PARAMS = self.GC_PARAMS.copy()
     if hasattr(meth, 'GC_PARAMS'):
         GC_PARAMS.update(meth.GC_PARAMS)
     GC_PARAMS['translated_to_c'] = False
     self.gc = self.GCClass(config, **GC_PARAMS)
     self.gc.DEBUG = True
     self.rootwalker = DirectRootWalker(self)
     self.gc.set_root_walker(self.rootwalker)
     self.layoutbuilder = TypeLayoutBuilder(self.GCClass)
     self.get_type_id = self.layoutbuilder.get_type_id
     self.layoutbuilder.initialize_gc_query_function(self.gc)
     self.gc.setup()
예제 #21
0
 def setup_method(self, meth):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True).translation
     self.stackroots = []
     GC_PARAMS = self.GC_PARAMS.copy()
     if hasattr(meth, 'GC_PARAMS'):
         GC_PARAMS.update(meth.GC_PARAMS)
     GC_PARAMS['translated_to_c'] = False
     self.gc = self.GCClass(config, **GC_PARAMS)
     self.gc.DEBUG = True
     self.rootwalker = DirectRootWalker(self)
     self.gc.set_root_walker(self.rootwalker)
     self.layoutbuilder = TypeLayoutBuilder(self.GCClass)
     self.get_type_id = self.layoutbuilder.get_type_id
     gcdata = self.layoutbuilder.initialize_gc_query_function(self.gc)
     ll_handlers = lltype.malloc(FIN_HANDLER_ARRAY, 0, immortal=True)
     gcdata.finalizer_handlers = llmemory.cast_ptr_to_adr(ll_handlers)
     self.gc.setup()
예제 #22
0
def test_run_translation():
    from rpython.rtyper.test.test_llinterp import get_interpreter
    from rpython.translator.goal import unixcheckpoint
    from rpython.config.translationoption import get_combined_translation_config
    from rpython.config.translationoption import set_opt_level

    config = get_combined_translation_config(translating=True)
    config.translation.gc = 'boehm'
    set_opt_level(config, level='jit')
    config.translation.backendopt.inline_threshold = 0.1

    try:
        interp, graph = get_interpreter(run, [], backendopt=False,
                                        config=config)
    except Exception, e:
        print '%s: %s' % (e.__class__, e)
        pdb.post_mortem(sys.exc_info()[2])
        raise
예제 #23
0
 def setup_method(self, meth):
     from rpython.config.translationoption import get_combined_translation_config
     config = get_combined_translation_config(translating=True).translation
     self.stackroots = []
     GC_PARAMS = self.GC_PARAMS.copy()
     if hasattr(meth, 'GC_PARAMS'):
         GC_PARAMS.update(meth.GC_PARAMS)
     GC_PARAMS['translated_to_c'] = False
     self.gc = self.GCClass(config, **GC_PARAMS)
     self.gc.DEBUG = True
     self.rootwalker = DirectRootWalker(self)
     self.gc.set_root_walker(self.rootwalker)
     self.layoutbuilder = TypeLayoutBuilder(self.GCClass)
     self.get_type_id = self.layoutbuilder.get_type_id
     gcdata = self.layoutbuilder.initialize_gc_query_function(self.gc)
     ll_handlers = lltype.malloc(FIN_HANDLER_ARRAY, 0, immortal=True)
     gcdata.finalizer_handlers = llmemory.cast_ptr_to_adr(ll_handlers)
     self.gc.setup()
예제 #24
0
    def test_entrypoint(self):
        import ctypes

        config = get_combined_translation_config(translating=True)
        self.config = config

        @entrypoint('test', [lltype.Signed], c_name='foo')
        def f(a):
            return a + 3

        def entry_point(argv):
            return 0

        t, cbuilder = self.compile(entry_point, shared=True,
                                   entrypoints=[f])
        libname = cbuilder.executable_name.join('..', 'lib' +
                                                cbuilder.modulename + '.so')
        lib = ctypes.CDLL(str(libname))
        assert lib.foo(13) == 16
예제 #25
0
파일: jithip.py 프로젝트: youaani/hippyvm
def test_run_translation():
    from rpython.rtyper.test.test_llinterp import get_interpreter
    from rpython.translator.goal import unixcheckpoint
    from rpython.config.translationoption import get_combined_translation_config
    from rpython.config.translationoption import set_opt_level

    config = get_combined_translation_config(translating=True)
    config.translation.gc = 'boehm'
    set_opt_level(config, level='jit')
    config.translation.backendopt.inline_threshold = 0.1

    try:
        interp, graph = get_interpreter(run, [],
                                        backendopt=False,
                                        config=config)
    except Exception, e:
        print '%s: %s' % (e.__class__, e)
        pdb.post_mortem(sys.exc_info()[2])
        raise
예제 #26
0
    def test_entrypoint(self):
        import ctypes

        config = get_combined_translation_config(translating=True)
        self.config = config

        @entrypoint('test', [lltype.Signed], c_name='foo')
        def f(a):
            return a + 3

        def entry_point(argv):
            return 0

        t, cbuilder = self.compile(entry_point, shared=True, entrypoints=[f])
        ext_suffix = '.so'
        if cbuilder.eci.platform.name == 'msvc':
            ext_suffix = '.dll'
        elif cbuilder.eci.platform.name.startswith('darwin'):
            ext_suffix = '.dylib'
        libname = cbuilder.executable_name.join(
            '..', 'lib' + cbuilder.modulename + ext_suffix)
        lib = ctypes.CDLL(str(libname))
        assert lib.foo(13) == 16
예제 #27
0
    def test_entrypoint(self):
        import ctypes

        config = get_combined_translation_config(translating=True)
        self.config = config

        @entrypoint('test', [lltype.Signed], c_name='foo')
        def f(a):
            return a + 3

        def entry_point(argv):
            return 0

        t, cbuilder = self.compile(entry_point, shared=True,
                                   entrypoints=[f])
        ext_suffix = '.so'
        if cbuilder.eci.platform.name == 'msvc':
            ext_suffix = '.dll'
        elif cbuilder.eci.platform.name.startswith('darwin'):
            ext_suffix = '.dylib'
        libname = cbuilder.executable_name.join('..', 'lib' +
                                      cbuilder.modulename + ext_suffix)
        lib = ctypes.CDLL(str(libname))
        assert lib.foo(13) == 16
예제 #28
0
    def test_multiple_threads(self):
        import time, random
        from rpython.rlib import rthread

        def check(name, nextop, expected=True):
            # we may not have the GIL here, don't use "print"
            if rgil.am_I_holding_the_GIL() != expected:
                debug_print('assert failed at point', name, 'at', nextop)
                debug_print('rgil.gil_get_holder() ==', rgil.gil_get_holder())
                assert False

        seed = int(time.time())
        print "Random seed:", seed
        random.seed(seed)

        # This is just a complicated way of simulating random work.
        # We randomly release the GIL in various ways from 4 different threads
        # and check that at least rgil.am_I_holding_the_GIL() is sane.

        OP_YIELD = 0
        OP_RELEASE_AND_ACQUIRE = 1
        OP_BUSY = 2  # without releasing the GIL
        OP_SLEEP = 3  # time.sleep() always releases the GIL
        OPS = [OP_YIELD, OP_RELEASE_AND_ACQUIRE, OP_BUSY, OP_SLEEP]

        N_THREADS = 4
        ops_by_thread = []
        for i in range(N_THREADS):
            ops = []
            for j in range(10000):
                op = random.choice(OPS)
                ops.append(op)
                if op >= 2:
                    ops.append(random.randint(0, 1000))
            ops_by_thread.append(ops)

        class Glob:
            def __init__(self):
                self.my_locks = []
                self.n_threads = 0

        glob = Glob()

        def do_random_work():
            thread_index = glob.n_threads
            glob.n_threads += 1
            ops = ops_by_thread[thread_index]
            nextop = 0
            while nextop < len(ops):
                op = ops[nextop]
                nextop += 1
                if op == OP_YIELD:
                    rgil.yield_thread()
                    check("after yield", nextop)
                elif op == OP_RELEASE_AND_ACQUIRE:
                    rgil.release()
                    check("after release_gil", nextop, expected=False)
                    rgil.acquire()
                    check("after acquire_gil", nextop)
                else:
                    arg = ops[nextop]
                    nextop += 1
                    if op == OP_BUSY:
                        end_time = time.time() + arg * 1e-6
                        while time.time() < end_time:
                            pass
                        check("after busy work", nextop)
                    else:
                        time.sleep(arg * 1e-6)
                        check("after time.sleep()", nextop)
            finish_lock = glob.my_locks[thread_index]
            finish_lock.release()

        def main(argv):
            for j in range(N_THREADS):
                lock = rthread.allocate_lock()
                lock.acquire(True)
                glob.my_locks.append(lock)

            for j in range(N_THREADS):
                rthread.start_new_thread(do_random_work, ())

            for j in range(N_THREADS):
                glob.my_locks[j].acquire(True)

            print "OK"
            return 0

        self.config = get_combined_translation_config(
            overrides={"translation.thread": True})
        t, cbuilder = self.compile(main)
        data = cbuilder.cmdexec('')
        assert data == "OK\n"
예제 #29
0
def print_help(config):
    to_optparse(config).print_help()


take_options = True


def get_additional_config_options():
    return system.translation_options()


if __name__ == '__main__':
    assert not objectmodel.we_are_translated()
    from rpython.translator.driver import TranslationDriver
    driver = TranslationDriver()
    driver.config = get_combined_translation_config(
        system.translation_options(), translating=False)
    if "--" in sys.argv:
        idx = sys.argv.index("--")
        configargs, args = sys.argv[0:idx], sys.argv[idx:]
    else:
        configargs, args = [], sys.argv
    f, _, _ = target(driver, configargs)
    try:
        sys.exit(f(args))
    except SystemExit:
        pass
    except:
        if hasattr(sys, 'ps1') or not sys.stderr.isatty():
            # we are in interactive mode or we don't have a tty-like
            # device, so we call the default hook
            sys.__excepthook__(type, value, tb)
예제 #30
0
파일: config.py 프로젝트: rrnewton/pycket
def get_testing_config(**overrides):
    return get_combined_translation_config(
            pycketoption_descr,
            translating=False,
            overrides=overrides)
예제 #31
0
                "optional_plugins",
                "Which optional plugins should be enabled (a comma-separated "\
                "list, e.g. 'RubyPlugin,DatabasePlugin,JitHooks')",
                default="", cmdline="--plugins"
            ),
            StrOption(
                "disabled_plugins",
                "Which default plugins should be disabled (a comma-separated "\
                "list, e.g. 'LargeIntegers,SocketPlugin,SqueakSSL')",
                default="", cmdline="--disabled_plugins"
            ),
            BoolOption(
                "without_plugins",
                "Disable all plugins",
                default=False, cmdline="--without_plugins"
            ),
        ]
    )


@not_rpython
def expose_options(config):
    for name in translation_options().getpaths():
        globals()[name] = getattr(config.rsqueak, name)
    globals()["translationconfig"] = config.translation


# Expose an empty default
expose_options(
    get_combined_translation_config(translation_options(), translating=False))
예제 #32
0
파일: driver.py 프로젝트: yuyichao/pypy
    def __init__(self, setopts=None, default_goal=None,
                 disable=[],
                 exe_name=None, extmod_name=None,
                 config=None, overrides=None):
        self.timer = Timer()
        SimpleTaskEngine.__init__(self)

        self.log = log

        if config is None:
            from rpython.config.translationoption import get_combined_translation_config
            config = get_combined_translation_config(translating=True)
        self.config = config
        if overrides is not None:
            self.config.override(overrides)

        if setopts is not None:
            self.config.set(**setopts)

        self.exe_name = exe_name
        self.extmod_name = extmod_name

        self.done = {}

        self.disable(disable)

        if default_goal:
            default_goal, = self.backend_select_goals([default_goal])
            if default_goal in self._maybe_skip():
                default_goal = None

        self.default_goal = default_goal
        self.extra_goals = []
        self.exposed = []

        # expose tasks
        def expose_task(task, backend_goal=None):
            if backend_goal is None:
                backend_goal = task
            def proc():
                return self.proceed(backend_goal)
            self.exposed.append(task)
            setattr(self, task, proc)

        backend, ts = self.get_backend_and_type_system()
        for task in self.tasks:
            explicit_task = task
            if task == 'annotate':
                expose_task(task)
            else:
                task, postfix = task.split('_')
                if task in ('rtype', 'backendopt', 'llinterpret',
                            'pyjitpl'):
                    if ts:
                        if ts == postfix:
                            expose_task(task, explicit_task)
                    else:
                        expose_task(explicit_task)
                elif task in ('source', 'compile', 'run'):
                    if backend:
                        if backend == postfix:
                            expose_task(task, explicit_task)
                    elif ts:
                        if ts == 'lltype':
                            expose_task(explicit_task)
                    else:
                        expose_task(explicit_task)
예제 #33
0
 def test_debug_print_start_stop(self):
     import sys
     from rpython.rtyper.lltypesystem import rffi
     if sys.platform == 'win32':
         # ftell(stderr) is a bit different under subprocess.Popen
         tell = 0
     else:
         tell = -1
     def entry_point(argv):
         x = "got:"
         debug_start  ("mycat")
         if have_debug_prints(): x += "b"
         debug_print    ("foo", r_longlong(2), "bar", 3)
         debug_start      ("cat2")
         if have_debug_prints(): x += "c"
         debug_print        ("baz")
         debug_stop       ("cat2")
         if have_debug_prints(): x += "d"
         debug_print    ("bok")
         debug_stop   ("mycat")
         if have_debug_prints(): x += "a"
         debug_print("toplevel")
         debug_print("some int", rffi.cast(rffi.INT, 3))
         debug_flush()
         os.write(1, x + "." + str(debug_offset()) + '.\n')
         return 0
     t, cbuilder = self.compile(entry_point)
     # check with PYPYLOG undefined
     out, err = cbuilder.cmdexec("", err=True, env={})
     assert out.strip() == 'got:a.%d.' % tell
     assert 'toplevel' in err
     assert 'mycat' not in err
     assert 'foo 2 bar 3' not in err
     assert 'cat2' not in err
     assert 'baz' not in err
     assert 'bok' not in err
     # check with PYPYLOG defined to an empty string (same as undefined)
     out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ''})
     assert out.strip() == 'got:a.%d.' % tell
     assert 'toplevel' in err
     assert 'mycat' not in err
     assert 'foo 2 bar 3' not in err
     assert 'cat2' not in err
     assert 'baz' not in err
     assert 'bok' not in err
     # check with PYPYLOG=:- (means print to stderr)
     out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ':-'})
     assert out.strip() == 'got:bcda.%d.' % tell
     assert 'toplevel' in err
     assert '{mycat' in err
     assert 'mycat}' in err
     assert 'foo 2 bar 3' in err
     assert '{cat2' in err
     assert 'cat2}' in err
     assert 'baz' in err
     assert 'bok' in err
     assert 'some int 3' in err
     # check with PYPYLOG=:somefilename
     path = udir.join('test_debug_xxx.log')
     out, err = cbuilder.cmdexec("", err=True,
                                 env={'PYPYLOG': ':%s' % path})
     size = os.stat(str(path)).st_size
     assert out.strip() == 'got:bcda.' + str(size) + '.'
     assert not err
     assert path.check(file=1)
     data = path.read()
     assert 'toplevel' in data
     assert '{mycat' in data
     assert 'mycat}' in data
     assert 'foo 2 bar 3' in data
     assert '{cat2' in data
     assert 'cat2}' in data
     assert 'baz' in data
     assert 'bok' in data
     # check with PYPYLOG=somefilename
     path = udir.join('test_debug_xxx_prof.log')
     if str(path).find(':')>=0:
         # bad choice of udir, there is a ':' in it which messes up the test
         pass
     else:
         out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': str(path)})
         size = os.stat(str(path)).st_size
         assert out.strip() == 'got:a.' + str(size) + '.'
         assert not err
         assert path.check(file=1)
         data = path.read()
         assert 'toplevel' in data
         assert '{mycat' in data
         assert 'mycat}' in data
         assert 'foo 2 bar 3' not in data
         assert '{cat2' in data
         assert 'cat2}' in data
         assert 'baz' not in data
         assert 'bok' not in data
     # check with PYPYLOG=+somefilename
     path = udir.join('test_debug_xxx_prof_2.log')
     out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': '+%s' % path})
     size = os.stat(str(path)).st_size
     assert out.strip() == 'got:a.' + str(size) + '.'
     assert not err
     assert path.check(file=1)
     data = path.read()
     assert 'toplevel' in data
     assert '{mycat' in data
     assert 'mycat}' in data
     assert 'foo 2 bar 3' not in data
     assert '{cat2' in data
     assert 'cat2}' in data
     assert 'baz' not in data
     assert 'bok' not in data
     # check with PYPYLOG=myc:somefilename   (includes mycat but not cat2)
     path = udir.join('test_debug_xxx_myc.log')
     out, err = cbuilder.cmdexec("", err=True,
                                 env={'PYPYLOG': 'myc:%s' % path})
     size = os.stat(str(path)).st_size
     assert out.strip() == 'got:bda.' + str(size) + '.'
     assert not err
     assert path.check(file=1)
     data = path.read()
     assert 'toplevel' in data
     assert '{mycat' in data
     assert 'mycat}' in data
     assert 'foo 2 bar 3' in data
     assert 'cat2' not in data
     assert 'baz' not in data
     assert 'bok' in data
     # check with PYPYLOG=cat:somefilename   (includes cat2 but not mycat)
     path = udir.join('test_debug_xxx_cat.log')
     out, err = cbuilder.cmdexec("", err=True,
                                 env={'PYPYLOG': 'cat:%s' % path})
     size = os.stat(str(path)).st_size
     assert out.strip() == 'got:ca.' + str(size) + '.'
     assert not err
     assert path.check(file=1)
     data = path.read()
     assert 'toplevel' in data
     assert 'mycat' not in data
     assert 'foo 2 bar 3' not in data
     assert 'cat2' in data
     assert 'baz' in data
     assert 'bok' not in data
     # check with PYPYLOG=myc,cat2:somefilename   (includes mycat and cat2)
     path = udir.join('test_debug_xxx_myc_cat2.log')
     out, err = cbuilder.cmdexec("", err=True,
                                 env={'PYPYLOG': 'myc,cat2:%s' % path})
     size = os.stat(str(path)).st_size
     assert out.strip() == 'got:bcda.' + str(size) + '.'
     assert not err
     assert path.check(file=1)
     data = path.read()
     assert 'toplevel' in data
     assert '{mycat' in data
     assert 'mycat}' in data
     assert 'foo 2 bar 3' in data
     assert 'cat2' in data
     assert 'baz' in data
     assert 'bok' in data
     #
     # finally, check compiling with logging disabled
     config = get_combined_translation_config(translating=True)
     config.translation.log = False
     self.config = config
     t, cbuilder = self.compile(entry_point)
     path = udir.join('test_debug_does_not_show_up.log')
     out, err = cbuilder.cmdexec("", err=True,
                                 env={'PYPYLOG': ':%s' % path})
     assert out.strip() == 'got:.-1.'
     assert not err
     assert path.check(file=0)
예제 #34
0
 def setup_class(cls):
     if sys.platform == 'win32':
         from rpython.config.translationoption import get_combined_translation_config
         cls.config = get_combined_translation_config(translating=True)
         cls.config.translation.cc = 'mingw32'
예제 #35
0
파일: __main__.py 프로젝트: Fleurer/topaz
import sys

import py
py.log.setconsumer("platform", None)

from rpython.config.translationoption import get_combined_translation_config

from topaz.main import create_entry_point, get_topaz_config_options


entry_point = create_entry_point(get_combined_translation_config(
    overrides=get_topaz_config_options(),
))
sys.exit(entry_point(sys.argv))
예제 #36
0
 def test_no_asmgcrot_on_msvc():
     config = get_combined_translation_config()
     py.test.raises(ConfigError, config.translation.setoption, 
                                     'gcrootfinder', 'asmgcc', 'user') 
예제 #37
0
파일: test_thread.py 프로젝트: sbw111/lab4
 def setup_class(cls):
     if sys.platform == 'win32':
         from rpython.config.translationoption import get_combined_translation_config
         cls.config = get_combined_translation_config(translating=True)
         cls.config.translation.cc = 'mingw32'
예제 #38
0
    def __init__(self,
                 setopts=None,
                 default_goal=None,
                 disable=[],
                 exe_name=None,
                 extmod_name=None,
                 config=None,
                 overrides=None):
        from rpython.config import translationoption
        self.timer = Timer()
        SimpleTaskEngine.__init__(self)

        self.log = log

        if config is None:
            config = translationoption.get_combined_translation_config(
                translating=True)
        # XXX patch global variable with translation config
        translationoption._GLOBAL_TRANSLATIONCONFIG = config
        self.config = config
        if overrides is not None:
            self.config.override(overrides)

        if setopts is not None:
            self.config.set(**setopts)

        self.exe_name = exe_name
        self.extmod_name = extmod_name

        self.done = {}

        self.disable(disable)

        if default_goal:
            default_goal, = self.backend_select_goals([default_goal])
            if default_goal in self._maybe_skip():
                default_goal = None

        self.default_goal = default_goal
        self.extra_goals = []
        self.exposed = []

        # expose tasks
        def expose_task(task, backend_goal=None):
            if backend_goal is None:
                backend_goal = task

            def proc():
                return self.proceed(backend_goal)

            self.exposed.append(task)
            setattr(self, task, proc)

        backend, ts = self.get_backend_and_type_system()
        for task in self.tasks:
            explicit_task = task
            if task == 'annotate':
                expose_task(task)
            else:
                task, postfix = task.split('_')
                if task in ('rtype', 'backendopt', 'llinterpret', 'pyjitpl'):
                    if ts:
                        if ts == postfix:
                            expose_task(task, explicit_task)
                    else:
                        expose_task(explicit_task)
                elif task in ('source', 'compile', 'run'):
                    if backend:
                        if backend == postfix:
                            expose_task(task, explicit_task)
                    elif ts:
                        if ts == 'lltype':
                            expose_task(explicit_task)
                    else:
                        expose_task(explicit_task)
예제 #39
0
        main_func = module.getattr(u"main")
    except space.Error as error:
        pass
    else:
        result = main_func.call([space.List(argv)])
    return space.null


def force_config(config):
    config.translation.continuation = True
    config.translation.thread = True
    config.translation.rweakref = True


def target(driver, args):
    driver.exe_name = "lever"
    force_config(driver.config)
    return main.new_entry_point(driver.config), None


def jitpolicy(driver):
    from rpython.jit.codewriter.policy import JitPolicy
    return JitPolicy()


if __name__ == '__main__':
    from rpython.config.translationoption import get_combined_translation_config
    config = get_combined_translation_config(translating=True)
    force_config(config)
    sys.exit(main.new_entry_point(config)(sys.argv))
예제 #40
0
 def test_no_asmgcrot_on_msvc():
     config = get_combined_translation_config()
     config.translation.gcrootfinder = "asmgcc"
     py.test.raises(ConfigError, set_opt_level, config, 'jit') 
예제 #41
0
파일: main.py 프로젝트: cheery/pyllisp
#from compiler import to_program
#from reader import read, Literal, Expr
from rpython.config.translationoption import get_combined_translation_config
from util import STDIN, STDOUT, STDERR, read_file, write
import api
import base
import evaluator.loader
import space
import sys, os
config = get_combined_translation_config(translating=True)
if config.translation.continuation:
    import green

#def interactive():
#    module = space.Module(u'shell', {}, extends=base.module)
#    prompt = u"pyl> "
#    write(STDOUT, prompt)
#    source = os.read(0, 4096).decode('utf-8')
#    while source != u"":
#        try:
#            program = to_program(read(source))
#            write(STDOUT, program.call([module]).repr() + u"\n")
#        except space.Error as error:
#            print_traceback(error)
#        write(STDOUT, prompt)
#        source = os.read(0, 4096).decode('utf-8')
#    if source == u"":
#        write(STDOUT, u"\n")
#    return 0
#
#def batch(path):
예제 #42
0
def new_topaz_objspace():
    translating = sys.argv[0] == '.build/build.py'  # make better
    config = get_combined_translation_config(translating=translating)
    config.set(**get_topaz_config_options())
    config.translation.suggest(check_str_without_nul=True)
    return ObjectSpace(config)
예제 #43
0
파일: translate.py 프로젝트: mozillazg/pypy
def parse_options_and_load_target():
    opt_parser = optparse.OptionParser(usage="%prog [options] [target] [target-specific-options]",
                                       prog="translate",
                                       formatter=OptHelpFormatter(),
                                       add_help_option=False)

    opt_parser.disable_interspersed_args()

    config = get_combined_translation_config(translating=True)
    to_optparse(config, parser=opt_parser, useoptions=['translation.*'])
    translateconfig = Config(translate_optiondescr)
    to_optparse(translateconfig, parser=opt_parser)

    options, args = opt_parser.parse_args()

    # set goals and skipped_goals
    reset = False
    for name, _, _, _ in GOALS:
        if name.startswith('?'):
            continue
        if getattr(translateconfig.goal_options, name):
            if name not in translateconfig.goals:
                translateconfig.goals.append(name)
        if getattr(translateconfig.goal_options, 'no_' + name):
            if name not in translateconfig.skipped_goals:
                if not reset:
                    translateconfig.skipped_goals[:] = []
                    reset = True
                translateconfig.skipped_goals.append(name)

    if args:
        arg = args[0]
        args = args[1:]
        if os.path.isfile(arg + '.py'):
            assert not os.path.isfile(arg), (
                "ambiguous file naming, please rename %s" % arg)
            translateconfig.targetspec = arg
        elif os.path.isfile(arg) and arg.endswith('.py'):
            translateconfig.targetspec = arg[:-3]
        else:
            log.ERROR("Could not find target %r" % (arg, ))
            sys.exit(1)
    else:
        show_help(translateconfig, opt_parser, None, config)

    # print the version of the host
    # (if it's PyPy, it includes the hg checksum)
    log.info(sys.version)

    # apply the platform settings
    set_platform(config)

    targetspec = translateconfig.targetspec
    targetspec_dic = load_target(targetspec)

    if args and not targetspec_dic.get('take_options', False):
        log.WARNING("target specific arguments supplied but will be ignored: %s" % ' '.join(args))

    # give the target the possibility to get its own configuration options
    # into the config
    if 'get_additional_config_options' in targetspec_dic:
        optiondescr = targetspec_dic['get_additional_config_options']()
        config = get_combined_translation_config(
                optiondescr,
                existing_config=config,
                translating=True)

    # show the target-specific help if --help was given
    show_help(translateconfig, opt_parser, targetspec_dic, config)

    # apply the optimization level settings
    set_opt_level(config, translateconfig.opt)

    # let the target modify or prepare itself
    # based on the config
    if 'handle_config' in targetspec_dic:
        targetspec_dic['handle_config'](config, translateconfig)

    return targetspec_dic, translateconfig, config, args
예제 #44
0
def test_no_gcrootfinder_with_boehm():
    config = get_combined_translation_config()
    config.translation.gcrootfinder = "shadowstack"
    py.test.raises(ConflictConfigError, set_opt_level, config, '0')
예제 #45
0
    return OptionDescription(
        "rsqueak", "RSqueak Options", [
            StrOption(
                "optional_plugins",
                "Which optional plugins should be enabled (a comma-separated "\
                "list, e.g. 'RubyPlugin,DatabasePlugin,JitHooks')",
                default="", cmdline="--plugins"
            ),
            StrOption(
                "disabled_plugins",
                "Which default plugins should be disabled (a comma-separated "\
                "list, e.g. 'LargeIntegers,SocketPlugin,SqueakSSL')",
                default="", cmdline="--disabled_plugins"
            ),
            BoolOption(
                "without_plugins",
                "Disable all plugins",
                default=False, cmdline="--without_plugins"
            ),
        ]
    )

@not_rpython
def expose_options(config):
    for name in translation_options().getpaths():
        globals()[name] = getattr(config.rsqueak, name)
    globals()["translationconfig"] = config.translation

# Expose an empty default
expose_options(get_combined_translation_config(translation_options(), translating=False))
예제 #46
0
파일: conftest.py 프로젝트: Perth68/topaz
 def build_space():
     space = ObjectSpace(get_combined_translation_config(
         overrides=get_topaz_config_options(),
     ))
     space.setup(topaz.__file__)
     return space
예제 #47
0
def print_help(config):
    to_optparse(config).print_help()

take_options = True

def get_additional_config_options():
    return system.translation_options()


if __name__ == '__main__':
    assert not objectmodel.we_are_translated()
    from rpython.translator.driver import TranslationDriver
    driver = TranslationDriver()
    driver.config = get_combined_translation_config(
        system.translation_options(),
        translating=False)
    if "--" in sys.argv:
        idx = sys.argv.index("--")
        configargs, args = sys.argv[0:idx], sys.argv[idx:]
    else:
        configargs, args = [], sys.argv
    f, _, _ = target(driver, configargs)
    try:
        sys.exit(f(args))
    except SystemExit:
        pass
    except:
        if hasattr(sys, 'ps1') or not sys.stderr.isatty():
            # we are in interactive mode or we don't have a tty-like
            # device, so we call the default hook
예제 #48
0
 def build_space():
     space = ObjectSpace(
         get_combined_translation_config(
             overrides=get_topaz_config_options(), ))
     space.setup(topaz.__file__)
     return space
예제 #49
0
파일: pypyoption.py 프로젝트: weijiwei/pypy
def get_pypy_config(overrides=None, translating=False):
    from rpython.config.translationoption import get_combined_translation_config
    return get_combined_translation_config(pypy_optiondescription,
                                           overrides=overrides,
                                           translating=translating)
예제 #50
0
    def test_debug_print_start_stop(self):
        import sys
        from rpython.rtyper.lltypesystem import rffi
        if sys.platform == 'win32':
            # ftell(stderr) is a bit different under subprocess.Popen
            tell = 0
        else:
            tell = -1

        def entry_point(argv):
            x = "got:"
            debug_start("mycat")
            if have_debug_prints(): x += "b"
            debug_print("foo", r_longlong(2), "bar", 3)
            debug_start("cat2")
            if have_debug_prints(): x += "c"
            debug_print("baz")
            debug_stop("cat2")
            if have_debug_prints(): x += "d"
            debug_print("bok")
            debug_stop("mycat")
            if have_debug_prints(): x += "a"
            debug_print("toplevel")
            debug_print("some int", rffi.cast(rffi.INT, 3))
            debug_flush()
            os.write(1, x + "." + str(debug_offset()) + '.\n')
            return 0

        t, cbuilder = self.compile(entry_point)
        # check with PYPYLOG undefined
        out, err = cbuilder.cmdexec("", err=True, env={})
        assert out.strip() == 'got:a.%d.' % tell
        assert 'toplevel' in err
        assert 'mycat' not in err
        assert 'foo 2 bar 3' not in err
        assert 'cat2' not in err
        assert 'baz' not in err
        assert 'bok' not in err
        # check with PYPYLOG defined to an empty string (same as undefined)
        out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ''})
        assert out.strip() == 'got:a.%d.' % tell
        assert 'toplevel' in err
        assert 'mycat' not in err
        assert 'foo 2 bar 3' not in err
        assert 'cat2' not in err
        assert 'baz' not in err
        assert 'bok' not in err
        # check with PYPYLOG=:- (means print to stderr)
        out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ':-'})
        assert out.strip() == 'got:bcda.%d.' % tell
        assert 'toplevel' in err
        assert '{mycat' in err
        assert 'mycat}' in err
        assert 'foo 2 bar 3' in err
        assert '{cat2' in err
        assert 'cat2}' in err
        assert 'baz' in err
        assert 'bok' in err
        assert 'some int 3' in err
        # check with PYPYLOG=:somefilename
        path = udir.join('test_debug_xxx.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': ':%s' % path})
        size = os.stat(str(path)).st_size
        assert out.strip() == 'got:bcda.' + str(size) + '.'
        assert not err
        assert path.check(file=1)
        data = path.read()
        assert 'toplevel' in data
        assert '{mycat' in data
        assert 'mycat}' in data
        assert 'foo 2 bar 3' in data
        assert '{cat2' in data
        assert 'cat2}' in data
        assert 'baz' in data
        assert 'bok' in data
        # check with PYPYLOG=somefilename
        path = udir.join('test_debug_xxx_prof.log')
        if str(path).find(':') >= 0:
            # bad choice of udir, there is a ':' in it which messes up the test
            pass
        else:
            out, err = cbuilder.cmdexec("",
                                        err=True,
                                        env={'PYPYLOG': str(path)})
            size = os.stat(str(path)).st_size
            assert out.strip() == 'got:a.' + str(size) + '.'
            assert not err
            assert path.check(file=1)
            data = path.read()
            assert 'toplevel' in data
            assert '{mycat' in data
            assert 'mycat}' in data
            assert 'foo 2 bar 3' not in data
            assert '{cat2' in data
            assert 'cat2}' in data
            assert 'baz' not in data
            assert 'bok' not in data
        # check with PYPYLOG=+somefilename
        path = udir.join('test_debug_xxx_prof_2.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': '+%s' % path})
        size = os.stat(str(path)).st_size
        assert out.strip() == 'got:a.' + str(size) + '.'
        assert not err
        assert path.check(file=1)
        data = path.read()
        assert 'toplevel' in data
        assert '{mycat' in data
        assert 'mycat}' in data
        assert 'foo 2 bar 3' not in data
        assert '{cat2' in data
        assert 'cat2}' in data
        assert 'baz' not in data
        assert 'bok' not in data
        # check with PYPYLOG=myc:somefilename   (includes mycat but not cat2)
        path = udir.join('test_debug_xxx_myc.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': 'myc:%s' % path})
        size = os.stat(str(path)).st_size
        assert out.strip() == 'got:bda.' + str(size) + '.'
        assert not err
        assert path.check(file=1)
        data = path.read()
        assert 'toplevel' in data
        assert '{mycat' in data
        assert 'mycat}' in data
        assert 'foo 2 bar 3' in data
        assert 'cat2' not in data
        assert 'baz' not in data
        assert 'bok' in data
        # check with PYPYLOG=cat:somefilename   (includes cat2 but not mycat)
        path = udir.join('test_debug_xxx_cat.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': 'cat:%s' % path})
        size = os.stat(str(path)).st_size
        assert out.strip() == 'got:ca.' + str(size) + '.'
        assert not err
        assert path.check(file=1)
        data = path.read()
        assert 'toplevel' in data
        assert 'mycat' not in data
        assert 'foo 2 bar 3' not in data
        assert 'cat2' in data
        assert 'baz' in data
        assert 'bok' not in data
        # check with PYPYLOG=myc,cat2:somefilename   (includes mycat and cat2)
        path = udir.join('test_debug_xxx_myc_cat2.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': 'myc,cat2:%s' % path})
        size = os.stat(str(path)).st_size
        assert out.strip() == 'got:bcda.' + str(size) + '.'
        assert not err
        assert path.check(file=1)
        data = path.read()
        assert 'toplevel' in data
        assert '{mycat' in data
        assert 'mycat}' in data
        assert 'foo 2 bar 3' in data
        assert 'cat2' in data
        assert 'baz' in data
        assert 'bok' in data
        #
        # finally, check compiling with logging disabled
        config = get_combined_translation_config(translating=True)
        config.translation.log = False
        self.config = config
        t, cbuilder = self.compile(entry_point)
        path = udir.join('test_debug_does_not_show_up.log')
        out, err = cbuilder.cmdexec("",
                                    err=True,
                                    env={'PYPYLOG': ':%s' % path})
        assert out.strip() == 'got:.-1.'
        assert not err
        assert path.check(file=0)
예제 #51
0
def get_pypy_config(overrides=None, translating=False):
    from rpython.config.translationoption import get_combined_translation_config
    return get_combined_translation_config(
            pypy_optiondescription, overrides=overrides,
            translating=translating)
예제 #52
0
def new_topaz_objspace():
    translating = sys.argv[0] == '.build/build.py'  # make better
    config = get_combined_translation_config(translating=translating)
    config.set(**get_topaz_config_options())
    config.translation.suggest(check_str_without_nul=True)
    return ObjectSpace(config)
예제 #53
0
파일: config.py 프로젝트: fenildf/pycket
def get_testing_config(**overrides):
    return get_combined_translation_config(pycketoption_descr,
                                           translating=False,
                                           overrides=overrides)
예제 #54
0
import sys

import py
py.log.setconsumer("platform", None)

from rpython.config.translationoption import get_combined_translation_config

from topaz.main import create_entry_point, get_topaz_config_options

entry_point = create_entry_point(
    get_combined_translation_config(overrides=get_topaz_config_options(), ))
sys.exit(entry_point(sys.argv))
예제 #55
0
 def test_no_asmgcrot_on_msvc():
     config = get_combined_translation_config()
     config.translation.gcrootfinder = "asmgcc"
     py.test.raises(ConfigError, set_opt_level, config, 'jit')
예제 #56
0
def test_no_gcrootfinder_with_boehm():
    config = get_combined_translation_config()
    config.translation.gcrootfinder = "shadowstack"
    py.test.raises(ConflictConfigError, set_opt_level, config, '0')