Пример #1
0
    def __init__(
        self,
        *,
        rules: Optional[Iterable] = None,
        target_types: Optional[Iterable[Type[Target]]] = None,
        objects: Optional[Dict[str, Any]] = None,
        context_aware_object_factories: Optional[Dict[str, Any]] = None,
    ) -> None:
        self.build_root = os.path.realpath(mkdtemp(suffix="_BUILD_ROOT"))
        safe_mkdir(self.build_root, clean=True)
        safe_mkdir(self.pants_workdir)
        BuildRoot().path = self.build_root

        # TODO: Redesign rule registration for tests to be more ergonomic and to make this less
        #  special-cased.
        all_rules = (
            *(rules or ()),
            *source_root.rules(),
            *pants_environment.rules(),
            QueryRule(WrappedTarget, (Address,)),
        )
        build_config_builder = BuildConfiguration.Builder()
        build_config_builder.register_aliases(
            BuildFileAliases(
                objects=objects, context_aware_object_factories=context_aware_object_factories
            )
        )
        build_config_builder.register_rules(all_rules)
        build_config_builder.register_target_types(target_types or ())
        self.build_config = build_config_builder.create()

        options_bootstrapper = create_options_bootstrapper()
        global_options = options_bootstrapper.bootstrap_options.for_global_scope()
        local_store_dir = global_options.local_store_dir
        local_execution_root_dir = global_options.local_execution_root_dir
        named_caches_dir = global_options.named_caches_dir

        graph_session = EngineInitializer.setup_graph_extended(
            pants_ignore_patterns=[],
            use_gitignore=False,
            local_store_dir=local_store_dir,
            local_execution_root_dir=local_execution_root_dir,
            named_caches_dir=named_caches_dir,
            native=Native(),
            options_bootstrapper=options_bootstrapper,
            build_root=self.build_root,
            build_configuration=self.build_config,
            execution_options=ExecutionOptions.from_bootstrap_options(global_options),
        ).new_session(
            build_id="buildid_for_test",
            session_values=SessionValues(
                {OptionsBootstrapper: options_bootstrapper, PantsEnvironment: PantsEnvironment()}
            ),
            should_report_workunits=True,
        )
        self.scheduler = graph_session.scheduler_session
Пример #2
0
def load_backends_and_plugins(
    plugins: List[str],
    working_set: WorkingSet,
    backends: List[str],
    bc_builder: Optional[BuildConfiguration.Builder] = None,
) -> BuildConfiguration:
    """Load named plugins and source backends.

    :param plugins: v2 plugins to load.
    :param working_set: A pkg_resources.WorkingSet to load plugins from.
    :param backends: v2 backends to load.
    :param bc_builder: The BuildConfiguration (for adding aliases).
    """
    bc_builder = bc_builder or BuildConfiguration.Builder()
    load_build_configuration_from_source(bc_builder, backends)
    load_plugins(bc_builder, plugins, working_set)
    return bc_builder.create()
Пример #3
0
def create_bootstrap_scheduler(
        options_bootstrapper: OptionsBootstrapper,
        executor: PyExecutor | None = None) -> BootstrapScheduler:
    bc_builder = BuildConfiguration.Builder()
    # To load plugins, we only need access to the Python/PEX rules.
    load_build_configuration_from_source(bc_builder, ["pants.backend.python"])
    # And to plugin-loading-specific rules.
    bc_builder.register_rules("_dummy_for_bootstrapping_",
                              plugin_resolver_rules())
    # We allow unrecognized options to defer any option error handling until post-bootstrap.
    bc_builder.allow_unknown_options()
    return BootstrapScheduler(
        EngineInitializer.setup_graph(
            options_bootstrapper.bootstrap_options.for_global_scope(),
            bc_builder.create(),
            DynamicRemoteOptions.disabled(),
            executor,
        ).scheduler)
