clan-cli: Add CLAN_TEST_STORE env var to clan-pytest-without-core

This commit is contained in:
Qubasa
2025-02-17 13:19:45 +07:00
parent ab6a9b2d52
commit 892bd25a3a
2 changed files with 8 additions and 22 deletions

View File

@@ -130,11 +130,18 @@ pythonRuntime.pkgs.buildPythonApplication {
clan-pytest-without-core = clan-pytest-without-core =
runCommand "clan-pytest-without-core" { nativeBuildInputs = testDependencies; } runCommand "clan-pytest-without-core" { nativeBuildInputs = testDependencies; }
'' ''
set -ux -o pipefail
cp -r ${source} ./src cp -r ${source} ./src
chmod +w -R ./src chmod +w -R ./src
cd ./src cd ./src
export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1 PYTHONWARNINGS=error export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1 PYTHONWARNINGS=error
# required to prevent concurrent 'nix flake lock' operations
export CLAN_TEST_STORE=$TMPDIR/store
export LOCK_NIX=$TMPDIR/nix_lock
mkdir -p "$CLAN_TEST_STORE/nix/store"
python -m pytest -m "not impure and not with_core" ./tests python -m pytest -m "not impure and not with_core" ./tests
touch $out touch $out
''; '';
@@ -158,6 +165,7 @@ pythonRuntime.pkgs.buildPythonApplication {
}; };
} }
'' ''
set -ux -o pipefail
cp -r ${source} ./src cp -r ${source} ./src
chmod +w -R ./src chmod +w -R ./src
cd ./src cd ./src

View File

@@ -5,10 +5,8 @@ from pathlib import Path
from typing import Any from typing import Any
import pytest import pytest
from clan_cli.cmd import run
from clan_cli.flake import Flake from clan_cli.flake import Flake
from clan_cli.locked_open import locked_open from clan_cli.locked_open import locked_open
from clan_cli.nix import nix_command
from clan_cli.templates import ( from clan_cli.templates import (
InputName, InputName,
TemplateName, TemplateName,
@@ -77,26 +75,6 @@ def test_clan_core_templates(
f.write(data) f.write(data)
def test_copy_from_nixstore_symlink(
monkeypatch: pytest.MonkeyPatch, temporary_home: Path
) -> None:
src = temporary_home / "src"
src.mkdir()
(src / "file.txt").write_text("magicstring!")
res = run(nix_command(["store", "add", str(src)]))
src_nix = Path(res.stdout.strip())
src2 = temporary_home / "src2"
src2.mkdir()
(src2 / "file.txt").symlink_to(src_nix / "file.txt")
res = run(nix_command(["store", "add", str(src2)]))
src2_nix = Path(res.stdout.strip())
dest = temporary_home / "dest"
copy_from_nixstore(src2_nix, dest)
assert (dest / "file.txt").exists()
assert (dest / "file.txt").read_text() == "magicstring!"
assert (dest / "file.txt").is_symlink()
# Test Case 1: Minimal input with empty templates # Test Case 1: Minimal input with empty templates
@pytest.mark.impure @pytest.mark.impure
def test_clan_get_nix_attrset_case_1( def test_clan_get_nix_attrset_case_1(