Example #1
0
def create_gecko_tests_directory(tests_directory, gecko_checkout_subdirectory,
                                 gecko_tests_subdirectory):
    """Create Gecko tests directory from a Gecko source checkout using links."""
    gecko_checkout_directory = os.path.join(tests_directory,
                                            gecko_checkout_subdirectory)
    if not os.path.exists(gecko_checkout_directory):
        raise Exception('Unable to find Gecko source directory %s.' %
                        gecko_checkout_directory)

    web_platform_sub_directory = 'testing%sweb-platform%s' % (os.sep, os.sep)
    for root, directories, _ in os.walk(gecko_checkout_directory):
        for directory in directories:
            if not re.match('.*tests?$', directory):
                continue

            directory_absolute_path = os.path.join(root, directory)
            sub_directory = utils.strip_from_left(
                directory_absolute_path, gecko_checkout_directory + os.sep)
            source_subdirectory = gecko_checkout_subdirectory + os.sep + sub_directory
            target_subdirectory = gecko_tests_subdirectory + os.sep + sub_directory

            if sub_directory.startswith(web_platform_sub_directory):
                # Exclude web-platform tests already included in blink layout tests.
                continue

            create_symbolic_link(tests_directory, source_subdirectory,
                                 target_subdirectory)
Example #2
0
def get_component_source_and_relative_path(path, revisions_dict):
    """Get component source and relative path given a revisions dictionary and
  path."""
    if not revisions_dict:
        return ComponentPath()

    normalized_path = normalize_source_path(path)
    if normalized_path is None:
        return ComponentPath()

    component_sources = sorted(list(revisions_dict.keys()),
                               key=len,
                               reverse=True)
    default_component_source = None
    for component_source in component_sources:
        # Trailing slash is important so that we match the exact component source.
        # E.g. without slash, we would match src/webrtc_overrides with src/webrtc
        # which is incorrect.
        stripped_component_source = (
            SOURCE_STRIP_REGEX.sub('', component_source) + '/')

        if normalized_path.startswith(stripped_component_source):
            relative_path = utils.strip_from_left(normalized_path,
                                                  stripped_component_source)
            return ComponentPath(component_source, relative_path,
                                 normalized_path)

        if stripped_component_source == '/':
            default_component_source = component_source

    if default_component_source is None:
        return ComponentPath()

    return ComponentPath(default_component_source, normalized_path,
                         normalized_path)
Example #3
0
def get_kernel_stack_frame_link(stack_frame, kernel_prefix, kernel_hash):
    """Add source links data to kernel stack frames."""
    match = LLVM_SYMBOLIZER_STACK_FRAME_PATH_LINE_REGEX.search(stack_frame)
    if not match:
        # If this stack frame does not contain a path and line, bail out.
        return stack_frame

    path = _get_clean_kernel_path(match.group(1))
    line = match.group(3)
    kernel_prefix = utils.strip_from_left(kernel_prefix, 'kernel/private/')
    display_path = f'{kernel_prefix}/{path}:{line}'

    # If we have a column number, lets add it to the display path.
    if match.group(4):
        display_path += match.group(4)

    kernel_url_info = (r'http://go/pakernel/{prefix}/+/{hash}/{path}#{line};'
                       r'{display_path};').format(prefix=kernel_prefix,
                                                  hash=kernel_hash,
                                                  path=path,
                                                  line=line,
                                                  display_path=display_path)

    link_added_stack_frame = LLVM_SYMBOLIZER_STACK_FRAME_PATH_LINE_REGEX.sub(
        kernel_url_info, stack_frame)

    return link_added_stack_frame
Example #4
0
def get_bucket_name_and_path(cloud_storage_file_path):
  """Return bucket name and path given a full cloud storage path."""
  filtered_path = utils.strip_from_left(cloud_storage_file_path, GS_PREFIX)
  _, bucket_name_and_path = filtered_path.split('/', 1)

  if '/' in bucket_name_and_path:
    bucket_name, path = bucket_name_and_path.split('/', 1)
  else:
    bucket_name = bucket_name_and_path
    path = ''

  return bucket_name, path
Example #5
0
def get_kernel_stack_frame_link(stack_frame, kernel_prefix, kernel_hash):
    """Add source links data to kernel stack frames."""
    match = source_mapper.STACK_FRAME_PATH_LINE_REGEX.search(stack_frame)
    if not match:
        # If this stack frame does not contain a path and line, bail out.
        return stack_frame

    path = match.group(1)
    line = match.group(3)
    kernel_prefix = utils.strip_from_left(kernel_prefix, 'kernel/private/')
    display_path = '/'.join([kernel_prefix, path])
    kernel_url_info = (r'http://go/pakernel/{prefix}/+/{hash}/{path}#{line};'
                       r'{display_path};').format(prefix=kernel_prefix,
                                                  hash=kernel_hash,
                                                  path=path,
                                                  line=line,
                                                  display_path=display_path)

    link_added_stack_frame = source_mapper.STACK_FRAME_PATH_LINE_REGEX.sub(
        kernel_url_info, stack_frame)

    return link_added_stack_frame