Skip to content

Commit

Permalink
Merge pull request systemd#3109 from DaanDeMeyer/tests-tools
Browse files Browse the repository at this point in the history
Make tools tree available in tests
  • Loading branch information
behrmann authored Oct 7, 2024
2 parents 5d777f7 + ad135a8 commit 4005997
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mkosi/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ def preexec() -> None:
make_foreground_process(new_process_group=False)


def find_binary(*names: PathString, root: Path = Path("/"), extra: Sequence[Path] = ()) -> Optional[Path]:
def find_binary(
*names: PathString,
root: Optional[Path] = None,
extra: Sequence[Path] = (),
) -> Optional[Path]:
root = root or Path("/")

if root != Path("/"):
path = ":".join(
itertools.chain(
Expand Down
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ImageConfig:
distribution: Distribution
release: str
debug_shell: bool
tools: Optional[Path]


class Image:
Expand Down Expand Up @@ -64,6 +65,7 @@ def mkosi(
return run(
[
"python3", "-m", "mkosi",
*(["--tools-tree", os.fspath(self.config.tools)] if self.config.tools else []),
"--debug",
*options,
verb,
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
from collections.abc import Iterator
from pathlib import Path
from typing import Any, cast

import pytest
Expand Down Expand Up @@ -48,6 +49,7 @@ def config(request: Any) -> ImageConfig:
distribution=distribution,
release=release,
debug_shell=request.config.getoption("--debug-shell"),
tools=p if (p := Path("mkosi.tools")).exists() else None,
)


Expand Down

0 comments on commit 4005997

Please sign in to comment.