Пример #1
0
def run_cram_tests(project, logger):
    logger.info("Running Cram command line tests")

    command_and_arguments = _cram_command_for(project)
    command_and_arguments.extend(_find_files(project))
    report_file = _report_file(project)

    env = os.environ.copy()
    source_dir = project.expand_path("$dir_source_main_python")
    _prepend_path(env, "PYTHONPATH", source_dir)
    script_dir = project.expand_path('$dir_source_main_scripts')
    _prepend_path(env, "PATH", script_dir)

    return_code = execute_command(command_and_arguments,
                                  report_file,
                                  env=env,
                                  error_file_name=report_file)

    report = read_file(report_file)
    result = report[-1][2:].strip()

    if return_code != 0:
        logger.error("Cram tests failed!")
        if project.get_property("verbose"):
            for line in report:
                logger.error(line.rstrip())
        else:
            logger.error(result)

        logger.error("See: '{0}' for details".format(report_file))
        raise BuildFailedException("Cram tests failed!")

    logger.info("Cram tests were fine")
    logger.info(result)
Пример #2
0
def run_cram_tests(project, logger):
    logger.info("Running Cram command line tests")

    command_and_arguments = _cram_command_for(project)
    command_and_arguments.extend(_find_files(project))
    report_file = _report_file(project)

    env = os.environ.copy()
    source_dir = project.expand_path("$dir_source_main_python")
    _prepend_path(env, "PYTHONPATH", source_dir)
    script_dir = project.expand_path('$dir_source_main_scripts')
    _prepend_path(env, "PATH", script_dir)

    return_code = execute_command(command_and_arguments,
                                  report_file,
                                  env=env,
                                  error_file_name=report_file)

    report = read_file(report_file)
    result = report[-1][2:].strip()

    if return_code != 0:
        logger.error("Cram tests failed!")
        if project.get_property("verbose"):
            for line in report:
                logger.error(line.rstrip())
        else:
            logger.error(result)

        logger.error("See: '{0}' for details".format(report_file))
        raise BuildFailedException("Cram tests failed!")

    logger.info("Cram tests were fine")
    logger.info(result)
Пример #3
0
def run_cram_tests(project, logger):
    logger.info("Running Cram command line tests")

    cram_tests = list(_find_files(project))
    if not cram_tests or len(cram_tests) == 0:
        if project.get_property("cram_fail_if_no_tests"):
            raise BuildFailedException("No Cram tests found!")
        else:
            return

    command_and_arguments = _cram_command_for(project)
    command_and_arguments.extend(cram_tests)
    report_file = _report_file(project)

    env = os.environ.copy()
    if project.get_property('cram_run_test_from_target'):
        dist_dir = project.expand_path("$dir_dist")
        _prepend_path(env, "PYTHONPATH", dist_dir)
        script_dir_dist = project.get_property('dir_dist_scripts')
        _prepend_path(env, "PATH", os.path.join(dist_dir, script_dir_dist))
    else:
        source_dir = project.expand_path("$dir_source_main_python")
        _prepend_path(env, "PYTHONPATH", source_dir)
        script_dir = project.expand_path('$dir_source_main_scripts')
        _prepend_path(env, "PATH", script_dir)

    return_code = execute_command(command_and_arguments,
                                  report_file,
                                  env=env,
                                  error_file_name=report_file)

    if return_code != 0:
        error_str = "Cram tests failed! See %s for full details:\n%s" % (
            report_file, tail_log(report_file))
        logger.error(error_str)
        raise BuildFailedException(error_str)

    report = read_file(report_file)
    result = report[-1][2:].strip()
    logger.info("Cram tests were fine")
    logger.info(result)
Пример #4
0
def run_cram_tests(project, logger):
    logger.info("Running Cram command line tests")

    cram_tests = list(_find_files(project))
    if not cram_tests or len(cram_tests) == 0:
        if project.get_property("cram_fail_if_no_tests"):
            raise BuildFailedException("No Cram tests found!")
        else:
            return

    command_and_arguments = _cram_command_for(project)
    command_and_arguments.extend(cram_tests)
    report_file = _report_file(project)

    env = os.environ.copy()
    if project.get_property('cram_run_test_from_target'):
        dist_dir = project.expand_path("$dir_dist")
        _prepend_path(env, "PYTHONPATH", dist_dir)
        script_dir_dist = project.get_property('dir_dist_scripts')
        _prepend_path(env, "PATH", os.path.join(dist_dir, script_dir_dist))
    else:
        source_dir = project.expand_path("$dir_source_main_python")
        _prepend_path(env, "PYTHONPATH", source_dir)
        script_dir = project.expand_path('$dir_source_main_scripts')
        _prepend_path(env, "PATH", script_dir)

    return_code = execute_command(command_and_arguments,
                                  report_file,
                                  env=env,
                                  error_file_name=report_file)

    if return_code != 0:
        error_str = "Cram tests failed! See %s for full details:\n%s" % (report_file, tail_log(report_file))
        logger.error(error_str)
        raise BuildFailedException(error_str)

    report = read_file(report_file)
    result = report[-1][2:].strip()
    logger.info("Cram tests were fine")
    logger.info(result)