See: cl/4840
When importing Python modules, we include `functional2` in the module
path, like this:
from functional2.testlib.fixtures.env import ManagedEnv
This means that python expects to see a file like
`functional2/testlib/fixtures/env.py`. We run `pytest` from `tests/` in
the `justfile` and have `tests/functional2/__init__.py` so `pytest` in
`meson` is able to find these imports.
However, language servers generally consider the `pyproject.toml` to be
the project root, so (e.g.) `pyright` is unable to follow any of the
`functional2` imports, leading to lots of spurious errors.
In cl/4840 I moved `tests/functional2/pyproject.toml` to
`tests/pyproject.toml`, which worked but was considered aesthetically
unappealing.
This diff is much larger but it's a more elegant solution.
Change-Id: I2983c7b87f88f59a4e3521451a9f5acd6a6a6964
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import re
|
|
from pathlib import Path
|
|
|
|
from testlib.fixtures.file_helper import with_files
|
|
from testlib.fixtures.nix import Nix
|
|
from testlib.utils import get_global_asset_pack
|
|
|
|
|
|
@with_files(get_global_asset_pack("dependencies"))
|
|
def test_compression_levels(nix: Nix):
|
|
cache_dir1 = nix.env.dirs.cache_dir / "test1"
|
|
cache_dir2 = nix.env.dirs.cache_dir / "test2"
|
|
|
|
nix.settings.feature("nix-command")
|
|
res = nix.nix_build(["dependencies.nix", "--no-out-link"]).run().ok()
|
|
out_path = res.stdout_plain
|
|
|
|
def get_size_for_level(level: int, c_dir: Path) -> int:
|
|
cpy_res = (
|
|
nix.nix(
|
|
[
|
|
"copy",
|
|
"--to",
|
|
f"file://{c_dir}?compression=xz&compression-level={level}",
|
|
out_path,
|
|
],
|
|
build=True,
|
|
)
|
|
.run()
|
|
.ok()
|
|
)
|
|
assert "copying 4 paths..." in cpy_res.stderr_plain
|
|
|
|
size = 0
|
|
for f in c_dir.glob("*.narinfo"):
|
|
size += int(re.search(r"FileSize: (\d+)\n", f.read_text()).group(1))
|
|
|
|
return size
|
|
|
|
size_0 = get_size_for_level(0, cache_dir1)
|
|
|
|
size_5 = get_size_for_level(5, cache_dir2)
|
|
|
|
assert size_0 > size_5
|