Exemple #1
0
def test(ctx):
    """Run the felix tests and other commands."""

    # Make sure we're built.
    phases, iscr, felix = build(ctx)

    from buildsystem.flx import test_flx

    failed_srcs = []

    def test(src):
        try:
            passed = test_flx(phases.target, felix, src)
        except fbuild.ConfigFailed as e:
            ctx.logger.log(str(e))
            passed = False
        return src, passed

    # Run the dynamic loading tests first
    try:
        lib1 = felix.compile('test/regress/drt/lib1.flx', static=False)
        lib2 = felix.compile('test/regress/drt/lib2.flx', static=False)
    except fbuild.ExecutionError as e:
        ctx.logger.log(e, verbose=1)
    else:
        if not test_flx(phases.target, felix, 'test/regress/drt/main1.flx',
                env={'lib1': lib1, 'lib2': lib2}):
            failed_srcs.append('test/regress/drt/main1.flx')

    srcs = Path.globall(
        'test/*/*.flx',
        'test/*/*/*.flx',
        'tut/*/*.flx',
        exclude=[
            'test/drivers/*.flx',
            'test/faio/posix-*.flx',
            'test/faio/win-*.flx',
            'test/regress/drt/*.flx',
            'test/regress/bt/*.flx',
            'test/regress/kf/*.flx',
            'test/regress/nd/*.flx',
            'test/test-data/*.flx',
        ])

    if 'posix' in phases.target.platform:
        srcs.extend(Path.glob('test/faio/posix-*.flx'))

    if 'windows' in phases.target.platform:
        srcs.extend(Path.glob('test/faio/win-*.flx'))

    for src, passed in phases.target.ctx.scheduler.map(
            test,
            sorted(srcs, reverse=True)):
        if not passed:
            failed_srcs.append(src)

    if failed_srcs:
        ctx.logger.log('\nThe following tests failed:')
        for src in failed_srcs:
            ctx.logger.log('  %s' % src, color='yellow')
Exemple #2
0
 def test(src):
     try:
         passed = test_flx(phases.target, felix, src)
     except fbuild.ConfigFailed as e:
         ctx.logger.log(str(e))
         passed = False
     return src, passed