Пример #4
0
def create_bootstrap_scheduler(
    options_bootstrapper: OptionsBootstrapper,
    executor: Optional[PyExecutor] = None,
) -> BootstrapScheduler:
    bc_builder = BuildConfiguration.Builder()
    # To load plugins, we only need access to the Python/PEX rules.
    load_build_configuration_from_source(bc_builder, ["pants.backend.python"])
    # And to plugin-loading-specific rules.
    bc_builder.register_rules(plugin_resolver_rules())
    # We allow unrecognized options to defer any option error handling until post-bootstrap.
    bc_builder.allow_unknown_options()
    return BootstrapScheduler(
        EngineInitializer.setup_graph(
            options_bootstrapper,
            bc_builder.create(),
            executor=executor,
            # TODO: We use the default execution options to avoid invoking remote execution auth
            # plugins. They should be loaded via rules using the bootstrap Scheduler in the future.
            execution_options=DEFAULT_EXECUTION_OPTIONS,
        ).scheduler)
Пример #5
0
    def __init__(
            self,
            *,
            rules: Iterable | None = None,
            target_types: Iterable[type[Target]] | None = None,
            objects: dict[str, Any] | None = None,
            context_aware_object_factories: dict[str, Any] | None = None,
            isolated_local_store: bool = False,
            preserve_tmpdirs: bool = False,
            ca_certs_path: str | None = None,
            bootstrap_args: Iterable[str] = (),
    ) -> None:

        bootstrap_args = [*bootstrap_args]

        root_dir: Path | None = None
        if preserve_tmpdirs:
            root_dir = Path(mkdtemp(prefix="RuleRunner."))
            print(
                f"Preserving rule runner temporary directories at {root_dir}.",
                file=sys.stderr)
            bootstrap_args.extend([
                "--no-process-execution-local-cleanup",
                f"--local-execution-root-dir={root_dir}",
            ])
            build_root = (root_dir / "BUILD_ROOT").resolve()
            build_root.mkdir()
            self.build_root = str(build_root)
        else:
            self.build_root = os.path.realpath(
                safe_mkdtemp(prefix="_BUILD_ROOT"))

        safe_mkdir(self.pants_workdir)
        BuildRoot().path = self.build_root

        # TODO: Redesign rule registration for tests to be more ergonomic and to make this less
        #  special-cased.
        all_rules = (
            *(rules or ()),
            *source_root.rules(),
            QueryRule(WrappedTarget, [Address]),
            QueryRule(UnionMembership, []),
        )
        build_config_builder = BuildConfiguration.Builder()
        build_config_builder.register_aliases(
            BuildFileAliases(
                objects=objects,
                context_aware_object_factories=context_aware_object_factories))
        build_config_builder.register_rules("_dummy_for_test_", all_rules)
        build_config_builder.register_target_types("_dummy_for_test_",
                                                   target_types or ())
        self.build_config = build_config_builder.create()

        self.environment = CompleteEnvironment({})
        self.options_bootstrapper = create_options_bootstrapper(
            args=bootstrap_args)
        options = self.options_bootstrapper.full_options(self.build_config)
        global_options = self.options_bootstrapper.bootstrap_options.for_global_scope(
        )

        dynamic_remote_options, _ = DynamicRemoteOptions.from_options(
            options, self.environment)
        local_store_options = LocalStoreOptions.from_options(global_options)
        if isolated_local_store:
            if root_dir:
                lmdb_store_dir = root_dir / "lmdb_store"
                lmdb_store_dir.mkdir()
                store_dir = str(lmdb_store_dir)
            else:
                store_dir = safe_mkdtemp(prefix="lmdb_store.")
            local_store_options = dataclasses.replace(local_store_options,
                                                      store_dir=store_dir)

        local_execution_root_dir = global_options.local_execution_root_dir
        named_caches_dir = global_options.named_caches_dir

        graph_session = EngineInitializer.setup_graph_extended(
            pants_ignore_patterns=GlobalOptions.compute_pants_ignore(
                self.build_root, global_options),
            use_gitignore=False,
            local_store_options=local_store_options,
            local_execution_root_dir=local_execution_root_dir,
            named_caches_dir=named_caches_dir,
            build_root=self.build_root,
            build_configuration=self.build_config,
            executor=_EXECUTOR,
            execution_options=ExecutionOptions.from_options(
                global_options, dynamic_remote_options),
            ca_certs_path=ca_certs_path,
            engine_visualize_to=None,
        ).new_session(
            build_id="buildid_for_test",
            session_values=SessionValues({
                OptionsBootstrapper: self.options_bootstrapper,
                CompleteEnvironment: self.environment,
            }),
        )
        self.scheduler = graph_session.scheduler_session
 def setUp(self) -> None:
     self.bc_builder = BuildConfiguration.Builder()
