コード例 #1
0
def parseCommandline(args):
    '''Analyze command line arguments'''
    global imported_fog
    global options

    parser = create_parser()
    (options, args) = parser.parse_args(args=args)
    if not options.header_filename is None:
        if not os.path.exists(options.header_filename):
            abort("ERROR: the file '%s' does not exist!" %
                  options.header_filename)
        INPUT = open(options.header_filename)
        headers = [line.strip() for line in INPUT]
        args.extend(headers)
        INPUT.close()

    if options.fog and not imported_fog:
        abort(
            "Cannot use the FOG parser.  Check that the 'ply' package is installed.  The 'ordereddict' package is also required if running Python 2.6"
        )

    if options.version:
        printVersion()

    # the cxxtest builder relies on this behaviour! don't remove
    if options.runner == 'none':
        options.runner = None

    if options.xunit_printer or options.runner == "XUnitPrinter":
        options.xunit_printer = True
        options.runner = "XUnitPrinter"
        if len(args) > 1:
            if options.xunit_file == "":
                if options.world == "":
                    options.world = "cxxtest"
                options.xunit_file = "TEST-" + options.world + ".xml"
        elif options.xunit_file == "":
            if options.world == "":
                options.world = "cxxtest"
            options.xunit_file = "TEST-" + options.world + ".xml"

    if options.error_printer:
        options.runner = "ErrorPrinter"
        options.haveStandardLibrary = True

    if options.noStaticInit and (options.root or options.part):
        abort('--no-static-init cannot be used with --root/--part')

    if options.gui and not options.runner:
        options.runner = 'StdioPrinter'

    files = setFiles(args[1:])
    if len(files) == 0 and not options.root:
        sys.stderr.write(parser.error("No input files found"))

    return files
コード例 #2
0
def parseCommandline(args):
    '''Analyze command line arguments'''
    global imported_fog
    global options

    parser = create_parser()
    (options, args) = parser.parse_args(args=args)
    if not options.header_filename is None:
        if not os.path.exists(options.header_filename):
            abort( "ERROR: the file '%s' does not exist!" % options.header_filename )
        INPUT = open(options.header_filename)
        headers = [line.strip() for line in INPUT]
        args.extend( headers )
        INPUT.close()

    if options.fog and not imported_fog:
        abort( "Cannot use the FOG parser.  Check that the 'ply' package is installed.  The 'ordereddict' package is also required if running Python 2.6")

    if options.version:
      printVersion()

    # the cxxtest builder relies on this behaviour! don't remove
    if options.runner == 'none':
        options.runner = None

    if options.xunit_printer or options.runner == "XUnitPrinter":
        options.xunit_printer=True
        options.runner="XUnitPrinter"
        if len(args) > 1:
            if options.xunit_file == "":
                if options.world == "":
                    options.world = "cxxtest"
                options.xunit_file="TEST-"+options.world+".xml"
        elif options.xunit_file == "":
            if options.world == "":
                options.world = "cxxtest"
            options.xunit_file="TEST-"+options.world+".xml"

    if options.error_printer:
      options.runner= "ErrorPrinter"
      options.haveStandardLibrary = True
    
    if options.noStaticInit and (options.root or options.part):
        abort( '--no-static-init cannot be used with --root/--part' )

    if options.gui and not options.runner:
        options.runner = 'StdioPrinter'

    files = setFiles(args[1:])
    if len(files) == 0 and not options.root:
        sys.stderr.write(parser.error("No input files found"))

    return files
