mirror of
https://github.com/esphome/esphome.git
synced 2026-10-04 02:05:59 +00:00
Accept precompiled=false, keep same-file copies intact, ungate the empty-match warning
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from unittest.mock import MagicMock, patch
|
||||
@@ -188,6 +189,20 @@ def test_surplus_arguments_error(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
assert "expected 2 arguments, got 3" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_copy_same_file_keeps_the_input(tmp_path: Path) -> None:
|
||||
"""A same-file copy (dst IS src) must not unlink the input."""
|
||||
src = tmp_path / "firmware.bin"
|
||||
src.write_bytes(b"image")
|
||||
with (
|
||||
patch.object(
|
||||
build_tool.sys, "argv", ["build_tool", "copy", str(src), str(src)]
|
||||
),
|
||||
pytest.raises(shutil.SameFileError),
|
||||
):
|
||||
build_tool.main()
|
||||
assert src.read_bytes() == b"image"
|
||||
|
||||
|
||||
def test_copy_failure_leaves_no_partial_output(tmp_path: Path) -> None:
|
||||
"""A failed copy unlinks the destination; a partial firmware image must
|
||||
never be left on disk."""
|
||||
|
||||
Reference in New Issue
Block a user