def run_config(config, basedir, output_dir, random_seed, report_all, args):
    for key in config.iterkeys():
        if not os.path.isabs(config[key]):
            config[key] = os.path.abspath(os.path.join(basedir, config[key]))
    report_filename = "report.xml"
    report_filename = os.path.abspath(os.path.join(output_dir,
                                                   report_filename))

    global normalize
    if "normalizer" in config:
        normalize = imp.load_source("normalizer",
                                    config["normalizer"]).normalize
    else:
        normalize = lambda x, y: x

    command = " ".join(args[2:])
    command += " schema=" + os.path.basename(config['ddl'])

    generator = SQLGenerator(config["schema"], config["template"])
    statements = []
    counter = 0

    for i in generator.generate():
        statements.append({"id": counter, "SQL": i})
        counter += 1

    if run_once("jni", command, statements) != 0:
        exit(-1)
    if run_once("hsqldb", command, statements) != 0:
        exit(-1)

    report = XMLGenerator({"Statements": statements})
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    fd = open(report_filename, "w")
    fd.write(report.toXML())
    fd.close()

    success = generate_html_reports({"Statements": statements}, random_seed,
                                    report_all, output_dir)
    return success
Beispiel #2
0
def run_config(config, basedir, output_dir, random_seed, report_all, args):
    for key in config.iterkeys():
        if not os.path.isabs(config[key]):
            config[key] = os.path.abspath(os.path.join(basedir, config[key]))
    report_filename = "report.xml"
    report_filename = os.path.abspath(os.path.join(output_dir, report_filename))

    global normalize
    if "normalizer" in config:
        normalize = imp.load_source("normalizer", config["normalizer"]).normalize
    else:
        normalize = lambda x, y: x

    command = " ".join(args[2:])
    command += " schema=" + os.path.basename(config['ddl'])

    generator = SQLGenerator(config["schema"], config["template"])
    statements = []
    counter = 0

    for i in generator.generate():
        statements.append({"id": counter,
                           "SQL": i})
        counter += 1

    if run_once("jni", command, statements) != 0:
        exit(-1)
    if run_once("hsqldb", command, statements) != 0:
        exit(-1)

    report = XMLGenerator({"Statements": statements})
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    fd = open(report_filename, "w")
    fd.write(report.toXML())
    fd.close()

    success = generate_html_reports({"Statements": statements},
                                    random_seed, report_all, output_dir)
    return success
def run_config(config, basedir, output_dir, random_seed, report_all, args):
    for key in config.iterkeys():
        if not os.path.isabs(config[key]):
            config[key] = os.path.abspath(os.path.join(basedir, config[key]))
    report_filename = "report.xml"
    report_filename = os.path.abspath(os.path.join(output_dir, report_filename))
    template = config["template"]

    global normalize
    if "normalizer" in config:
        normalize = imp.load_source("normalizer", config["normalizer"]).normalize
    else:
        normalize = lambda x, y: x

    command = " ".join(args[2:])
    command += " schema=" + os.path.basename(config["ddl"])

    random_state = random.getstate()
    if "template-jni" in config:
        template = config["template-jni"]
    generator = SQLGenerator(config["schema"], template, True)
    statements = []
    counter = 0

    for i in generator.generate():
        statements.append({"id": counter, "SQL": i})
        counter += 1

    if run_once("jni", command, statements) != 0:
        print >> sys.stderr, "Test with the JNI backend had errors."
        exit(1)

    random.seed(random_seed)
    random.setstate(random_state)
    # To get around the timestamp issue. Volt and HSQLDB use different units
    # for timestamp (microsec vs. millisec), so we have to use different
    # template file for regression test, since all the statements are not
    # generated in this case.
    if "template-hsqldb" in config:
        template = config["template-hsqldb"]
    generator = SQLGenerator(config["schema"], template, False)
    counter = 0

    for i in generator.generate():
        statements[counter]["SQL"] = i
        counter += 1

    if run_once("hsqldb", command, statements) != 0:
        print >> sys.stderr, "Test with the HSQLDB backend had errors."
        exit(1)

    report_dict = {"Seed": random_seed, "Statements": statements}
    report = XMLGenerator(report_dict)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    fd = open(report_filename, "w")
    fd.write(report.toXML())
    fd.close()

    success = generate_html_reports(report_dict, output_dir, report_all)
    return success
def run_config(config, basedir, output_dir, random_seed, report_all, args):
    for key in config.iterkeys():
        if not os.path.isabs(config[key]):
            config[key] = os.path.abspath(os.path.join(basedir, config[key]))
    report_filename = "report.xml"
    report_filename = os.path.abspath(os.path.join(output_dir, report_filename))
    template = config["template"]

    global normalize
    if "normalizer" in config:
        normalize = imp.load_source("normalizer", config["normalizer"]).normalize
    else:
        normalize = lambda x, y: x

    command = " ".join(args[2:])
    command += " schema=" + os.path.basename(config['ddl'])

    random_state = random.getstate()
    if "template-jni" in config:
        template = config["template-jni"]
    generator = SQLGenerator(config["schema"], template, True)
    statements = []
    counter = 0

    for i in generator.generate():
        statements.append({"id": counter,
                           "SQL": i})
        counter += 1

    if run_once("jni", command, statements) != 0:
        print >> sys.stderr, "Test with the JNI backend had errors."
        exit(1)

    random.seed(random_seed)
    random.setstate(random_state)
    # To get around the timestamp issue. Volt and HSQLDB use different units
    # for timestamp (microsec vs. millisec), so we have to use different
    # template file for regression test, since all the statements are not
    # generated in this case.
    if "template-hsqldb" in config:
        template = config["template-hsqldb"]
    generator = SQLGenerator(config["schema"], template, False)
    counter = 0

    for i in generator.generate():
        statements[counter]["SQL"] = i
        counter += 1

    if run_once("hsqldb", command, statements) != 0:
        print >> sys.stderr, "Test with the HSQLDB backend had errors."
        exit(1)

    report_dict = {"Seed": random_seed, "Statements": statements}
    report = XMLGenerator(report_dict)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    fd = open(report_filename, "w")
    fd.write(report.toXML())
    fd.close()

    success = generate_html_reports(report_dict, output_dir, report_all)
    return success