Пример #7
0
 def build_config(cls):
     build_config = BuildConfiguration.Builder()
     build_config.register_aliases(cls.alias_groups())
     build_config.register_rules(cls.rules())
     build_config.register_target_types(cls.target_types())
     return build_config.create()
 def setUp(self):
     self.bc_builder = BuildConfiguration.Builder()
     self.working_set = WorkingSet()
     for entry in working_set.entries:
         self.working_set.add_entry(entry)
Пример #9
0
def bc_builder() -> BuildConfiguration.Builder:
    return BuildConfiguration.Builder()
Пример #10
0
    def __init__(
        self,
        *,
        rules: Iterable | None = None,
        target_types: Iterable[type[Target]] | None = None,
        objects: dict[str, Any] | None = None,
        context_aware_object_factories: dict[str, Any] | None = None,
        isolated_local_store: bool = False,
        ca_certs_path: str | None = None,
    ) -> None:
        self.build_root = os.path.realpath(mkdtemp(suffix="_BUILD_ROOT"))
        safe_mkdir(self.build_root, clean=True)
        safe_mkdir(self.pants_workdir)
        BuildRoot().path = self.build_root

        # TODO: Redesign rule registration for tests to be more ergonomic and to make this less
        #  special-cased.
        all_rules = (
            *(rules or ()),
            *source_root.rules(),
            *pants_environment.rules(),
            QueryRule(WrappedTarget, [Address]),
            QueryRule(UnionMembership, []),
        )
        build_config_builder = BuildConfiguration.Builder()
        build_config_builder.register_aliases(
            BuildFileAliases(
                objects=objects,
                context_aware_object_factories=context_aware_object_factories))
        build_config_builder.register_rules(all_rules)
        build_config_builder.register_target_types(target_types or ())
        self.build_config = build_config_builder.create()

        self.options_bootstrapper = create_options_bootstrapper()
        options = self.options_bootstrapper.full_options(self.build_config)
        global_options = self.options_bootstrapper.bootstrap_options.for_global_scope(
        )
        local_store_dir = (os.path.realpath(safe_mkdtemp())
                           if isolated_local_store else
                           global_options.local_store_dir)
        local_execution_root_dir = global_options.local_execution_root_dir
        named_caches_dir = global_options.named_caches_dir

        graph_session = EngineInitializer.setup_graph_extended(
            pants_ignore_patterns=GlobalOptions.compute_pants_ignore(
                self.build_root, global_options),
            use_gitignore=False,
            local_store_dir=local_store_dir,
            local_execution_root_dir=local_execution_root_dir,
            named_caches_dir=named_caches_dir,
            native=Native(),
            build_root=self.build_root,
            build_configuration=self.build_config,
            executor=_EXECUTOR,
            execution_options=ExecutionOptions.from_options(options),
            ca_certs_path=ca_certs_path,
            native_engine_visualize_to=None,
        ).new_session(
            build_id="buildid_for_test",
            session_values=SessionValues({
                OptionsBootstrapper: self.options_bootstrapper,
                PantsEnvironment: PantsEnvironment(),
            }),
        )
        self.scheduler = graph_session.scheduler_session
