def METHOD_NAME(index, testfile, timeout, **kwargs):
    """Run a given test
    """
    global test_status_
    global total_
    pyExec = os.environ.get('PYTHON_EXECUTABLE', sys.executable)
    cmd = Command([pyExec, testfile])
    ti = time.time()
    name = os.path.basename(testfile)
    out = (name + '.' * 50)[:40]
    print('[TEST %3d/%d] %41s ' % (index, total_, out), end='')
    sys.stdout.flush()
    # Run the test.
    status = cmd.run(timeout=timeout, **kwargs)
    t = time.time() - ti
    print('% 7.2f s' % t, end='')
    sys.stdout.flush()
    # Change to directory and copy before running then test.
    cwd = os.path.dirname(testfile)
    os.chdir(cwd)
    with open(os.path.join(cwd, 'matplotlibrc'), 'w') as f:
        logging.debug('Writing matplotlibrc to %s' % cwd)
        f.write(matplotlibrc_)
    if status != 0:
        if status == -15:
            msg = '% 4d TIMEOUT' % status
            test_status_['TIMED-OUT'].append(testfile)
        else:
            msg = '% 4d FAILED' % status
            test_status_['FAILED'].append(testfile)
        print(msg)
    else:
        print('% 4d PASSED' % status)
        test_status_['PASSED'].append(testfile)
    sys.stdout.flush()