Exemple #3
0
def test(ctx):
    """Run the felix tests and other commands."""

    # Make sure we're built.
    phases, iscr, felix = build(ctx)

    from buildsystem.flx import test_flx, compile_flx

    failed = []

    def test(src):
        try:
            passed = test_flx(phases.target, felix, src)
        except fbuild.ConfigFailed as e:
            ctx.logger.log(str(e))
            passed = False
        return src, passed

    def test_compile(src):
        try:
            passed = compile_flx(phases.target, felix, src)
        except fbuild.ConfigFailed as e:
            ctx.logger.log(str(e))
            passed = False
        return src, passed

    # Run the dynamic loading tests first
    ctx.logger.log("\nRunning dynamic loading tests\n", color='red')
    try:
        lib1 = felix.compile('test/regress/drt/lib1.flx', static=False)
        lib2 = felix.compile('test/regress/drt/lib2.flx', static=False)
        print("lib1="+lib1)
        print("lib2="+lib2)
    except fbuild.ExecutionError as e:
        ctx.logger.log(e, verbose=1)
    else:
        if not test_flx(phases.target, felix, 'test/regress/drt/main1.flx',
                env={'lib1': lib1, 'lib2': lib2}):
            failed.append('test/regress/drt/main1.flx')

    srcs = [
      # CORE
      ('regress_rt' , Path.globall('test/regress/rt/*.flx')),
      ('regress_nd' , Path.globall('test/regress/nd/*.flx')),
      ('regress_stl' , Path.globall('test/regress/stl/*.flx')),

      ('tut_embedding' , Path.globall('tut/embedding/*.flx')),
      ('tut_migration', Path.globall('tut/migration/*.flx')),
      ('tut_tutorial', Path.globall('tut/tutorial/*.flx')),

      ('collection' , Path.globall('test/collection/*.flx')),
      #('drivers' , Path.globall('test/drivers/*.flx')),
      ('glob' , Path.globall('test/glob/*.flx')),
      ('judy' , Path.globall('test/judy/*.flx')),
      ('sqlite3' , Path.globall('test/sqlite/*.flx')),
      ('pthread' , Path.globall('test/pthread/*.flx')),
      ('stdlib' , Path.globall('test/stdlib/*.flx')),
      ('tre' , Path.globall('test/tre/*.flx')),
      ('web' , Path.globall('test/web/*.flx',exclude=['test/web/xml2-*.flx'])),

      # ASYNC I/O
      ('faio',Path.globall('test/faio/*.flx',exclude=['test/faio/posix-*.flx','test/faio/win-*.flx'])),
      ]

    gmp_h = config_call(
        'fbuild.config.c.gmp.gmp_h', 
        phases.target.platform,
        phases.target.c.static).header
    if gmp_h: ctx.logger.log("gmp supported",color='green')
    else: ctx.logger.log("gmp NOT supported",color='red')

    mman_h = config_call(
        'fbuild.config.c.posix04.sys_mman_h', 
        phases.target.platform,
        phases.target.c.static).header
    if mman_h: ctx.logger.log("mmap supported",color='green')
    else: ctx.logger.log("mmap NOT supported",color='red')

    libxml2_libxml_xmlexports_h = config_call(
        'fbuild.config.c.xml2.libxml2_libxml_xmlexports_h', 
        phases.target.platform,
        phases.target.c.static).header
    if libxml2_libxml_xmlexports_h: ctx.logger.log("libxml2 supported",color='green')
    else: ctx.logger.log("libxml2 NOT supported",color='red')

    zmq_h = config_call(
        'fbuild.config.c.zmq.zmq_h', 
        phases.target.platform,
        phases.target.c.static).header
    if zmq_h: ctx.logger.log("zmq supported",color='green')
    else: ctx.logger.log("zmq NOT supported",color='red')

    osrcs = [
      # EXTERNAL LIBS
      ('windows' in phases.target.platform,'faio_win', Path.globall('test/faio/win-*.flx')),
      ('posix' in phases.target.platform, 'faio_posix', Path.globall('test/faio/posix-*.flx')),
      (gmp_h,'gmp', Path.globall('test/gmp/*.flx')),
      (mman_h,'mmap', Path.globall('test/mmap/*.flx')),
      (libxml2_libxml_xmlexports_h,'xml2', Path.globall('test/web/xml2-*flx')),
      ]

    osrcs_compileonly = [
      (zmq_h,'zmq', Path.globall('test/zmq/*.flx')),
    ]
    #--------------------------------
    ctx.logger.log("\nRunning core tests\n", color='cyan')
    for name,paths in srcs:
      failed_srcs = []
      ctx.logger.log("Running test "+name, color='cyan')
      for src, passed in phases.target.ctx.scheduler.map(
          test,
          sorted(paths, reverse=True)):
        if not passed:
          failed_srcs.append(src)
          failed.append(src)

      if failed_srcs:
        ctx.logger.log('\nOf '+str (len (paths))+' tests')
        ctx.logger.log('\nThe following tests failed:')
        for src in failed_srcs:
          ctx.logger.log('  %s' % src, color='yellow')
      else:
        ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')

    ctx.logger.log("\nRunning optional tests\n", color='cyan')
    for flag,name,paths in osrcs:
      if flag:
        failed_srcs = []
        ctx.logger.log("Running test "+name, color='cyan')
        for src, passed in phases.target.ctx.scheduler.map(
            test,
            sorted(paths, reverse=True)):
          if not passed:
            failed_srcs.append(src)
            failed.append(src)

        if failed_srcs:
          ctx.logger.log('\nOf '+str (len (paths))+' tests')
          ctx.logger.log('\nThe following tests failed:')
          for src in failed_srcs:
            ctx.logger.log('  %s' % src, color='yellow')
        else:
          ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')
      else:
        ctx.logger.log("SKIPPING test "+name+" resource not availabe", color='red')

    ctx.logger.log("\nRunning optional compiler only tests\n", color='cyan')
    for flag,name,paths in osrcs_compileonly:
      if flag:
        failed_srcs = []
        ctx.logger.log("Compiling test "+name, color='cyan')
        for src, passed in phases.target.ctx.scheduler.map(
            test_compile,
            sorted(paths, reverse=True)):
          if not passed:
            failed_srcs.append(src)
            failed.append(src)

        if failed_srcs:
          ctx.logger.log('\nOf '+str (len (paths))+' tests')
          ctx.logger.log('\nThe following tests failed:')
          for src in failed_srcs:
            ctx.logger.log('  %s' % src, color='yellow')
        else:
          ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')
      else:
        ctx.logger.log("SKIPPING test "+name+" resource not availabe", color='red')


    if failed:
        ctx.logger.log('\n======================================')
        ctx.logger.log('\nThe following tests failed:')
        for src in failed:
            ctx.logger.log('  %s' % src, color='yellow')