Пример #11
0
def test_get_all_help_info():
    class Global(Subsystem):
        options_scope = GLOBAL_SCOPE
        help = "Global options."

        opt1 = IntOption("-o", "--opt1", default=42, help="Option 1")

    class Foo(Subsystem):
        options_scope = "foo"
        help = "A foo."

        opt2 = BoolOption("--opt2",
                          default=True,
                          advanced=True,
                          help="Option 2")

    class Bar(GoalSubsystem):
        name = "bar"
        help = "The bar goal."
        deprecated_options_scope = "bar-old"
        deprecated_options_scope_removal_version = "9.9.999"

    class QuxField(StringField):
        alias = "qux"
        default = "blahblah"
        help = "A qux string."

    class QuuxField(IntField):
        alias = "quux"
        required = True
        help = "A quux int.\n\nMust be non-zero. Or zero. Whatever you like really."

    class BazLibrary(Target):
        alias = "baz_library"
        help = "A library of baz-es.\n\nUse it however you like."

        core_fields = [QuxField, QuuxField]

    options = Options.create(
        env={},
        config=Config.load([]),
        known_scope_infos=[
            Global.get_scope_info(),
            Foo.get_scope_info(),
            Bar.get_scope_info()
        ],
        args=["./pants"],
        bootstrap_option_values=None,
    )
    Global.register_options_on_scope(options)
    Foo.register_options_on_scope(options)
    Bar.register_options_on_scope(options)

    @rule
    def rule_info_test(foo: Foo) -> Target:
        """This rule is for testing info extraction only."""

    def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
        return ("somescope", f"used_by_{scope or 'GLOBAL_SCOPE'}")

    bc_builder = BuildConfiguration.Builder()
    bc_builder.register_subsystems("help_info_extracter_test", (Foo, Bar))
    bc_builder.register_target_types("help_info_extracter_test",
                                     (BazLibrary, ))
    bc_builder.register_rules("help_info_extracter_test",
                              collect_rules(locals()))

    all_help_info = HelpInfoExtracter.get_all_help_info(
        options,
        UnionMembership({}),
        fake_consumed_scopes_mapper,
        RegisteredTargetTypes({BazLibrary.alias: BazLibrary}),
        bc_builder.create(),
    )

    all_help_info_dict = all_help_info.asdict()
    expected_all_help_info_dict = {
        "scope_to_help_info": {
            GLOBAL_SCOPE: {
                "scope":
                GLOBAL_SCOPE,
                "description":
                "Global options.",
                "provider":
                "",
                "is_goal":
                False,
                "deprecated_scope":
                None,
                "basic": ({
                    "display_args": ("-o=<int>", "--opt1=<int>"),
                    "comma_separated_display_args": "-o=<int>, --opt1=<int>",
                    "scoped_cmd_line_args": ("-o", "--opt1"),
                    "unscoped_cmd_line_args": ("-o", "--opt1"),
                    "config_key": "opt1",
                    "env_var": "PANTS_OPT1",
                    "value_history": {
                        "ranked_values": (
                            {
                                "rank": Rank.NONE,
                                "value": None,
                                "details": None
                            },
                            {
                                "rank": Rank.HARDCODED,
                                "value": 42,
                                "details": None
                            },
                        ),
                    },
                    "typ": int,
                    "default": 42,
                    "help": "Option 1",
                    "deprecation_active": False,
                    "deprecated_message": None,
                    "removal_version": None,
                    "removal_hint": None,
                    "choices": None,
                    "comma_separated_choices": None,
                }, ),
                "advanced":
                tuple(),
                "deprecated":
                tuple(),
            },
            "foo": {
                "scope":
                "foo",
                "provider":
                "help_info_extracter_test",
                "description":
                "A foo.",
                "is_goal":
                False,
                "deprecated_scope":
                None,
                "basic": (),
                "advanced": ({
                    "display_args": ("--[no-]foo-opt2", ),
                    "comma_separated_display_args":
                    "--[no-]foo-opt2",
                    "scoped_cmd_line_args": ("--foo-opt2", "--no-foo-opt2"),
                    "unscoped_cmd_line_args": ("--opt2", "--no-opt2"),
                    "config_key":
                    "opt2",
                    "env_var":
                    "PANTS_FOO_OPT2",
                    "value_history": {
                        "ranked_values": (
                            {
                                "rank": Rank.NONE,
                                "value": None,
                                "details": None
                            },
                            {
                                "rank": Rank.HARDCODED,
                                "value": True,
                                "details": None
                            },
                        ),
                    },
                    "typ":
                    bool,
                    "default":
                    True,
                    "help":
                    "Option 2",
                    "deprecation_active":
                    False,
                    "deprecated_message":
                    None,
                    "removal_version":
                    None,
                    "removal_hint":
                    None,
                    "choices":
                    None,
                    "comma_separated_choices":
                    None,
                }, ),
                "deprecated":
                tuple(),
            },
            "bar": {
                "scope": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "is_goal": True,
                "deprecated_scope": "bar-old",
                "basic": tuple(),
                "advanced": tuple(),
                "deprecated": tuple(),
            },
            "bar-old": {
                "scope": "bar-old",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "is_goal": True,
                "deprecated_scope": "bar-old",
                "basic": tuple(),
                "advanced": tuple(),
                "deprecated": tuple(),
            },
        },
        "rule_output_type_to_rule_infos": {
            "Foo": ({
                "description": None,
                "help": "A foo.",
                "input_gets": ("Get(ScopedOptions, Scope, ..)", ),
                "input_types": (),
                "name": "construct_scope_foo",
                "output_desc": None,
                "output_type": "Foo",
                "provider": "help_info_extracter_test",
            }, ),
            "Target": ({
                "description":
                None,
                "help":
                "This rule is for testing info extraction only.",
                "input_gets": (),
                "input_types": ("Foo", ),
                "name":
                "pants.help.help_info_extracter_test.rule_info_test",
                "output_desc":
                ("A Target represents an addressable set of metadata.\n\n    Set the "
                 "`help` class property with a description, which will be used in "
                 "`./pants help`. For the\n    best rendering, use soft wrapping (e.g. "
                 "implicit string concatenation) within paragraphs, but\n    hard wrapping "
                 "(`\n`) to separate distinct paragraphs and/or lists.\n    "),
                "output_type":
                "Target",
                "provider":
                "help_info_extracter_test",
            }, ),
        },
        "name_to_goal_info": {
            "bar": {
                "name": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "consumed_scopes": ("somescope", "used_by_bar"),
                "is_implemented": True,
            },
            "bar-old": {
                "name": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "consumed_scopes": ("somescope", "used_by_bar-old"),
                "is_implemented": True,
            },
        },
        "name_to_target_type_info": {
            "baz_library": {
                "alias":
                "baz_library",
                "provider":
                "help_info_extracter_test",
                "summary":
                "A library of baz-es.",
                "description":
                "A library of baz-es.\n\nUse it however you like.",
                "fields": (
                    {
                        "alias": "qux",
                        "provider": "",
                        "default": "'blahblah'",
                        "description": "A qux string.",
                        "required": False,
                        "type_hint": "str | None",
                    },
                    {
                        "alias":
                        "quux",
                        "provider":
                        "",
                        "default":
                        None,
                        "description":
                        "A quux int.\n\nMust be non-zero. Or zero. "
                        "Whatever you like really.",
                        "required":
                        True,
                        "type_hint":
                        "int",
                    },
                ),
            }
        },
    }
    assert expected_all_help_info_dict == all_help_info_dict
