def main_run(args):
  typ_path = os.path.abspath(os.path.join(
      os.path.dirname(__file__), os.path.pardir, os.path.pardir,
      'third_party', 'typ'))
  _AddToPathIfNeeded(typ_path)
  import typ

  top_level_dir = os.path.join(
      common.SRC_DIR, 'headless', 'lib', 'browser', 'devtools_api')
  with common.temporary_file() as tempfile_path:
    rc = typ.main(
        argv=[],
        top_level_dir=top_level_dir,
        write_full_results_to=tempfile_path,
        coverage_source=[top_level_dir])

    with open(tempfile_path) as f:
      results = json.load(f)

  parsed_results = common.parse_common_test_results(results, test_separator='.')
  failures = parsed_results['unexpected_failures']

  json.dump({
      'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
                   ((rc == 0) or failures)),
      'failures': failures.keys(),
  }, args.output)

  return rc
示例#2
0
def main_run(args):
    typ_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
                     'third_party', 'catapult', 'third_party', 'typ'))
    _AddToPathIfNeeded(typ_path)
    import typ

    top_level_dir = os.path.join(common.SRC_DIR, 'headless', 'lib', 'browser',
                                 'devtools_api')
    with common.temporary_file() as tempfile_path:
        rc = typ.main(argv=[],
                      top_level_dir=top_level_dir,
                      write_full_results_to=tempfile_path,
                      coverage_source=[top_level_dir])

        with open(tempfile_path) as f:
            results = json.load(f)

    parsed_results = common.parse_common_test_results(results,
                                                      test_separator='.')
    failures = parsed_results['unexpected_failures']

    json.dump(
        {
            'valid':
            bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
                 ((rc == 0) or failures)),
            'failures':
            failures.keys(),
        }, args.output)

    return rc
示例#3
0
def Run(top_level_dir, path=None):
  """Runs a set of Python tests using typ.

  Args:
    top_level_dir: Directory to look for Python unit tests in.
    path: A list of extra paths to add to sys.path when running the tests.

  Returns:
    An exit code (0 for success, otherwise non-zero).
  """
  typ_path = os.path.abspath(os.path.join(
      os.path.dirname(__file__), os.path.pardir, 'third_party', 'typ'))
  _AddToPathIfNeeded(typ_path)
  import typ
  return typ.main(
      top_level_dir=top_level_dir,
      path=(path or []),
      coverage_source=[top_level_dir])
示例#4
0
def Run(top_level_dir, path=None):
    """Runs a set of Python tests using typ.

  Args:
    top_level_dir: Directory to look for Python unit tests in.
    path: A list of extra paths to add to sys.path when running the tests.

  Returns:
    An exit code (0 for success, otherwise non-zero).
  """
    typ_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir, 'third_party',
                     'typ'))
    _AddToPathIfNeeded(typ_path)
    import typ
    return typ.main(top_level_dir=top_level_dir,
                    path=(path or []),
                    coverage_source=[top_level_dir])
示例#5
0
    def call(self, host, argv, stdin, env):
        stdin = unicode(stdin)
        host.stdin = io.StringIO(stdin)
        if env:
            host.getenv = env.get
        host.capture_output()
        orig_sys_path = sys.path[:]
        orig_sys_modules = list(sys.modules.keys())

        try:
            ret = main(argv + ['-j', '1'], host)
        finally:
            out, err = host.restore_output()
            modules_to_unload = []
            for k in sys.modules:
                if k not in orig_sys_modules:
                    modules_to_unload.append(k)
            for k in modules_to_unload:
                del sys.modules[k]
            sys.path = orig_sys_path

        return ret, out, err
示例#6
0
    def call(self, host, argv, stdin, env):
        stdin = unicode(stdin)
        host.stdin = io.StringIO(stdin)
        if env:
            host.getenv = env.get
        host.capture_output()
        orig_sys_path = sys.path[:]
        orig_sys_modules = list(sys.modules.keys())

        try:
            ret = main(argv + ['-j', '1'], host)
        finally:
            out, err = host.restore_output()
            modules_to_unload = []
            for k in sys.modules:
                if k not in orig_sys_modules:
                    modules_to_unload.append(k)
            for k in modules_to_unload:
                del sys.modules[k]
            sys.path = orig_sys_path

        return ret, out, err
