Esempio n. 1
0
def run_tests(chrome_binary,
              chrome_features,
              test_suite_path,
              test_suite,
              jobs,
              server,
              test_file=None):
    env = os.environ.copy()
    env['CHROME_BIN'] = chrome_binary
    if chrome_features:
        env['CHROME_FEATURES'] = chrome_features

    if test_file is not None:
        env['TEST_FILE'] = test_file

    if jobs:
        env['JOBS'] = jobs

    env['SERVER'] = server
    cwd = devtools_paths.devtools_root_path()
    exec_command = [
        devtools_paths.node_path(),
        devtools_paths.mocha_path(),
        '--config',
        os.path.join(test_suite_path, '.mocharc.js'),
    ]

    exit_code = test_helpers.popen(exec_command, cwd=cwd, env=env)
    if exit_code != 0:
        return True

    return False
Esempio n. 2
0
def run_tests(chrome_binary, chrome_features, test_suite, test_suite_list_path, test_file=None):
    env = os.environ.copy()
    env['CHROME_BIN'] = chrome_binary
    env['TEST_LIST'] = test_suite_list_path
    if chrome_features:
        env['CHROME_FEATURES'] = chrome_features

    if test_file is not None:
        env['TEST_FILE'] = test_file

    cwd = devtools_paths.devtools_root_path()
    if test_suite == 'e2e':
        exec_command = [
            devtools_paths.node_path(),
            devtools_paths.mocha_path(),
            '--config',
            E2E_MOCHA_CONFIGURATION_LOCATION,
        ]
    else:
        runner_path = os.path.join(cwd, 'test', 'shared', 'runner.js')
        exec_command = [devtools_paths.node_path(), runner_path]

    exit_code = test_helpers.popen(exec_command, cwd=cwd, env=env)
    if exit_code != 0:
        return True

    return False
Esempio n. 3
0
def _CheckDevToolsRunBuildTests(input_api, output_api):
    # Check for changes in the build/tests directory, and run the tests if so.
    # We don't do this on every CL as most do not touch the rules, but if we do
    # change them we need to make sure all the tests are passing.
    original_sys_path = sys.path
    try:
        sys.path = sys.path + [
            input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts')
        ]
        import devtools_paths
    finally:
        sys.path = original_sys_path
    scripts_build_dir_path = input_api.os_path.join(
        input_api.PresubmitLocalPath(), 'scripts', 'build')
    scripts_build_affected_files = _getAffectedFiles(input_api,
                                                     [scripts_build_dir_path],
                                                     [], [])

    if len(scripts_build_affected_files) == 0:
        return []

    mocha_path = devtools_paths.mocha_path()
    build_tests_path = input_api.os_path.join(scripts_build_dir_path, 'tests',
                                              '*_test.js')

    results = [output_api.PresubmitNotifyResult('Build plugins unit tests')]
    results.extend(
        # The dot reporter is more concise which is useful to not get LOADS of
        # output when just one test fails.
        _checkWithNodeScript(input_api, output_api, mocha_path,
                             ['--reporter', 'dot', build_tests_path]))
    return results
def run_tests(chrome_binary,
              chrome_features,
              test_suite_path,
              test_suite,
              jobs,
              target,
              cwd=None,
              node_modules_path=None,
              test_patterns=None):
    env = os.environ.copy()
    env['CHROME_BIN'] = chrome_binary
    if chrome_features:
        env['CHROME_FEATURES'] = chrome_features

    if test_patterns:
        env['TEST_PATTERNS'] = ';'.join(test_patterns)

    if jobs:
        env['JOBS'] = jobs

    if target:
        env['TARGET'] = target

    if node_modules_path is not None:
        # Node requires the path to be absolute
        env['NODE_PATH'] = os.path.abspath(node_modules_path)

    if not cwd:
        cwd = devtools_paths.devtools_root_path()

    exec_command = [devtools_paths.node_path()]

    if 'DEBUG' in env:
        exec_command.append('--inspect')

    exec_command = exec_command + [
        devtools_paths.mocha_path(),
        '--config',
        os.path.join(test_suite_path, '.mocharc.js'),
    ]

    exit_code = test_helpers.popen(exec_command, cwd=cwd, env=env)
    if exit_code != 0:
        return True

    return False