예제 #1
0
파일: maven.py 프로젝트: tapichu/pyautotest
def report_errors(clazz, output, max_lines):
    """
    Prints information about errors.
    The errors can be compilation errors or test failures.
    """
    if COMPILE_ERR_PATC.search(output):
        # Compilation errors
        print error('Compilation errors:')
        for line in get_compilation_errors(output):
            print line
    else:
        # Test errors: search for the reports
        if clazz.endswith('Impl'):
            clazz = clazz[:-4]

        groups = (REPORT_DIR_PATC.match(line) for line in output.splitlines())
        dirs = (clean_path(g.group(1)) for g in groups if g)

        reports = gen_find('*' + clazz + '*.txt', dirs.next())
        lines = [line for line in open(reports.next())]
        
        if 0 < max_lines < len(lines):
            lines = lines[:max_lines]
        for line in lines:
            print line,
예제 #2
0
파일: maven.py 프로젝트: tapichu/pyautotest
def run_command(command, root_dir):
    """
    Runs a command using subprocess.
    """
    print highlight('\nRunning tests: %s' % command)

    start_time = time.time()
    proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
            stderr=subprocess.PIPE, cwd=root_dir)
    stdout_value, stderr_value = proc.communicate()
    end_time = time.time()

    if 0 < proc.returncode > 1:
        print error('Error trying to run the tests')
        print error(stderr_value)
        stdout_value = stderr_value
    else:
        print highlight('-------------------------------')
        print highlight('Finished tests in %.2f seconds\n' % (end_time - start_time))

    return (proc.returncode, stdout_value)
예제 #3
0
    import autotest.kde

    # Parse arguments
    parser = option_parser()
    (options, args) = parser.parse_args()
    if not options.root_path:
        parser.error('option -p is mandatory')

    modified_files = gen_follow_all('*.java', options.root_path)
    results = gen_mvntest(modified_files, options.root_path)

    for clazz, exit_code, output in results:
        # Stop the program if we're unable to execute the command
        if 0 < exit_code > 1:
            modified_files.close()
        else:
            # Print the number of tests, errors, etc.
            report_totals(output)

            if exit_code == 1:
                if options.kde:
                    autotest.kde.passive_popup('Errors in the tests!', 10,
                            'pyAutotest - %s' % clazz)
                print error('\nErrors in the tests!\n')
                report_errors(clazz, output, options.lines)
            else:
                if options.kde:
                    autotest.kde.passive_popup('Test execution successful!', 10,
                            'pyAutotest - %s' % clazz)