sys.exit(
    typ.main(
        tests=resolve(
            'actions/extract_actions_test.py',

            # TODO(crbug.com/1220251) - the test ordering is very sensitive due to
            # potential name collisions between ukm/pretty_print.py and
            # histograms/pretty_print.py and the implementation in typ.
            #
            # Until this issue is fixed, best to ensure that the 'histograms' files
            # show up *after* the 'ukm' files (in order for the histograms
            # directory to be added to sys.path *before* ukm), and that we run the
            # tests in a single process (jobs=1, below).
            'ukm/codegen_test.py',
            'ukm/gen_builders_test.py',
            'ukm/ukm_model_test.py',
            'ukm/xml_validations_test.py',
            'histograms/expand_owners_unittest.py',
            'histograms/extract_histograms_test.py',
            'histograms/generate_expired_histograms_array_unittest.py',
            'histograms/pretty_print_test.py',
            '../json_comment_eater/json_comment_eater_test.py',
            '../json_to_struct/element_generator_test.py',
            '../json_to_struct/struct_generator_test.py',
            '../variations/fieldtrial_to_struct_unittest.py',
            '../variations/fieldtrial_util_unittest.py',
            '../variations/split_variations_cmd_unittest.py',
            '../../components/variations/service/'
            'generate_ui_string_overrider_unittest.py',
        ),
        jobs=1))
示例#8
0
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys  # pragma: no cover

from typ import main  # pragma: no cover


if __name__ == "__main__":  # pragma: no cover
    sys.exit(main())
# found in the LICENSE file.

import os
import sys

THIS_DIR = os.path.abspath(os.path.dirname(__file__))
SRC_DIR = os.path.dirname(os.path.dirname(THIS_DIR))
TYP_DIR = os.path.join(SRC_DIR, 'third_party', 'typ')

if not TYP_DIR in sys.path:
    sys.path.insert(0, TYP_DIR)

import typ


def resolve(*paths):
    return [os.path.join(THIS_DIR, *(p.split('/'))) for p in paths]

sys.exit(typ.main(tests=resolve(
   'actions/extract_actions_test.py',
   'histograms/generate_expired_histograms_array_unittest.py',
   'ukm/pretty_print_test.py',
   "../json_comment_eater/json_comment_eater_test.py",
   "../json_to_struct/element_generator_test.py",
   "../json_to_struct/struct_generator_test.py",
   '../variations/fieldtrial_to_struct_unittest.py',
   '../variations/fieldtrial_util_unittest.py',
   '../../components/variations/service/'
       'generate_ui_string_overrider_unittest.py',
   )))
