Beispiel #1
0
def verifySuite(suite):
    '''Verify current suite is legal'''
    if 'create' in suite and 'destroy' not in suite:
        abort( '%s:%s: Suite %s has createSuite() but no destroySuite()' %
               (suite['file'], suite['create'], suite['name']) )
    elif 'destroy' in suite and 'create' not in suite:
        abort( '%s:%s: Suite %s has destroySuite() but no createSuite()' %
               (suite['file'], suite['destroy'], suite['name']) )
Beispiel #2
0
def verifySuite(suite):
    '''Verify current suite is legal'''
    if 'create' in suite and 'destroy' not in suite:
        abort('%s:%s: Suite %s has createSuite() but no destroySuite()' %
              (suite['file'], suite['create'], suite['name']))
    elif 'destroy' in suite and 'create' not in suite:
        abort('%s:%s: Suite %s has destroySuite() but no createSuite()' %
              (suite['file'], suite['destroy'], suite['name']))
Beispiel #3
0
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    global options
    options=_options
    for file in files:
        scanInputFile(file)
    global suites
    if len(suites) is 0 and not options.root:
        abort( 'No tests defined' )
    return [options,suites]
def verifySuite(suite):
    """Verify current suite is legal"""
    if "create" in suite and "destroy" not in suite:
        abort(
            "%s:%s: Suite %s has createSuite() but no destroySuite()" % (suite["file"], suite["create"], suite["name"])
        )
    elif "destroy" in suite and "create" not in suite:
        abort(
            "%s:%s: Suite %s has destroySuite() but no createSuite()" % (suite["file"], suite["destroy"], suite["name"])
        )
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    global options
    options=_options
    for file in files:
        scanInputFile(file)
    global suites
    if len(suites) is 0 and not options.root:
        abort( 'No tests defined' )
    return [options,suites]
Beispiel #6
0
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    global options
    options = _options
    for file in files:
        scanInputFile(file)
    global suites
    if len(suites) is 0 and not options.root:
        abort('No tests defined')

    #print("INFO\n")
    #for suite in suites:
    #for key in suite:
    #print(key,suite[key])
    #print("")

    return [options, suites]
Beispiel #7
0
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    global options
    options=_options
    for file in files:
        scanInputFile(file)
    global suites
    if len(suites) is 0 and not options.root:
        abort( 'No tests defined' )

    #print("INFO\n")
    #for suite in suites:
        #for key in suite:
            #print(key,suite[key])
        #print("")

    return [options,suites]
Beispiel #8
0
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    #
    # Reset global data
    #
    global options
    options=_options
    global suites
    suites = []
    global suite
    suite = None
    global inBlock
    inBlock = 0
    #
    for file in files:
        scanInputFile(file)
    if len(suites) is 0 and not options.root:
        abort( 'No tests defined' )
    return [options,suites]
Beispiel #9
0
def scanInputFiles(files, _options):
    '''Scan all input files for test suites'''
    #
    # Reset global data
    #
    global options
    options = _options
    global suites
    suites = []
    global suite
    suite = None
    global inBlock
    inBlock = 0
    #
    for file in files:
        scanInputFile(file)
    if len(suites) is 0 and not options.root:
        abort('No tests defined')
    return [options, suites]
Beispiel #10
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
Beispiel #11
0
def addSuiteCreateDestroy( suite, which, line ):
    '''Add createSuite()/destroySuite() to current suite'''
    if which in suite:
        abort( '%s:%s: %sSuite() already declared' % ( suite['file'], str(line), which ) )
    suite[which] = line
Beispiel #12
0
def addSuiteCreateDestroy(suite, which, line):
    '''Add createSuite()/destroySuite() to current suite'''
    if which in suite:
        abort('%s:%s: %sSuite() already declared' %
              (suite['file'], str(line), which))
    suite[which] = line
def addSuiteCreateDestroy(suite, which, line):
    """Add createSuite()/destroySuite() to current suite"""
    if which in suite:
        abort("%s:%s: %sSuite() already declared" % (suite["file"], str(line), which))
    suite[which] = line
Beispiel #14
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