コード例 #3
0
ファイル: cxxtestgen.py プロジェクト: 3upperm2n/PowerGraph
def parseCommandline(args):
    '''Analyze command line arguments'''
    global imported_fog
    global options
    parser = OptionParser("%prog [options] [<filename> ...]")
    parser.add_option("--version",
                      action="store_true", dest="version", default=False,
                      help="Write the CxxTest version.")
    parser.add_option("-o", "--output",
                      dest="outputFileName", default=None, metavar="NAME",
                      help="Write output to file NAME.")
    parser.add_option("-w","--world", dest="world", default="cxxtest",
                      help="The label of the tests, used to name the XML results.")
    parser.add_option("", "--include", action="append",
                      dest="headers", default=[], metavar="HEADER",
                      help="Include file HEADER in the test runner before other headers.")
    parser.add_option("", "--abort-on-fail",
                      action="store_true", dest="abortOnFail", default=False,
                      help="Abort tests on failed asserts (like xUnit).")
    parser.add_option("", "--main",
                      action="store", dest="main", default="main",
                      help="Specify an alternative name for the main() function.")
    parser.add_option("", "--headers",
                      action="store", dest="header_filename", default=None,
                      help="Specify a filename that contains a list of header files that are processed to generate a test runner.")
    parser.add_option("", "--runner",
                      dest="runner", default="", metavar="CLASS",
                      help="Create a test runner that processes test events using the class CxxTest::CLASS.")
    parser.add_option("", "--gui",
                      dest="gui", metavar="CLASS",
                      help="Create a GUI test runner that processes test events using the class CxxTest::CLASS. (deprecated)")
    parser.add_option("", "--error-printer",
                      action="store_true", dest="error_printer", default=False,
                      help="Create a test runner using the ErrorPrinter class, and allow the use of the standard library.")
    parser.add_option("", "--xunit-printer",
                      action="store_true", dest="xunit_printer", default=False,
                      help="Create a test runner using the XUnitPrinter class.")
    parser.add_option("", "--xunit-file",  dest="xunit_file", default="",
                      help="The file to which the XML summary is written for test runners using the XUnitPrinter class.  The default XML filename is TEST-<world>.xml, where <world> is the value of the --world option.  (default: cxxtest)")
    parser.add_option("", "--have-std",
                      action="store_true", dest="haveStandardLibrary", default=False,
                      help="Use the standard library (even if not found in tests).")
    parser.add_option("", "--no-std",
                      action="store_true", dest="noStandardLibrary", default=False,
                      help="Do not use standard library (even if found in tests).")
    parser.add_option("", "--have-eh",
                      action="store_true", dest="haveExceptionHandling", default=False,
                      help="Use exception handling (even if not found in tests).")
    parser.add_option("", "--no-eh",
                      action="store_true", dest="noExceptionHandling", default=False,
                      help="Do not use exception handling (even if found in tests).")
    parser.add_option("", "--longlong",
                      dest="longlong", default=None, metavar="TYPE",
                      help="Use TYPE as for long long integers.  (default: not supported)")
    parser.add_option("", "--no-static-init",
                      action="store_true", dest="noStaticInit", default=False,
                      help="Do not rely on static initialization in the test runner.")
    parser.add_option("", "--template",
                      dest="templateFileName", default=None, metavar="TEMPLATE",
                      help="Generate the test runner using file TEMPLATE to define a template.")
    parser.add_option("", "--root",
                      action="store_true", dest="root", default=False,
                      help="Write the main() function and global data for a test runner.")
    parser.add_option("", "--part",
                      action="store_true", dest="part", default=False,
                      help="Write the tester classes for a test runner.")
    #parser.add_option("", "--factor",
                      #action="store_true", dest="factor", default=False,
                      #help="Declare the _CXXTEST_FACTOR macro.  (deprecated)")
    if imported_fog:
        fog_help = "Use new FOG C++ parser"
    else:
        fog_help = "Use new FOG C++ parser (disabled)"
    parser.add_option("-f", "--fog-parser",
                        action="store_true",
                        dest="fog",
                        default=False,
                        help=fog_help
                        )

    (options, args) = parser.parse_args(args=args)
    if not options.header_filename is None:
        if not os.path.exists(options.header_filename):
            abort( "ERROR: the file '%s' does not exist!" % options.header_filename )
        INPUT = open(options.header_filename)
        headers = [line.strip() for line in INPUT]
        args.extend( headers )
        INPUT.close()

    if options.fog and not imported_fog:
        abort( "Cannot use the FOG parser.  Check that the 'ply' package is installed.  The 'ordereddict' package is also required if running Python 2.6")

    if options.version:
      printVersion()

    # the cxxtest builder relies on this behaviour! don't remove
    if options.runner == 'none':
        options.runner = None

    if options.xunit_printer or options.runner == "XUnitPrinter":
        options.xunit_printer=True
        options.runner="XUnitPrinter"
        if len(args) > 1:
            if options.xunit_file == "":
                if options.world == "":
                    options.world = "cxxtest"
                options.xunit_file="TEST-"+options.world+".xml"
        elif options.xunit_file == "":
            if options.world == "":
                options.world = "cxxtest"
            options.xunit_file="TEST-"+options.world+".xml"

    if options.error_printer:
      options.runner= "ErrorPrinter"
      options.haveStandardLibrary = True
    
    if options.noStaticInit and (options.root or options.part):
        abort( '--no-static-init cannot be used with --root/--part' )

    if options.gui and not options.runner:
        options.runner = 'StdioPrinter'

    files = setFiles(args[1:])
    if len(files) == 0 and not options.root:
        sys.stderr.write(parser.error("No input files found"))

    return files