示例#10
0
 typ.main(tests=resolve(
     'api_categorizer_test.py',
     'api_data_source_test.py',
     'api_list_data_source_test.py',
     'api_models_test.py',
     'api_schema_graph_test.py',
     'app_yaml_helper_test.py',
     'availability_finder_test.py',
     'branch_utility_test.py',
     'cache_chain_object_store_test.py',
     'caching_file_system_test.py',
     'caching_rietveld_patcher_test.py',
     'chained_compiled_file_system_test.py',
     'chroot_file_system_test.py',
     'compiled_file_system_test.py',
     'content_provider_test.py',
     'content_providers_test.py',
     'directory_zipper_test.py',
     'docs_server_utils_test.py',
     'document_parser_test.py',
     'document_renderer_test.py',
     'environment_test.py',
     'features_bundle_test.py',
     'file_system_test.py',
     'future_test.py',
     'handler_test.py',
     'host_file_system_iterator_test.py',
     'host_file_system_provider_test.py',
     'instance_servlet_test.py',
     'integration_test.py',
     'jsc_view_test.py',
     'link_error_detector_test.py',
     'local_file_system_test.py',
     'manifest_data_source_test.py',
     'manifest_features_test.py',
     'mock_file_system_test.py',
     'mock_function_test.py',
     'object_store_creator_test.py',
     'owners_data_source_test.py',
     'patch_servlet_test.py',
     'patched_file_system_test.py',
     'path_canonicalizer_test.py',
     'path_util_test.py',
     'permissions_data_source_test.py',
     'persistent_object_store_test.py',
     'platform_bundle_test.py',
     'platform_util_test.py',
     'redirector_test.py',
     'reference_resolver_test.py',
     'rietveld_patcher_test.py',
     'samples_model_test.py',
     'schema_processor_test.py',
     'sidenav_data_source_test.py',
     'template_data_source_test.py',
     'template_renderer_test.py',
     'test_file_system_test.py',
     'test_object_store_test.py',
     'test_servlet_test.py',
     'whats_new_data_source_test.py',
     # 'render_servlet_test.py', (This has a test failure currently).
 )))
示例#11
0
def main():
    return typ.main(path=[path_finder.get_integration_tests_dir()], )
示例#12
0
if not TYP_DIR in sys.path:
  sys.path.insert(0, TYP_DIR)

import typ


def resolve(*paths):
  return [os.path.join(THIS_DIR, *(p.split('/'))) for p in paths]


sys.exit(
    typ.main(tests=resolve(
        'actions/extract_actions_test.py',
        'histograms/extract_histograms_test.py',
        'histograms/generate_expired_histograms_array_unittest.py',
        'histograms/pretty_print_test.py',
        'rappor/rappor_model_test.py',
        'ukm/codegen_test.py',
        'ukm/gen_builders_test.py',
        'ukm/ukm_model_test.py',
        'ukm/xml_validations_test.py',
        '../json_comment_eater/json_comment_eater_test.py',
        '../json_to_struct/element_generator_test.py',
        '../json_to_struct/struct_generator_test.py',
        '../variations/fieldtrial_to_struct_unittest.py',
        '../variations/fieldtrial_util_unittest.py',
        '../variations/split_variations_cmd_unittest.py',
        '../../components/variations/service/'
        'generate_ui_string_overrider_unittest.py',
    )))
示例#13
0
def main():
    return typ.main(top_level_dirs=[
        path_finder.get_blink_tools_dir(),
        os.path.join(path_finder.get_source_dir(), 'build', 'scripts')
    ],
                    path=[path_finder.get_blinkpy_thirdparty_dir()])
示例#14
0
def main(args):
    return typ.main(top_level_dirs=[os.path.join(CUR_DIR, '..')],
                    skip=['grit.pseudo_unittest.*'])
def main(args):
  os.chdir(CUR_DIR)
  return typ.main(top_level_dirs=[CUR_DIR])
示例#16
0
#!/usr/bin/env vpython
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys

THIS_DIR = os.path.abspath(os.path.dirname(__file__))
SRC_DIR = os.path.abspath(os.path.join(THIS_DIR, *((os.pardir, ) * 4)))
TYP_DIR = os.path.join(SRC_DIR, 'third_party', 'catapult', 'third_party',
                       'typ')

if not TYP_DIR in sys.path:
    sys.path.insert(0, TYP_DIR)

import typ

sys.exit(
    typ.main(top_level_dir=os.path.dirname(THIS_DIR), suffixes=['*_test.py']))
def Main():
    return typ.main(top_level_dir=_MOJOM_DIR)
示例#18
0
def main(args):
    return typ.main(top_level_dirs=[os.path.join(CUR_DIR, '..')],
                    skip=[
                        'grit.format.gen_predetermined_ids_unittest.*',
                        'grit.pseudo_unittest.*'
                    ])
示例#19
0
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys  # pragma: no cover

from typ import main  # pragma: no cover

if __name__ == '__main__':  # pragma: no cover
    sys.exit(main())