Files
eldritch horrors f5b9f105e2 libstore: drop Store::connect
there's no reason a store should not open a connection during init if it
needs to open any connection to function. delaying connection setup like
this makes openStore less deterministic and graceful fallback impossible

this caused test failures where the old behaviour was required to ensure
test output stability. because of course something like that must happen

Change-Id: I946adddee026f1f4c74b4699d730b4d1ac9a5072
2026-07-17 18:00:14 +00:00

40 lines
1.6 KiB
Python

import re
from pathlib import Path
import pytest
from mistletoe.markdown_renderer import MarkdownRenderer
from testlib.repl_util import ReplTest, ReplTestMetadata, get_repl_test_params
from testlib.fixtures.nix import Nix
def pytest_generate_tests(metafunc: pytest.Metafunc):
if metafunc.definition.name != "test_repl_char":
return
params, ids = get_repl_test_params()
metafunc.parametrize(("files", "metadata"), params, indirect=["files"], ids=ids)
def _clean_output(output: str, origin: Path) -> str:
lix_version_regex = r"Lix \d+\.\d+\.\d+-?[^\n ]*"
return re.sub(lix_version_regex, "Lix VERSION", output.replace(str(origin), "/pwd"))
@pytest.mark.nix_settings(trusted_users="*") # silence trusted settings warnings
def test_repl_char(nix: Nix, do_snapshot_update: bool, metadata: ReplTestMetadata, files: Path):
nix.settings.add_xp_feature("nix-command", "flakes", "repl-automation")
with MarkdownRenderer() as renderer:
test: ReplTest = metadata.create_test()
args = [arg.replace("{PWD}", str(files.absolute())) for arg in metadata.args or []]
cmd = nix.nix(["repl", "--offline", *args]).with_stdin(test.input.encode())
cmd.err_to_out = True
res = cmd.run().expect(metadata.should_fail or 0)
usable_output = _clean_output(res.stdout_plain, files)
if test.check_and_update(usable_output, do_snapshot_update):
new_content = metadata.as_frontmatter + renderer.render(test.doc)
metadata.file.write_text(new_content)
pytest.skip("Updated golden files")