コード例 #4
0
                for fn in parse_info.get_functions(key,quiet=True):
                    tname = fn[0]
                    lineno = str(fn[1])
                    if tname.startswith('createSuite'):
                        # Indicate that we're using a dynamically generated test suite
                        suite['create'] = str(lineno) # (unknown line)
                    if tname.startswith('destroySuite'):
                        # Indicate that we're using a dynamically generated test suite
                        suite['destroy'] = str(lineno) # (unknown line)
                    if not tpat.match(tname):
                        # Skip non-test methods
                        continue
                    test = { 'name'   : tname,
                        'suite'  : suite,
                        'class'  : 'TestDescription_suite_%s_%s' % (suite['fullname'].replace('::','_'), tname),
                        'object' : 'testDescription_suite_%s_%s' % (suite['fullname'].replace('::','_'), tname),
                        'line'   : lineno,
                        }
                    suite['tests'].append(test)
                suites.append(suite)

    if not _options.root:
        ntests = 0
        for suite in suites:
            ntests += len(suite['tests'])
        if ntests == 0:
            abort( 'No tests defined' )
    #
    return [_options, suites]

コード例 #5
0
ファイル: cxxtest_fog.py プロジェクト: highinit/hiaux
                        # Indicate that we're using a dynamically generated test suite
                        suite['destroy'] = str(lineno)  # (unknown line)
                    if not tpat.match(tname):
                        # Skip non-test methods
                        continue
                    test = {
                        'name':
                        tname,
                        'suite':
                        suite,
                        'class':
                        'TestDescription_suite_%s_%s' %
                        (suite['fullname'].replace('::', '_'), tname),
                        'object':
                        'testDescription_suite_%s_%s' %
                        (suite['fullname'].replace('::', '_'), tname),
                        'line':
                        lineno,
                    }
                    suite['tests'].append(test)
                suites.append(suite)

    if not _options.root:
        ntests = 0
        for suite in suites:
            ntests += len(suite['tests'])
        if ntests == 0:
            abort('No tests defined')
    #
    return [_options, suites]
