示例#1
0
        for c in structure['connections']:
            in_mapping, out_mapping = self.create_connection(c, namespace, in_mappings, out_mappings)
            for p in in_mapping:
                export_in_mappings.setdefault(p, []).extend(in_mapping[p])
            export_out_mappings.update(out_mapping)

        return export_in_mappings, export_out_mappings


def generate_app_info(cs_info, verify=True):
    a = Analyzer(cs_info, verify=verify)
    return a.app_info


if __name__ == '__main__':
    import cscompiler
    import json

    filename = 'scripts/test2.calvin'
    with open(filename, 'r') as f:
        script = f.read()
        print script
        print "---------------"
        data, errors, warnings = cscompiler.compile(script, filename)
        if errors:
            print "{reason} {script} [{line}:{col}]".format(script=filename, **errors[0])

        a = Analyzer(data)
        print "======= DONE ========"
        print json.dumps(a.app_info, indent=4, sort_keys=True)
for test in tests:
    filename = 'tests/scripts/%s.calvin' % test
    print test,

    with open(filename, 'r') as f:
        source = f.read()

    header = source.splitlines()[0].lstrip('/ ')
    print header,
    res[test] = [header]
    if test in crashers:
        res[test].append("CRASHER")
        print "CRASHER"
        continue

    prg, errors, warnings = cscompiler.compile(source, test)
    if error:
        print "{reason} {script} [{line}:{col}]".format(script=filename, **error)
        raise Exception(error['reason'])
    a1 = A1(prg)
    a2 = A2(prg)

    # print "======= DONE ========"

    if a1.app_info == a2.app_info:
        output = "EXPECTED DIFF" if test in expected_diff else "IDENTICAL"
        print output
    else:
        output = "EXPECTED DIFF" if test in expected_diff else "DIFFERENCE"
        print output
        out1 = json.dumps(a1.app_info, indent=4, sort_keys=True)
示例#3
0
for test in tests:
    filename = 'tests/scripts/%s.calvin' % test
    print test,

    with open(filename, 'r') as f:
        source = f.read()

    header = source.splitlines()[0].lstrip('/ ')
    print header,
    res[test] = [header]
    if test in crashers:
        res[test].append("CRASHER")
        print "CRASHER"
        continue

    prg, errors, warnings = cscompiler.compile(source, test)
    if error:
        print "{reason} {script} [{line}:{col}]".format(script=filename,
                                                        **error)
        raise Exception(error['reason'])
    a1 = A1(prg)
    a2 = A2(prg)

    # print "======= DONE ========"

    if a1.app_info == a2.app_info:
        output = "EXPECTED DIFF" if test in expected_diff else "IDENTICAL"
        print output
    else:
        output = "EXPECTED DIFF" if test in expected_diff else "DIFFERENCE"
        print output
示例#4
0
            else:
                # Add mapping from internal actor/component to component outport
                export_mappings['out'][dst_actor_port] = src_actor_port

        return export_mappings

def generate_app_info(cs_info):
    a = Analyzer(cs_info)
    return a.app_info


if __name__ == '__main__':
    import cscompiler
    import json

    filename = 'scripts/test2.calvin'
    with open(filename, 'r') as f:
        script = f.read()
        print script
        print "---------------"
        data, errors, warnings = cscompiler.compile(script, filename)
        if errors:
            print "{reason} {script} [{line}:{col}]".format(script=filename, **error[0])

        a = Analyzer(data)
        print "======= DONE ========"
        print json.dumps(a.app_info, indent=4, sort_keys=True)