From 892bd25a3a846513a1e0b79d3c95f3592e7663a9 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Mon, 17 Feb 2025 13:19:45 +0700 Subject: [PATCH] clan-cli: Add CLAN_TEST_STORE env var to clan-pytest-without-core --- pkgs/clan-cli/default.nix | 8 +++++++ pkgs/clan-cli/tests/test_clan_nix_attrset.py | 22 -------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index a4fdec3ad..027a59593 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -130,11 +130,18 @@ pythonRuntime.pkgs.buildPythonApplication { clan-pytest-without-core = runCommand "clan-pytest-without-core" { nativeBuildInputs = testDependencies; } '' + set -ux -o pipefail cp -r ${source} ./src chmod +w -R ./src cd ./src 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 touch $out ''; @@ -158,6 +165,7 @@ pythonRuntime.pkgs.buildPythonApplication { }; } '' + set -ux -o pipefail cp -r ${source} ./src chmod +w -R ./src cd ./src diff --git a/pkgs/clan-cli/tests/test_clan_nix_attrset.py b/pkgs/clan-cli/tests/test_clan_nix_attrset.py index 36da4fe36..48e376e05 100644 --- a/pkgs/clan-cli/tests/test_clan_nix_attrset.py +++ b/pkgs/clan-cli/tests/test_clan_nix_attrset.py @@ -5,10 +5,8 @@ from pathlib import Path from typing import Any import pytest -from clan_cli.cmd import run from clan_cli.flake import Flake from clan_cli.locked_open import locked_open -from clan_cli.nix import nix_command from clan_cli.templates import ( InputName, TemplateName, @@ -77,26 +75,6 @@ def test_clan_core_templates( 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 @pytest.mark.impure def test_clan_get_nix_attrset_case_1(