コード例 #6
0
def parseCommandline(args):
    '''Analyze command line arguments'''
    global imported_fog
    global options
    parser = OptionParser("%prog [options] [<filename> ...]")
    parser.add_option("--version",
                      action="store_true",
                      dest="version",
                      default=False,
                      help="Write the CxxTest version.")
    parser.add_option("-o",
                      "--output",
                      dest="outputFileName",
                      default=None,
                      metavar="NAME",
                      help="Write output to file NAME.")
    parser.add_option(
        "-w",
        "--world",
        dest="world",
        default="cxxtest",
        help="The label of the tests, used to name the XML results.")
    parser.add_option(
        "",
        "--include",
        action="append",
        dest="headers",
        default=[],
        metavar="HEADER",
        help="Include file HEADER in the test runner before other headers.")
    parser.add_option("",
                      "--abort-on-fail",
                      action="store_true",
                      dest="abortOnFail",
                      default=False,
                      help="Abort tests on failed asserts (like xUnit).")
    parser.add_option(
        "",
        "--main",
        action="store",
        dest="main",
        default="main",
        help="Specify an alternative name for the main() function.")
    parser.add_option(
        "",
        "--headers",
        action="store",
        dest="header_filename",
        default=None,
        help=
        "Specify a filename that contains a list of header files that are processed to generate a test runner."
    )
    parser.add_option(
        "",
        "--runner",
        dest="runner",
        default="",
        metavar="CLASS",
        help=
        "Create a test runner that processes test events using the class CxxTest::CLASS."
    )
    parser.add_option(
        "",
        "--gui",
        dest="gui",
        metavar="CLASS",
        help=
        "Create a GUI test runner that processes test events using the class CxxTest::CLASS. (deprecated)"
    )
    parser.add_option(
        "",
        "--error-printer",
        action="store_true",
        dest="error_printer",
        default=False,
        help=
        "Create a test runner using the ErrorPrinter class, and allow the use of the standard library."
    )
    parser.add_option(
        "",
        "--xunit-printer",
        action="store_true",
        dest="xunit_printer",
        default=False,
        help="Create a test runner using the XUnitPrinter class.")
    parser.add_option(
        "",
        "--xunit-file",
        dest="xunit_file",
        default="",
        help=
        "The file to which the XML summary is written for test runners using the XUnitPrinter class.  The default XML filename is TEST-<world>.xml, where <world> is the value of the --world option.  (default: cxxtest)"
    )
    parser.add_option(
        "",
        "--have-std",
        action="store_true",
        dest="haveStandardLibrary",
        default=False,
        help="Use the standard library (even if not found in tests).")
    parser.add_option(
        "",
        "--no-std",
        action="store_true",
        dest="noStandardLibrary",
        default=False,
        help="Do not use standard library (even if found in tests).")
    parser.add_option(
        "",
        "--have-eh",
        action="store_true",
        dest="haveExceptionHandling",
        default=False,
        help="Use exception handling (even if not found in tests).")
    parser.add_option(
        "",
        "--no-eh",
        action="store_true",
        dest="noExceptionHandling",
        default=False,
        help="Do not use exception handling (even if found in tests).")
    parser.add_option(
        "",
        "--longlong",
        dest="longlong",
        default=None,
        metavar="TYPE",
        help="Use TYPE as for long long integers.  (default: not supported)")
    parser.add_option(
        "",
        "--no-static-init",
        action="store_true",
        dest="noStaticInit",
        default=False,
        help="Do not rely on static initialization in the test runner.")
    parser.add_option(
        "",
        "--template",
        dest="templateFileName",
        default=None,
        metavar="TEMPLATE",
        help=
        "Generate the test runner using file TEMPLATE to define a template.")
    parser.add_option(
        "",
        "--root",
        action="store_true",
        dest="root",
        default=False,
        help="Write the main() function and global data for a test runner.")
    parser.add_option("",
                      "--part",
                      action="store_true",
                      dest="part",
                      default=False,
                      help="Write the tester classes for a test runner.")
    #parser.add_option("", "--factor",
    #action="store_true", dest="factor", default=False,
    #help="Declare the _CXXTEST_FACTOR macro.  (deprecated)")
    if imported_fog:
        fog_help = "Use new FOG C++ parser"
    else:
        fog_help = "Use new FOG C++ parser (disabled)"
    parser.add_option("-f",
                      "--fog-parser",
                      action="store_true",
                      dest="fog",
                      default=False,
                      help=fog_help)

    (options, args) = parser.parse_args(args=args)
    if not options.header_filename is None:
        if not os.path.exists(options.header_filename):
            abort("ERROR: the file '%s' does not exist!" %
                  options.header_filename)
        INPUT = open(options.header_filename)
        headers = [line.strip() for line in INPUT]
        args.extend(headers)
        INPUT.close()

    if options.fog and not imported_fog:
        abort(
            "Cannot use the FOG parser.  Check that the 'ply' package is installed.  The 'ordereddict' package is also required if running Python 2.6"
        )

    if options.version:
        printVersion()

    # the cxxtest builder relies on this behaviour! don't remove
    if options.runner == 'none':
        options.runner = None

    if options.xunit_printer or options.runner == "XUnitPrinter":
        options.xunit_printer = True
        options.runner = "XUnitPrinter"
        if len(args) > 1:
            if options.xunit_file == "":
                if options.world == "":
                    options.world = "cxxtest"
                options.xunit_file = "TEST-" + options.world + ".xml"
        elif options.xunit_file == "":
            if options.world == "":
                options.world = "cxxtest"
            options.xunit_file = "TEST-" + options.world + ".xml"

    if options.error_printer:
        options.runner = "ErrorPrinter"
        options.haveStandardLibrary = True

    if options.noStaticInit and (options.root or options.part):
        abort('--no-static-init cannot be used with --root/--part')

    if options.gui and not options.runner:
        options.runner = 'StdioPrinter'

    files = setFiles(args[1:])
    if len(files) == 0 and not options.root:
        sys.stderr.write(parser.error("No input files found"))

    return files