Пример #12
0
def test_get_all_help_info():
    class Global(Subsystem):
        options_scope = GLOBAL_SCOPE
        help = "Global options."

        opt1 = IntOption("--opt1", default=42, help="Option 1")
        # This is special in having a short option `-l`. Make sure it works.
        level = LogLevelOption()

    class Foo(Subsystem):
        options_scope = "foo"
        help = "A foo."

        opt2 = BoolOption("--opt2",
                          default=True,
                          advanced=True,
                          help="Option 2")

    class Bar(GoalSubsystem):
        name = "bar"
        help = "The bar goal."
        deprecated_options_scope = "bar-old"
        deprecated_options_scope_removal_version = "9.9.999"

    class QuxField(StringField):
        alias = "qux"
        default = "blahblah"
        help = "A qux string."

    class QuuxField(IntField):
        alias = "quux"
        required = True
        help = "A quux int.\n\nMust be non-zero. Or zero. Whatever you like really."

    class BazLibrary(Target):
        alias = "baz_library"
        help = "A library of baz-es.\n\nUse it however you like."

        core_fields = [QuxField, QuuxField]

    options = Options.create(
        env={},
        config=Config.load([]),
        known_scope_infos=[
            Global.get_scope_info(),
            Foo.get_scope_info(),
            Bar.get_scope_info()
        ],
        args=["./pants"],
        bootstrap_option_values=None,
    )
    Global.register_options_on_scope(options)
    Foo.register_options_on_scope(options)
    Bar.register_options_on_scope(options)

    @rule
    def rule_info_test(foo: Foo) -> Target:
        """This rule is for testing info extraction only."""

    def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
        return ("somescope", f"used_by_{scope or 'GLOBAL_SCOPE'}")

    bc_builder = BuildConfiguration.Builder()
    bc_builder.register_subsystems("help_info_extracter_test", (Foo, Bar))
    bc_builder.register_target_types("help_info_extracter_test",
                                     (BazLibrary, ))
    bc_builder.register_rules("help_info_extracter_test",
                              collect_rules(locals()))

    all_help_info = HelpInfoExtracter.get_all_help_info(
        options,
        UnionMembership({}),
        fake_consumed_scopes_mapper,
        RegisteredTargetTypes({BazLibrary.alias: BazLibrary}),
        bc_builder.create(),
    )

    all_help_info_dict = all_help_info.asdict()
    expected_all_help_info_dict = {
        "scope_to_help_info": {
            GLOBAL_SCOPE: {
                "scope":
                GLOBAL_SCOPE,
                "description":
                "Global options.",
                "provider":
                "",
                "is_goal":
                False,
                "deprecated_scope":
                None,
                "basic": (
                    {
                        "display_args": ("--opt1=<int>", ),
                        "comma_separated_display_args": "--opt1=<int>",
                        "scoped_cmd_line_args": ("--opt1", ),
                        "unscoped_cmd_line_args": ("--opt1", ),
                        "config_key": "opt1",
                        "env_var": "PANTS_OPT1",
                        "value_history": {
                            "ranked_values": (
                                {
                                    "rank": Rank.NONE,
                                    "value": None,
                                    "details": None
                                },
                                {
                                    "rank": Rank.HARDCODED,
                                    "value": 42,
                                    "details": None
                                },
                            ),
                        },
                        "typ": int,
                        "default": 42,
                        "help": "Option 1",
                        "deprecation_active": False,
                        "deprecated_message": None,
                        "removal_version": None,
                        "removal_hint": None,
                        "choices": None,
                        "comma_separated_choices": None,
                    },
                    {
                        "display_args":
                        ("-l=<LogLevel>", "--level=<LogLevel>"),
                        "comma_separated_display_args":
                        "-l=<LogLevel>, --level=<LogLevel>",
                        "scoped_cmd_line_args": ("-l", "--level"),
                        "unscoped_cmd_line_args": ("-l", "--level"),
                        "config_key":
                        "level",
                        "env_var":
                        "PANTS_LEVEL",
                        "value_history": {
                            "ranked_values": (
                                {
                                    "rank": Rank.NONE,
                                    "value": None,
                                    "details": None
                                },
                                {
                                    "rank": Rank.HARDCODED,
                                    "value": LogLevel.INFO,
                                    "details": None
                                },
                            ),
                        },
                        "typ":
                        LogLevel,
                        "default":
                        LogLevel.INFO,
                        "help":
                        "Set the logging level.",
                        "deprecation_active":
                        False,
                        "deprecated_message":
                        None,
                        "removal_version":
                        None,
                        "removal_hint":
                        None,
                        "choices": ("trace", "debug", "info", "warn", "error"),
                        "comma_separated_choices":
                        "trace, debug, info, warn, error",
                    },
                ),
                "advanced":
                tuple(),
                "deprecated":
                tuple(),
            },
            "foo": {
                "scope":
                "foo",
                "provider":
                "help_info_extracter_test",
                "description":
                "A foo.",
                "is_goal":
                False,
                "deprecated_scope":
                None,
                "basic": (),
                "advanced": ({
                    "display_args": ("--[no-]foo-opt2", ),
                    "comma_separated_display_args":
                    "--[no-]foo-opt2",
                    "scoped_cmd_line_args": ("--foo-opt2", "--no-foo-opt2"),
                    "unscoped_cmd_line_args": ("--opt2", "--no-opt2"),
                    "config_key":
                    "opt2",
                    "env_var":
                    "PANTS_FOO_OPT2",
                    "value_history": {
                        "ranked_values": (
                            {
                                "rank": Rank.NONE,
                                "value": None,
                                "details": None
                            },
                            {
                                "rank": Rank.HARDCODED,
                                "value": True,
                                "details": None
                            },
                        ),
                    },
                    "typ":
                    bool,
                    "default":
                    True,
                    "help":
                    "Option 2",
                    "deprecation_active":
                    False,
                    "deprecated_message":
                    None,
                    "removal_version":
                    None,
                    "removal_hint":
                    None,
                    "choices":
                    None,
                    "comma_separated_choices":
                    None,
                }, ),
                "deprecated":
                tuple(),
            },
            "bar": {
                "scope": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "is_goal": True,
                "deprecated_scope": "bar-old",
                "basic": tuple(),
                "advanced": tuple(),
                "deprecated": tuple(),
            },
            "bar-old": {
                "scope": "bar-old",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "is_goal": True,
                "deprecated_scope": "bar-old",
                "basic": tuple(),
                "advanced": tuple(),
                "deprecated": tuple(),
            },
        },
        "name_to_goal_info": {
            "bar": {
                "name": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "consumed_scopes": ("somescope", "used_by_bar"),
                "is_implemented": True,
            },
            "bar-old": {
                "name": "bar",
                "provider": "help_info_extracter_test",
                "description": "The bar goal.",
                "consumed_scopes": ("somescope", "used_by_bar-old"),
                "is_implemented": True,
            },
        },
        "name_to_target_type_info": {
            "baz_library": {
                "alias":
                "baz_library",
                "provider":
                "help_info_extracter_test",
                "summary":
                "A library of baz-es.",
                "description":
                "A library of baz-es.\n\nUse it however you like.",
                "fields": (
                    {
                        "alias": "qux",
                        "provider": "",
                        "default": "'blahblah'",
                        "description": "A qux string.",
                        "required": False,
                        "type_hint": "str | None",
                    },
                    {
                        "alias":
                        "quux",
                        "provider":
                        "",
                        "default":
                        None,
                        "description":
                        "A quux int.\n\nMust be non-zero. Or zero. "
                        "Whatever you like really.",
                        "required":
                        True,
                        "type_hint":
                        "int",
                    },
                ),
            }
        },
        "name_to_rule_info": {
            "construct_scope_foo": {
                "description": None,
                "documentation": "A foo.",
                "input_gets": ("Get(ScopedOptions, Scope, ..)", ),
                "input_types": (),
                "name": "construct_scope_foo",
                "output_type": "Foo",
                "provider": "help_info_extracter_test",
            },
            "pants.help.help_info_extracter_test.test_get_all_help_info.rule_info_test":
            {
                "description": None,
                "documentation":
                "This rule is for testing info extraction only.",
                "input_gets": (),
                "input_types": ("Foo", ),
                "name":
                "pants.help.help_info_extracter_test.test_get_all_help_info.rule_info_test",
                "output_type": "Target",
                "provider": "help_info_extracter_test",
            },
        },
        "name_to_api_type_info": {
            "pants.help.help_info_extracter_test.Foo": {
                "consumed_by_rules":
                ("pants.help.help_info_extracter_test.test_get_all_help_info.rule_info_test",
                 ),
                "dependees": ("help_info_extracter_test", ),
                "dependencies": ("pants.option.scope", ),
                "documentation":
                None,
                "is_union":
                False,
                "module":
                "pants.help.help_info_extracter_test",
                "name":
                "Foo",
                "provider":
                "help_info_extracter_test",
                "returned_by_rules": ("construct_scope_foo", ),
                "union_members": (),
                "union_type":
                None,
                "used_in_rules": (),
            },
            "pants.engine.target.Target": {
                "consumed_by_rules": (),
                "dependees": (),
                "dependencies": (),
                "documentation":
                ("A Target represents an addressable set of metadata.\n\n    Set the `help` "
                 "class property with a description, which will be used in `./pants help`. For "
                 "the\n    best rendering, use soft wrapping (e.g. implicit string concatenation"
                 ") within paragraphs, but\n    hard wrapping (`\n`) to separate distinct "
                 "paragraphs and/or lists.\n    "),
                "is_union":
                False,
                "module":
                "pants.engine.target",
                "name":
                "Target",
                "provider":
                "help_info_extracter_test",
                "returned_by_rules":
                ("pants.help.help_info_extracter_test.test_get_all_help_info.rule_info_test",
                 ),
                "union_members": (),
                "union_type":
                None,
                "used_in_rules": (),
            },
            "pants.option.scope.Scope": {
                "consumed_by_rules": (),
                "dependees": (),
                "dependencies": (),
                "documentation": "An options scope.",
                "is_union": False,
                "module": "pants.option.scope",
                "name": "Scope",
                "provider": "pants.option.scope",
                "returned_by_rules": (),
                "union_members": (),
                "union_type": None,
                "used_in_rules": ("construct_scope_foo", ),
            },
        },
    }

    # Break down this colossal structure into pieces so it is easier to spot where the issue is.
    # Check keys equality first, then contents
    assert set(expected_all_help_info_dict) == set(all_help_info_dict)
    for key in all_help_info_dict:
        actual = all_help_info_dict[key]
        expected = expected_all_help_info_dict[key]
        assert expected == actual