Exemplo n.º 1
0
def worker(test_queue, done_queue, worker_id, addr, authkey):
    """This is used by concurrent test processes. It takes a test
    off of the test_queue, runs it, then puts the Test object
    on the done_queue.
    """
    if addr is None:
        server = None
    else:
        server = get_client_manager(addr, authkey)

    # need a unique profile output file for each worker process
    testflo.profile._prof_file = 'profile_%s.out' % worker_id

    test_count = 0
    for test in iter(test_queue.get, 'STOP'):

        try:
            test_count += 1
            done_queue.put(test.run(server, addr, authkey))
        except:
            # we generally shouldn't get here, but just in case,
            # handle it so that the main process doesn't hang at the
            # end when it tries to join all of the concurrent processes.
            done_queue.put(test)

    # don't save anything unless we actually ran a test
    if test_count > 0:
        save_coverage()
        save_profile()
Exemplo n.º 2
0
    def get_iter(self, input_iter):
        """Run tests serially."""

        for test in input_iter:
            result = test.run(self._server, self._addr, self._authkey)
            yield result
            if self.stop and result.status == 'FAIL':
                break

        save_coverage()
Exemplo n.º 3
0
    def get_iter(self, input_iter):
        """Run tests serially."""

        for test in input_iter:
            result = self.run_testspec(test)
            yield result
            if self.stop and result.status == "FAIL":
                break

        save_coverage()
Exemplo n.º 4
0
    def get_iter(self, input_iter):
        """Run tests serially."""

        for tests in input_iter:
            stop = False
            for test in tests:
                if self.pre_announce:
                    print("    about to run %s" % test.short_name())
                result = test.run(self._queue)
                yield result
                if self.stop:
                    if (result.status == 'FAIL' and not result.expected_fail) or (
                                  result.status == 'OK' and result.expected_fail):
                          stop = True
                          break
            if stop:
                break

        save_coverage()
Exemplo n.º 5
0
    def get_iter(self, input_iter):
        """Run tests serially."""

        for tests in input_iter:
            stop = False
            for test in tests:
                if self.pre_announce:
                    print("    about to run %s" % test.short_name())
                    sys.stdout.flush()
                result = test.run(self._queue)
                yield result
                if self.stop:
                    if (result.status == 'FAIL' and not result.expected_fail
                        ) or (result.status == 'OK' and result.expected_fail):
                        stop = True
                        break
            if stop:
                break

        save_coverage()
Exemplo n.º 6
0
def worker(runner, test_queue, done_queue, worker_id):
    """This is used by concurrent test processes. It takes a test
    off of the test_queue, runs it, then puts the TestResult object
    on the done_queue.
    """

    # need a unique profile output file for each worker process
    testflo.profile._prof_file = "profile_%s.out" % worker_id

    test_count = 0
    for testspec in iter(test_queue.get, "STOP"):
        try:
            test_count += 1
            done_queue.put(runner.run_testspec(testspec))
        except:
            # we generally shouldn't get here, but just in case,
            # handle it so that the main process doesn't hang at the
            # end when it tries to join all of the concurrent processes.
            done_queue.put(TestResult(testspec, 0.0, 0.0, "FAIL", traceback.format_exc()))

    # don't save anything unless we actually ran a test
    if test_count > 0:
        save_coverage()
        save_profile()
Exemplo n.º 7
0
def worker(test_queue, done_queue, subproc_queue, worker_id):
    """This is used by concurrent test processes. It takes a test
    off of the test_queue, runs it, then puts the Test object
    on the done_queue.
    """
    test_count = 0
    for tests in iter(test_queue.get, 'STOP'):

        done_tests = []
        for test in tests:
            try:
                test_count += 1
                done_tests.append(test.run(subproc_queue))
            except:
                # we generally shouldn't get here, but just in case,
                # handle it so that the main process doesn't hang at the
                # end when it tries to join all of the concurrent processes.
                done_tests.append(test)

        done_queue.put(done_tests)

    # don't save anything unless we actually ran a test
    if test_count > 0:
        save_coverage()
Exemplo n.º 8
0
def worker(test_queue, done_queue, subproc_queue, worker_id):
    """This is used by concurrent test processes. It takes a test
    off of the test_queue, runs it, then puts the Test object
    on the done_queue.
    """
    test_count = 0
    for tests in iter(test_queue.get, 'STOP'):

        done_tests = []
        for test in tests:
            try:
                test_count += 1
                done_tests.append(test.run(subproc_queue))
            except:
                # we generally shouldn't get here, but just in case,
                # handle it so that the main process doesn't hang at the
                # end when it tries to join all of the concurrent processes.
                done_tests.append(test)

        done_queue.put(done_tests)

    # don't save anything unless we actually ran a test
    if test_count > 0:
        save_coverage()
Exemplo n.º 9
0
                # test already failed during discovery, probably an
                # import failure
                yield testspec
            else:
                yield run_isolated(testspec, self.args)


if __name__ == '__main__':

    exitcode = 0

    try:
        options = _get_parser().parse_args()
        runner = TestRunner(options)
        for result in runner.get_iter([options.tests[0]]):
            break
        if result.status != 'OK':
            sys.stderr.write(result.err_msg)
            exitcode = exit_codes[result.status]

        save_coverage()

    except:
        sys.stderr.write(traceback.format_exc())
        exitcode = exit_codes['FAIL']

    finally:
        sys.stdout.flush()
        sys.stderr.flush()
        sys.exit(exitcode)
Exemplo n.º 10
0
        # collect results
        results = comm.gather(test, root=0)
        if comm.rank == 0:
            if not all([isinstance(r, Test) for r in results]):
                print("\nNot all results gathered are Test objects.  "
                      "You may have out-of-sync collective MPI calls.\n")
            total_mem_usage = sum(r.memory_usage for r in results
                                  if isinstance(r, Test))
            test.memory_usage = total_mem_usage

            # check for errors and record error message
            for r in results:
                if test.status != 'FAIL' and r.status in ('SKIP', 'FAIL'):
                    test.err_msg = r.err_msg
                    test.status = r.status
                    if r.status == 'FAIL':
                        break

        save_coverage()

    except Exception:
        test.err_msg = traceback.format_exc()
        test.status = 'FAIL'

    finally:
        sys.stdout.flush()
        sys.stderr.flush()

        if comm.rank == 0:
            queue.put(test)