From aba66a51b598fff90bac8da7f83cc20d0f112683 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Wed, 9 Feb 2022 17:57:50 -0700 Subject: [PATCH] Make sure conda tests run with conda. --- flake.nix | 2 +- tests/all-tests.nix | 35 ++++------------------------------ tests/execute.sh | 6 ++++-- tests/make-tests.nix | 18 +++++++++++++++++ tests/test_py38_cp38_wheel.nix | 5 ++--- 5 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 tests/make-tests.nix diff --git a/flake.nix b/flake.nix index 34fe3e9..c234113 100644 --- a/flake.nix +++ b/flake.nix @@ -124,11 +124,11 @@ git nixFlakes parallel + bash ] ++ pkgs.lib.optional (stdenv.isLinux) busybox ++ pkgs.lib.optionals (stdenv.isDarwin) [ coreutils - (pkgs.runCommand "bin-sh" {} "mkdir -p $out/bin && ln -s ${pkgs.bash}/bin/bash $out/bin/sh") ])}" cd tests diff --git a/tests/all-tests.nix b/tests/all-tests.nix index 58117a5..5a9e4a6 100644 --- a/tests/all-tests.nix +++ b/tests/all-tests.nix @@ -1,35 +1,8 @@ with builtins; let mach-nix = import ../. {}; - conda = (getEnv "CONDA_TESTS") != ""; - makeTest = file: - import file ({ - inherit mach-nix; - } // (if conda then (rec { - baseArgsMkPython = { _provierDefaults = (fromTOML (readFile ./mach_nix/provider_defaults.toml) // { - _default = "conda,wheel,sdist,nixpkgs"; - }); }; - baseArgsBuildPythonPackage = baseArgsMkPython; - }) else { - baseArgsMkPython = { _provierDefaults = fromTOML (readFile ./mach_nix/provider_defaults.toml); }; - baseArgsBuildPythonPackage = baseArgsMkPython; - })); + lib = mach-nix.nixpkgs.lib; + makeTests = import ./make-tests.nix; + testNames = lib.mapAttrsToList (n: v: lib.removeSuffix ".nix" n) (lib.filterAttrs (n: v: lib.hasPrefix "test_" n && lib.hasSuffix ".nix" n) (builtins.readDir ./.)); in -flatten (map (file: makeTests) [ - ./test_alias_dateutil.nix - ./test_circular_deps.nix - ./test_dot_in_name.nix - ./test_extra_pkgs.nix - ./test_extras.nix - ./test_flakes.nix - ./test_jupyterlab_nixpkgs.nix - ./test_lazy_usage.nix - ./test_non_python_extra_pkgs.nix - ./test_overrides_selectPkgs.nix - ./test_passthru_select_pypi_pname.nix - ./test_py38_cp38_wheel.nix - ./test_pymc3.nix - ./test_r_pkgs.nix - ./test_underscore_override.nix - ./test_underscore_override_extra.nix -]) \ No newline at end of file + lib.flatten (map (name: makeTests { file = ./${name}.nix; }) testNames) diff --git a/tests/execute.sh b/tests/execute.sh index 97522a8..c79c60d 100755 --- a/tests/execute.sh +++ b/tests/execute.sh @@ -1,5 +1,7 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash + +set -euxo pipefail WORKERS=${WORKERS:-10} -ls ./test_* | parallel -a - -j $WORKERS --halt now,fail=1 nix-build --no-out-link --show-trace +find . -name "test_*.nix" | parallel -a - -j "${WORKERS}" --halt now,fail=1 nix-build --no-out-link --show-trace make-tests.nix --arg file diff --git a/tests/make-tests.nix b/tests/make-tests.nix new file mode 100644 index 0000000..f2612d6 --- /dev/null +++ b/tests/make-tests.nix @@ -0,0 +1,18 @@ +with builtins; +let + mach-nix = import ../. {}; + lib = mach-nix.nixpkgs.lib; + conda = (getEnv "CONDA_TESTS") != ""; + makeTests = {file}: + import file ({ + inherit mach-nix; + } // (if conda then (rec { + baseArgsMkPython = { _providerDefaults = (fromTOML (readFile ../mach_nix/provider_defaults.toml) // { + _default = "conda,wheel,sdist,nixpkgs"; + }); }; + baseArgsBuildPythonPackage = baseArgsMkPython; + }) else rec { + baseArgsMkPython = { _providerDefaults = fromTOML (readFile ../mach_nix/provider_defaults.toml); }; + baseArgsBuildPythonPackage = baseArgsMkPython; + })); +in makeTests diff --git a/tests/test_py38_cp38_wheel.nix b/tests/test_py38_cp38_wheel.nix index f0ca1d5..5f941fd 100644 --- a/tests/test_py38_cp38_wheel.nix +++ b/tests/test_py38_cp38_wheel.nix @@ -1,11 +1,10 @@ { - mach-nix ? import ../. { - python = "python38"; - }, + mach-nix ? import ../. {}, ... }: with builtins; mach-nix.mkPython { + python = "python38"; requirements = '' numba==0.50.1 '';