Esempio n. 1
0
    verbose = False
    parser = argparse.ArgumentParser(description='Compare the output of a program to a reference program')
    parser.add_argument("files", metavar='FILE', nargs="*", help="Path to program to test")
    parser.add_argument("-v","--verbose", action='store_true', help="Be verbose")
    parser.add_argument("-p","--pretend", action='store_true', help="Run tests but don't write any data")
    parser.add_argument("--ref", type=argparse.FileType('r'), nargs='+', help="Path to reference file")
    parser.add_argument("-r","--raw", action='store_true', help="Read input as raw path to source file")
    parser.add_argument("--basedir", action='store', default=None, help="Base directory to use for reference files")

    args = parser.parse_args()
    if args.verbose:
        verbose=True

    if verbose:
        sys.stderr.write("args: {}\n".format(args))
    tests = tl.load_tests(args.ref,verbose=verbose, basedir=args.basedir)
    for (k,t) in tests.items():
        if verbose:
            sys.stderr.write("Running {} tests on reference program {}, output to {}...\n".format(k, t['path'], t['basedir']))            
            run_tests(t,base_path=t['basedir'],output_path=t['basedir'],verbose=verbose)

    for tokens in map(shlex.split, fileinput.input(args.files)):
        for path in tokens:
            if verbose:
                sys.stderr.write("Running tests on {}\n".format(path))
            
            (basedir,basefile) = os.path.split(path)

            if basefile == t['path']:
                if verbose:
                    sys.stderr.write("Using path as source {}\n".format(basefile))
Esempio n. 2
0
        sys.stderr.write("{}: environment error\n".format(test_file))


if __name__ == '__main__':
    import argparse
    import fileinput

    parser = argparse.ArgumentParser(description='Compare a list of files to reference files')
    
    parser.add_argument("files", metavar='FILE', nargs="*", help="File name to read paths to source files from")
    parser.add_argument("--ref", type=argparse.FileType('r'), nargs='+', help="Path to reference file (.test)")
    parser.add_argument("--verbose","-v", action="store_true", help="Be verbose")
    parser.add_argument("--basedir", action='store', default=None, help="Base directory to use for reference files")

    args = parser.parse_args()

    ref_test = tl.load_tests(args.ref, basedir=args.basedir)
    open_refs(ref_test)

    #for (pid,path) in map(shlex.split, fileinput.input(args.files)):
    for path in imap(str.strip, fileinput.input(args.files)):
        if os.path.isfile(path):
            (path,filename) = os.path.split(path)
        for (name,test) in ref_test.items():
            (basedir,filename) = os.path.split(path)
            if filename == test['path']:
                path = basedir
            run_trials(test,path)

    close_refs(ref_test)