clan-cli/flash: make tests runnable in sandbox
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from clan_cli.tests.helpers import cli
|
||||
from clan_cli.tests.stdout import CaptureOutput
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_flash_list_languages(capture_output: CaptureOutput) -> None:
|
||||
@pytest.mark.with_core
|
||||
def test_flash_list_languages(
|
||||
temporary_home: Path, capture_output: CaptureOutput
|
||||
) -> None:
|
||||
with capture_output as output:
|
||||
cli.run(["flash", "list", "languages"])
|
||||
assert "en_US.UTF-8" in output.out
|
||||
@@ -14,8 +18,10 @@ def test_flash_list_languages(capture_output: CaptureOutput) -> None:
|
||||
assert len(languages) > 1
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_flash_list_keymaps(capture_output: CaptureOutput) -> None:
|
||||
@pytest.mark.with_core
|
||||
def test_flash_list_keymaps(
|
||||
temporary_home: Path, capture_output: CaptureOutput
|
||||
) -> None:
|
||||
with capture_output as output:
|
||||
cli.run(["flash", "list", "keymaps"])
|
||||
assert "us" in output.out
|
||||
|
||||
@@ -5,6 +5,7 @@ from typing import TypedDict
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.cmd import Log, RunOpts, run
|
||||
from clan_lib.dirs import nixpkgs_source
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.nix import nix_build
|
||||
|
||||
@@ -28,7 +29,7 @@ def get_machine_flash_options() -> FlashOptions:
|
||||
|
||||
|
||||
def list_languages() -> list[str]:
|
||||
cmd = nix_build(["nixpkgs#glibcLocales"])
|
||||
cmd = nix_build([f"{nixpkgs_source()}#legacyPackages.x86_64-linux.glibcLocales"])
|
||||
result = run(cmd, RunOpts(log=Log.STDERR, error_msg="Failed to find glibc locales"))
|
||||
locale_file = Path(result.stdout.strip()) / "share" / "i18n" / "SUPPORTED"
|
||||
|
||||
@@ -53,7 +54,7 @@ def list_languages() -> list[str]:
|
||||
|
||||
|
||||
def list_keymaps() -> list[str]:
|
||||
cmd = nix_build(["nixpkgs#kbd"])
|
||||
cmd = nix_build([f"{nixpkgs_source()}#legacyPackages.x86_64-linux.kbd"])
|
||||
result = run(cmd, RunOpts(log=Log.STDERR, error_msg="Failed to find kbdinfo"))
|
||||
keymaps_dir = Path(result.stdout.strip()) / "share" / "keymaps"
|
||||
|
||||
|
||||
@@ -216,6 +216,10 @@ pythonRuntime.pkgs.buildPythonApplication {
|
||||
pkgs.xkcdpass
|
||||
pkgs.pass
|
||||
nix-select
|
||||
|
||||
# needed by flash list tests
|
||||
nixpkgs.legacyPackages.x86_64-linux.kbd
|
||||
nixpkgs.legacyPackages.x86_64-linux.glibcLocales
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user