예제 #1
0
파일: testing.py 프로젝트: MJJoyce/numba
def multitest():
    """
    Run tests in multiple processes.
    """
    import numba.unittest_support as unittest
    import multiprocessing as mp

    loader = unittest.TestLoader()
    startdir = "numba.tests"
    suites = loader.discover(startdir)
    tests = _flatten_suite(suites)
    # Distribute tests to multiple processes
    pool = mp.Pool(processes=mp.cpu_count())
    results = pool.imap_unordered(_multiruntest, tests)

    errct = 0
    for ok, out in results:
        if not ok:
            print()
            print("=== Error ===")
            print(out)
            errct += 1
        else:
            print('.', end='')
            sys.stdout.flush()

    print()
    if errct == 0:
        print("All passed!")
        return True
    else:
        print("Error %d/%d" % (errct, len(tests)))
        return False
예제 #2
0
def discover_tests(startdir):
    """Discover test under a directory
    """

    loader = unittest.TestLoader()
    suite = loader.discover(startdir)
    return suite
예제 #3
0
    def _do_discovery(self, argv, Loader=None):
        """The discovery process is complicated by the fact that:

        * different test suites live under different directories
        * some test suites may not be available (CUDA)
        * some tests may have to be run serially, even in the presence of the '-m' flag."""

        from numba import cuda
        join = os.path.join
        loader = unittest.TestLoader() if Loader is None else Loader()
        topdir = os.path.abspath(join(os.path.dirname(__file__), '../..'))
        base_tests = loader.discover(join(topdir, 'numba/tests'), 'test*.py',
                                     topdir)
        cuda_tests = [
            loader.discover(join(topdir, 'numba/cuda/tests/nocuda'),
                            'test*.py', topdir)
        ]
        if cuda.is_available():
            gpus = cuda.list_devices()
            if gpus and gpus[0].compute_capability >= (2, 0):
                cuda_tests.append(
                    loader.discover(join(topdir, 'numba/cuda/tests/cudadrv'),
                                    'test*.py', topdir))
                cuda_tests.append(
                    loader.discover(join(topdir, 'numba/cuda/tests/cudapy'),
                                    'test*.py', topdir))
            else:
                print("skipped CUDA tests because GPU CC < 2.0")
        else:
            print("skipped CUDA tests")
        self.test = suite.TestSuite(tests=(base_tests,
                                           SerialSuite(cuda_tests)))
예제 #4
0
파일: testing.py 프로젝트: smtlify/numba
def discover_tests(startdir):
    """Discover test under a directory
    """
    # Avoid importing unittest
    from numba import unittest_support as unittest
    loader = unittest.TestLoader()
    suite = loader.discover(startdir)
    return suite
예제 #5
0
def test():
    import numba.unittest_support as unittest
    loader = unittest.TestLoader()
    startdir = "numba.tests"
    suite = loader.discover(startdir)

    runner = unittest.TextTestRunner(descriptions=True,
                                     verbosity=2,
                                     buffer=True)
    result = runner.run(suite)
    return result.wasSuccessful()
예제 #6
0
def multitest():
    """
    Run tests in multiple processes.
    """
    import numba.unittest_support as unittest
    import multiprocessing as mp
    loader = unittest.TestLoader()
    startdir = "numba.tests"
    suites = loader.discover(startdir)

    pool = mp.Pool(processes=mp.cpu_count())
    results = pool.map(_multiruntest, suites)
    return all(results)
예제 #7
0
파일: testing.py 프로젝트: MJJoyce/numba
def discover_tests(startdir):
    import numba.unittest_support as unittest

    loader = unittest.TestLoader()
    suite = loader.discover(startdir)
    return suite