Example #1
0
def rule_runner() -> RuleRunner:
    rule_runner = RuleRunner(
        rules=[
            *config_files.rules(),
            *coursier_fetch_rules(),
            *coursier_setup_rules(),
            *external_tool_rules(),
            *import_parser_rules(),
            *java_parser_launcher_rules(),
            *java_parser_rules(),
            *java_target_rules(),
            *java_util_rules(),
            *javac_rules(),
            *process_rules(),
            *source_files.rules(),
            *util_rules(),
            QueryRule(ParsedJavaImports, [ParseJavaImportsRequest]),
            QueryRule(Targets, [UnparsedAddressInputs]),
        ],
        target_types=[JavaSourcesGeneratorTarget],
        bootstrap_args=[
            NAMED_RESOLVE_OPTIONS,
        ],
    )
    rule_runner.set_options(args=[], env_inherit=PYTHON_BOOTSTRAP_ENV)
    return rule_runner
Example #2
0
def rule_runner() -> RuleRunner:
    return RuleRunner(
        rules=[
            *config_files.rules(),
            *source_files.rules(),
            *coursier_setup_rules(),
            *coursier_fetch_rules(),
            *external_tool_rules(),
            *util_rules(),
            *java_util_rules(),
            *process_rules(),
            QueryRule(BashBinary, ()),
            QueryRule(JdkSetup, ()),
            QueryRule(ProcessResult, (Process,)),
        ],
    )
Example #3
0
def rule_runner() -> RuleRunner:
    rule_runner = RuleRunner(rules=[
        *config_files.rules(),
        *source_files.rules(),
        *coursier_setup_rules(),
        *coursier_fetch_rules(),
        *external_tool_rules(),
        *util_rules(),
        *jdk_rules(),
        *process_rules(),
        QueryRule(BashBinary, ()),
        QueryRule(JdkSetup, ()),
        QueryRule(ProcessResult, (Process, )),
    ], )
    rule_runner.set_options(args=[], env_inherit=PYTHON_BOOTSTRAP_ENV)
    return rule_runner
Example #4
0
    def test_counters(self) -> None:
        @dataclass(frozen=True)
        class TrueResult:
            pass

        @rule(desc="a_rule")
        async def a_rule() -> TrueResult:
            proc = Process(
                ["/bin/sh", "-c", "true"],
                description="always true",
            )
            _ = await Get(ProcessResult, MultiPlatformProcess({None: proc}))
            return TrueResult()

        scheduler, tracker, handler = self._fixture_for_rules(
            [
                a_rule,
                QueryRule(TrueResult, tuple()), *process_rules(),
                *platform_rules()
            ],
            max_workunit_verbosity=LogLevel.TRACE,
        )

        with handler.session():
            scheduler.record_test_observation(128)
            scheduler.product_request(TrueResult, subjects=[0])
            histograms_info = scheduler.get_observation_histograms()

        finished = list(
            itertools.chain.from_iterable(tracker.finished_workunit_chunks))
        workunits_with_counters = [
            item for item in finished if "counters" in item
        ]
        assert workunits_with_counters[0]["counters"][
            "local_execution_requests"] == 1
        assert workunits_with_counters[1]["counters"][
            "local_cache_requests"] == 1
        assert workunits_with_counters[1]["counters"][
            "local_cache_requests_uncached"] == 1

        assert histograms_info["version"] == 0
        assert "histograms" in histograms_info
        assert "test_observation" in histograms_info["histograms"]
        assert (
            histograms_info["histograms"]["test_observation"] ==
            b"\x1c\x84\x93\x14\x00\x00\x00\x1fx\x9c\x93i\x99,\xcc\xc0\xc0\xc0\xcc\x00\x010\x9a\x11J3\xd9\x7f\x800\xfe32\x01\x00E\x0c\x03\x81"
        )
Example #5
0
def rule_runner() -> RuleRunner:
    return RuleRunner(
        rules=[
            *config_files.rules(),
            *coursier_fetch_rules(),
            *coursier_setup_rules(),
            *external_tool_rules(),
            *import_parser_rules(),
            *java_parser_launcher_rules(),
            *java_parser_rules(),
            *java_target_rules(),
            *java_util_rules(),
            *javac_rules(),
            *process_rules(),
            *source_files.rules(),
            *util_rules(),
            QueryRule(ParsedJavaImports, [ParseJavaImportsRequest]),
            QueryRule(Targets, [UnparsedAddressInputs]),
        ],
        target_types=[JavaSourcesGeneratorTarget],
        bootstrap_args=["--javac-jdk=system"
                        ],  # TODO(#12293): use a fixed JDK version.
    )