Changeset 11

Show
Ignore:
Timestamp:
10/10/2007 12:01:42 AM (15 months ago)
Author:
mikeal
Message:

Modularized the framework infrastructure to be more embeddable.

-Mikeal

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/functest/__init__.py

    r1 r11  
     1import bin, collector, formatter, frame, global_settings, reports, runner 
     2import os 
     3from time import sleep 
     4 
     5def configure(settings_module=global_settings, registry={}): 
     6    """Configure the framework""" 
     7    import functest 
     8    functest.registry = registry 
     9    functest.modules_passed = [] 
     10     
     11def run_framework(test_args=[], test_runner=None): 
     12     
     13    if test_runner is None: 
     14        test_runner = runner.CLIRunner() 
     15         
     16    tests = []     
     17    test_runner.start() 
     18    if len(test_args) is not 0: 
     19        for arg in test_args: 
     20            tests.append( [ collector.create_test_module(arg), collector.create_module_chain(arg) ] ) 
     21    else: 
     22        tests.append([collector.create_test_module(os.path.curdir), collector.create_module_chain(os.path.curdir) ]) 
     23     
     24    test_runner.wrap_stdout(global_settings.wrap_stdout, global_settings.wrap_stderr) 
     25    global_settings.test_runner = test_runner 
     26    totals = frame.execute(tests) 
     27    test_runner.summary(totals) 
     28    sleep(.5) 
  • trunk/functest/bin.py

    r10 r11  
    1313#   limitations under the License. 
    1414 
    15 import collector 
    16 import frame 
    1715import global_settings 
    18 import runner 
    19 from time import sleep 
    2016 
    21 import os, sys 
     17import sys 
    2218 
    2319usage = """functest test framework. 
     
    3531    (filter=)  Only run tests where the name contains this filter.""" 
    3632 
    37 def main(args): 
     33def main(test_args): 
     34    # tests = [] 
     35    # cli_runner = runner.CLIRunner() 
     36    # cli_runner.start() 
     37    # if len(args) is not 0: 
     38    #     for arg in args: 
     39    #         tests.append( [ collector.create_test_module(arg), collector.create_module_chain(arg) ] ) 
     40    # else: 
     41    #     tests.append([collector.create_test_module(os.path.curdir), collector.create_module_chain(os.path.curdir) ]) 
     42    # cli_runner.wrap_stdout(global_settings.wrap_stdout, global_settings.wrap_stderr) 
     43    # global_settings.test_runner = cli_runner 
     44    # totals = frame.execute(tests) 
     45    # cli_runner.summary(totals) 
     46    # sleep(.5)     
     47     
     48    import functest 
     49    functest.run_framework(test_args) 
    3850 
    39     tests = [] 
    40     cli_runner = runner.CLIRunner() 
    41     cli_runner.start() 
    42     if len(args) is not 0: 
    43         for arg in args: 
    44             tests.append( [ collector.create_test_module(arg), collector.create_module_chain(arg) ] ) 
    45     else: 
    46         tests.append([collector.create_test_module(os.path.curdir), collector.create_module_chain(os.path.curdir) ]) 
    47     cli_runner.wrap_stdout(global_settings.wrap_stdout, global_settings.wrap_stderr) 
    48     global_settings.test_runner = cli_runner 
    49     totals = frame.execute(tests) 
    50     cli_runner.summary(totals) 
    51     sleep(.5)     
    5251     
    5352def process_args(): 
     53    import functest 
     54    functest.configure() 
     55     
    5456    args = list(sys.argv) 
    5557    if args[0].endswith('functest') or args[0].endswith('functest.py') or args[0].endswith('functest.exe'): 
     
    6870    options = [ x.replace('--', '') for x in args ] 
    6971     
    70     import functest 
    71     functest.registry = {} 
    72     functest.modules_passed = [] 
    7372    for option in options: 
    7473        if option.find('=') is not -1: 
     
    8584    return functest.modules_passed 
    8685     
    87 if __name__ == "__main__": 
    88     main() 
     86 
  • trunk/scripts/functest

    r10 r11  
    1414#   limitations under the License. 
    1515 
    16 from functest import bin 
     16import functest 
    1717 
    1818if __name__ == '__main__': 
    19     bin.main(bin.process_args()) 
     19    functest.bin.main(functest.bin.process_args()) 
    2020 
    2121