Beispiel #1
0
def generate_main_c(target, source, env):
    """Parse the unit test file and search for functions that start with `test_`."""

    parsed = ParsedCFile(str(source[0]), env['ARCH'])
    test_functions = parsed.defined_functions(criterion=lambda x: x.startswith('test_'))

    render_template_inplace(str(source[1]), {'tests': test_functions})
Beispiel #2
0
def test_inplace_render(tmpdir):
    """Make sure we can render a single template file in place."""

    inpath = os.path.join(os.path.dirname(__file__), 'data', 'template.c.tpl')

    tmpfile = tmpdir.join('template.c.tpl')
    tmppath = str(tmpfile)
    shutil.copyfile(inpath, tmppath)

    outpath = render_template_inplace(tmppath, {}, dry_run=True)
    assert outpath == tmppath[:-4]
    assert not os.path.exists(outpath)

    outpath = render_template_inplace(tmppath, {})
    assert outpath == tmppath[:-4]
    assert os.path.exists(outpath)
Beispiel #3
0
def template_shipfile_action(target, source, env):
    """Template a yaml ship recipe in place."""

    render_template_inplace(str(source[0]), {}, resolver=env["RESOLVER"])
Beispiel #4
0
def _find_product_dependencies(src_file, resolver):
    resolver.start_tracking()
    render_template_inplace(src_file, {}, dry_run=True, resolver=resolver)

    products = resolver.end_tracking()
    return products