104 lines · 3.3 KB · Text
RawDownload
tdc - Adding plugins for tdc Author: Brenda J. Butler - bjb@mojatatu.com ADDING PLUGINS-------------- A new plugin should be written in python as a class that inherits from TdcPlugin.There are some examples in plugin-lib. The plugin can be used to add functionality to the test framework,such as: - adding commands to be run before and/or after the test suite- adding commands to be run before and/or after the test cases- adding commands to be run before and/or after the execute phase of the test cases- ability to alter the command to be run in any phase:    pre        (the pre-suite stage)    prepare    execute    verify    teardown    post       (the post-suite stage)- ability to add to the command line args, and use them at run time  The functions in the class should follow the following interfaces:     def __init__(self)    def pre_suite(self, testcount, testidlist)     # see "PRE_SUITE" below    def post_suite(self, ordinal)                  # see "SKIPPING" below    def pre_case(self, test_ordinal, testid)       # see "PRE_CASE" below    def post_case(self)    def pre_execute(self)    def post_execute(self)    def adjust_command(self, stage, command)       # see "ADJUST" below    def add_args(self, parser)                     # see "ADD_ARGS" below    def check_args(self, args, remaining)          # see "CHECK_ARGS" below  PRE_SUITE This method takes a testcount (number of tests to be run) andtestidlist (array of test ids for tests that will be run).  This isuseful for various things, including when an exception occurs and therest of the tests must be skipped.  The info is stored in the object,and the post_suite method can refer to it when dumping the "skipped"TAP output.  The tdc.py script will do that for the test suite asdefined in the test case, but if the plugin is being used to run extratests on each test (eg, check for memory leaks on associatedco-processes) then that other tap output can be generated in thepost-suite method using this info passed in to the pre_suite method.  SKIPPING The post_suite method will receive the ordinal number of the lasttest to be attempted.  It can use this info when outputtingthe TAP output for the extra test cases.  PRE_CASE The pre_case method will receive the ordinal number of the testand the test id.  Useful for outputing the extra test results.  ADJUST The adjust_command method receives a string representingthe execution stage and a string which is the actual command to beexecuted.  The plugin can adjust the command, based on the stage ofexecution. The stages are represented by the following strings:     'pre'    'setup'    'command'    'verify'    'teardown'    'post' The adjust_command method must return the adjusted command so tdccan use it.  ADD_ARGS The add_args method receives the argparser object and can addarguments to it.  Care should be taken that the new arguments do notconflict with any from tdc.py or from other plugins that will be usedconcurrently. The add_args method should return the argparser object.  CHECK_ARGS The check_args method is so that the plugin can do validation onthe args, if needed.  If there is a problem, and Exception shouldbe raised, with a string that explains the problem. eg:  raise Exception('plugin xxx, arg -y is wrong, fix it')