Example #1
0
def run_example_code(filepath, eci):
    output = build_executable_cache([filepath], eci)
    section = None
    for line in output.splitlines():
        line = line.strip()
        if line.startswith('-+- '):      # start of a new section
            section = {}
        elif line == '---':              # section end
            assert section is not None
            yield section
            section = None
        elif line:
            assert section is not None
            key, value = line.split(': ')
            section[key] = int(value)
Example #2
0
def run_example_code(filepath, eci):
    output = build_executable_cache([filepath], eci)
    section = None
    for line in output.splitlines():
        line = line.strip()
        if line.startswith('-+- '):  # start of a new section
            section = {}
        elif line == '---':  # section end
            assert section is not None
            yield section
            section = None
        elif line:
            assert section is not None
            key, value = line.split(': ')
            section[key] = int(value)
Example #3
0
def run_example_code(filepath, eci):
    eci = eci.convert_sources_to_files(being_main=True)
    files = [filepath]
    output = build_executable_cache(files, eci)
    section = None
    for line in output.splitlines():
        line = line.strip()
        if line.startswith('-+- '):      # start of a new section
            section = {}
        elif line == '---':              # section end
            assert section is not None
            yield section
            section = None
        elif line:
            assert section is not None
            key, value = line.split(': ')
            section[key] = int(value)
Example #4
0
def run_example_code(filepath, eci, ignore_errors=False):
    eci = eci.convert_sources_to_files(being_main=True)
    files = [filepath]
    output = build_executable_cache(files, eci, ignore_errors=ignore_errors)
    section = None
    for line in output.splitlines():
        line = line.strip()
        if line.startswith("-+- "):  # start of a new section
            section = {}
        elif line == "---":  # section end
            assert section is not None
            yield section
            section = None
        elif line:
            assert section is not None
            key, value = line.split(": ")
            section[key] = int(value)
Example #5
0
def run_example_code(filepath, eci):
    eci = eci.convert_sources_to_files(being_main=True)
    files = [filepath]
    output = build_executable_cache(files, eci)
    section = None
    for line in output.splitlines():
        line = line.strip()
        if line.startswith('-+- '):  # start of a new section
            section = {}
        elif line == '---':  # section end
            assert section is not None
            yield section
            section = None
        elif line:
            assert section is not None
            key, value = line.split(': ')
            section[key] = int(value)
Example #6
0
def ask_gcc(question, add_source=""):
    includes = ['stdlib.h', 'stdio.h', 'sys/types.h']
    include_string = "\n".join(["#include <%s>" % i for i in includes])
    c_source = py.code.Source('''
    // includes
    %s

    %s

    // checking code
    int main(void)
    {
       %s
       return (0);
    }
    ''' % (include_string, add_source, str(question)))
    c_file = udir.join("gcctest.c")
    c_file.write(str(c_source) + '\n')
    eci = ExternalCompilationInfo()
    return build_executable_cache([c_file], eci)
Example #7
0
def ask_gcc(question, add_source=""):
    includes = ['stdlib.h', 'sys/types.h']
    include_string = "\n".join(["#include <%s>" % i for i in includes])
    c_source = py.code.Source('''
    // includes
    %s

    %s

    // checking code
    int main(void)
    {
       %s
       return (0);
    }
    ''' % (include_string, add_source, str(question)))
    c_file = udir.join("gcctest.c")
    c_file.write(c_source)
    eci = ExternalCompilationInfo()
    return build_executable_cache([c_file], eci)
Example #8
0
def ask_gcc(question, add_source=""):
    from pypy.translator.platform import platform
    includes = ['stdlib.h', 'stdio.h', 'sys/types.h']
    if platform.name != 'msvc':
        includes += ['inttypes.h']
    include_string = "\n".join(["#include <%s>" % i for i in includes])
    c_source = py.code.Source('''
    // includes
    %s

    %s

    // checking code
    int main(void)
    {
       %s
       return (0);
    }
    ''' % (include_string, add_source, str(question)))
    c_file = udir.join("gcctest.c")
    c_file.write(str(c_source) + '\n')
    eci = ExternalCompilationInfo()
    return build_executable_cache([c_file], eci)