Beispiel #1
0
def run_suite(name):
    try:
        if not options.cleanup_mode:
            log_info("running suite: %s" % name)
            output_stream.indent()
        try:

            suite_data = file(current_namespace[-1].suites[name]).read()
            calls = parse_suite(suite_data)

            load_configuration(name)
            load_overrides()

            error_list = []
            # skip running suites if cleanup-only mode is set
            if not options.cleanup_mode:
                for script, args, line in calls:
                    errors = run_test(script, args)
                    if len(errors):
                        error_list += [
                            name + "(%d)::%s" % (line, x) for x in errors if x
                        ]
            return error_list
        except IOError, e:
            handle_exception("Unable to read suite %s" % name, e)
            return [name]
    finally:
        do_cleanup_for(name)
        output_stream.outdent()
Beispiel #2
0
def run_suite(name):
    try: 
        if not options.cleanup_mode:
            log_info("running suite: %s" % name)
            output_stream.indent()
        try:
        
            suite_data = file(current_namespace[-1].suites[name]).read()
            calls = parse_suite(suite_data)
        
            load_configuration(name)
            load_overrides() 

            error_list = [] 
            # skip running suites if cleanup-only mode is set 
            if not options.cleanup_mode:
                for script,args,line in calls: 
                    errors = run_test(script,args)
                    if len(errors):                     
                        error_list += [name + "(%d)::%s" % (line,x) for x in errors if x]
            return error_list
        except IOError,e: 
            handle_exception("Unable to read suite %s" % name,e)
            return [name]
    finally: 
        do_cleanup_for(name)
        output_stream.outdent()
Beispiel #3
0
def run_test(name, args):

    # this pushes the correct namespace on the stack
    # should be popped
    test = current_namespace[-1].lookup(name)
    if test is None:
        raise NameError("Unable to locate %s or %s in search path" %
                        (name + TEST, name + SUITE))
    name = test

    current = current_namespace[-1]
    try:
        if current.suites.get(name):
            if args:
                log_warn("Arguments provided to suites are ignored! [%s%s]" %
                         (name, args))
            return run_suite(name)
        elif current.tests.get(name):

            # don't do anything in cleanup only mode
            if options.cleanup_mode:
                return []

            try:
                log_info("running test: %s" % name)
                output_stream.indent()
                try:
                    script = file(current.tests[name]).read()
                    try:
                        parameters = make_dict_from_call(
                            args,
                            get_twill_glocals()[0])
                    except (ValueError, TypeError, SyntaxError), e:
                        e.args = ("\"%s%s\": Only positional argument passing is supported in suites." % \
                                      (name, args), ) + e.args[1:]
                        raise e
                    script = make_twill_local_defs(parameters) + script
                    twill.execute_string(script, no_reset=1)
                    return []
                except IOError, e:
                    handle_exception(
                        "Unable to read test '%s'" % (name + TEST), e)
                    return [name]
                except Exception, e:
                    handle_exception("Error running %s" % name, e)
                    return [name]
Beispiel #4
0
def run_test(name,args):

    # this pushes the correct namespace on the stack
    # should be popped
    test = current_namespace[-1].lookup(name)
    if test is None:
        raise NameError("Unable to locate %s or %s in search path" %
                        (name + TEST, name + SUITE))
    name = test

    current = current_namespace[-1]
    try:
        if current.suites.get(name):
            if args:
                log_warn("Arguments provided to suites are ignored! [%s%s]" 
                         % (name,args))
            return run_suite(name)
        elif current.tests.get(name):

            # don't do anything in cleanup only mode 
            if options.cleanup_mode:
                return []

            try:
                log_info("running test: %s" % name)
                output_stream.indent()
                try:            
                    script = file(current.tests[name]).read()
                    try:
                        parameters = make_dict_from_call(args,get_twill_glocals()[0])
                    except (ValueError, TypeError, SyntaxError), e:
                        e.args = ("\"%s%s\": Only positional argument passing is supported in suites." % \
                                      (name, args), ) + e.args[1:]
                        raise e
                    script = make_twill_local_defs(parameters) + script
                    twill.execute_string(script, no_reset=1)
                    return []
                except IOError, e: 
                    handle_exception("Unable to read test '%s'" % (name + TEST), e)
                    return [name]
                except Exception, e: 
                    handle_exception("Error running %s" % name, e)
                    return [name]