Fix(tests): fix failing pytests

This commit is contained in:
Johannes Kirschbauer
2025-05-28 10:42:38 +02:00
parent 6f0a4549a5
commit 673b6bb31f
3 changed files with 3 additions and 37 deletions

View File

@@ -7,10 +7,3 @@ from clan_lib.bwrap import bubblewrap_works
@pytest.mark.skipif(sys.platform != "linux", reason="bubblewrap only works on linux") @pytest.mark.skipif(sys.platform != "linux", reason="bubblewrap only works on linux")
def test_bubblewrap_works_on_linux() -> None: def test_bubblewrap_works_on_linux() -> None:
assert bubblewrap_works() is True assert bubblewrap_works() is True
@pytest.mark.skipif(
sys.platform == "linux", reason="bubblewrap does not work on non-linux"
)
def test_bubblewrap_detection_non_linux() -> None:
assert bubblewrap_works() is False

View File

@@ -39,6 +39,8 @@ class MockFlake:
output = subprocess.run( output = subprocess.run(
[ [
"nix", "nix",
"--extra-experimental-features",
"nix-command flakes",
"eval", "eval",
"--impure", "--impure",
"--json", "--json",

View File

@@ -176,36 +176,7 @@ pythonRuntime.pkgs.buildPythonApplication {
# limit build cores to 16 # limit build cores to 16
jobs="$((NIX_BUILD_CORES>16 ? 16 : NIX_BUILD_CORES))" jobs="$((NIX_BUILD_CORES>16 ? 16 : NIX_BUILD_CORES))"
python -m pytest -m "not impure and not with_core" -n $jobs ./clan_cli/tests python -m pytest -m "not impure and not with_core" -n $jobs ./clan_cli ./clan_lib
touch $out
'';
clan-lib-pytest-without-core =
runCommand "clan-lib-pytest-without-core"
{
nativeBuildInputs = testDependencies;
closureInfo = pkgs.closureInfo {
rootPaths = [
templateDerivation
];
};
}
''
set -euo pipefail
cp -r ${sourceWithTests} ./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"
# limit build cores to 16
jobs="$((NIX_BUILD_CORES>16 ? 16 : NIX_BUILD_CORES))"
python -m pytest -m "not impure and not with_core" -n $jobs ./clan_lib
touch $out touch $out
''; '';
} }