Beispiel #1
0
def test_format_summary_remote(rule_runner: RuleRunner) -> None:
    _assert_test_summary(
        "✓ //:dummy_address succeeded in 0.05s (ran remotely).",
        exit_code=0,
        run_id=0,
        result_metadata=ProcessResultMetadata(50, "ran_remotely", 0),
    )
Beispiel #2
0
def test_format_summary_memoized(rule_runner: RuleRunner) -> None:
    _assert_test_summary(
        "✓ //:dummy_address succeeded in 0.05s (memoized).",
        exit_code=0,
        run_id=1234,
        result_metadata=ProcessResultMetadata(50, "ran_locally", 0),
    )
Beispiel #3
0
 def test_result(self) -> TestResult:
     return TestResult(
         exit_code=self.exit_code(self.address),
         stdout="",
         stdout_digest=EMPTY_FILE_DIGEST,
         stderr="",
         stderr_digest=EMPTY_FILE_DIGEST,
         address=self.address,
         coverage_data=MockCoverageData(self.address),
         output_setting=ShowOutput.ALL,
         result_metadata=None if self.skipped(self.address) else
         ProcessResultMetadata(999, "ran_locally", 0),
     )
Beispiel #4
0
    def run_process_mock(process: Process) -> ProcessResult:
        if process_assertions:
            process_assertions(process)

        return ProcessResult(
            stdout=b"stdout",
            stdout_digest=EMPTY_FILE_DIGEST,
            stderr=b"stderr",
            stderr_digest=EMPTY_FILE_DIGEST,
            output_digest=EMPTY_DIGEST,
            platform=Platform.current,
            metadata=ProcessResultMetadata(0, "ran_locally", 0),
        )
Beispiel #5
0
def assert_streaming_output(
    *,
    exit_code: int | None,
    stdout: str = "stdout",
    stderr: str = "stderr",
    output_setting: ShowOutput = ShowOutput.ALL,
    expected_level: LogLevel,
    expected_message: str,
    result_metadata: ProcessResultMetadata = ProcessResultMetadata(
        999, "dummy", 0),
) -> None:
    result = TestResult(
        exit_code=exit_code,
        stdout=stdout,
        stdout_digest=EMPTY_FILE_DIGEST,
        stderr=stderr,
        stderr_digest=EMPTY_FILE_DIGEST,
        output_setting=output_setting,
        address=Address("demo_test"),
        result_metadata=result_metadata,
    )
    assert result.level() == expected_level
    assert result.message() == expected_message