summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAntoine Eiche <lewo@abesis.fr>2020-04-11 15:38:52 +0200
committerAntoine Eiche <lewo@abesis.fr>2020-04-19 10:01:57 +0200
commita53aa5ac9a080f292a45cea93e8249be2530d20b (patch)
treecb13691fb523cdd456fcbcb54b67b45ba75c11d4 /tests
parent6563abc1c45de0d9e6b02cf8842005800b4e2745 (diff)
Use Niv to pin nixpkgs releases
Before using Niv, we were following channels meaning we can not reproduce CI jobs easily. In this change, we use Niv to pin these dependencies. We are also addding a tests/default.nix to be able to run these tests locally. For instance, to run the test extern.nix on the nixpkgs-19.09 release: nix-build tests/default.nix -A extern.nixpkgs_19_09 Fixes #178
Diffstat (limited to 'tests')
-rw-r--r--tests/clamav.nix4
-rw-r--r--tests/default.nix57
-rw-r--r--tests/extern.nix4
-rw-r--r--tests/intern.nix4
-rw-r--r--tests/lib/pkgs.nokvm.nix3
5 files changed, 68 insertions, 4 deletions
diff --git a/tests/clamav.nix b/tests/clamav.nix
index 955d1ac..62b8d7d 100644
--- a/tests/clamav.nix
+++ b/tests/clamav.nix
@@ -14,7 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
-import <nixpkgs/nixos/tests/make-test.nix> {
+{ pkgs ? import <nixpkgs> {}}:
+
+import (pkgs.path + "/nixos/tests/make-test.nix") {
nodes = {
server = { config, pkgs, lib, ... }:
diff --git a/tests/default.nix b/tests/default.nix
new file mode 100644
index 0000000..7de029e
--- /dev/null
+++ b/tests/default.nix
@@ -0,0 +1,57 @@
+# Generate an attribute sets containing all tests for all releaeses
+# It looks like:
+# - extern.nixpkgs_19_09
+# - extern.nixpkgs_20.03
+# - extern.nixpkgs_unstable
+# - intern.nixpkgs_19_09
+# - intern.nixpkgs_20.03
+# - intern.nixpkgs_unstable
+
+# Modify pkgs to run the tests on non KVM machines
+{ noKVM ? false }:
+
+with builtins;
+
+let
+ sources = import ../nix/sources.nix;
+
+ releases = listToAttrs (map genRelease releaseNames);
+
+ genRelease = name: {
+ name = name;
+ value = import sources."${name}" {};
+ };
+
+ genTest = testName: release:
+ let
+ pkgs = releases."${release}";
+ noKVMPkgs = p: if noKVM
+ then import ./lib/pkgs.nokvm.nix { pkgs = p; }
+ else p;
+ test = pkgs.callPackage (./. + "/${testName}.nix") { };
+ in {
+ "name"= builtins.replaceStrings ["." "-"] ["_" "_"] release;
+ "value"= test {
+ pkgs = (noKVMPkgs pkgs);
+ };
+ };
+
+ releaseNames = [
+ "nixpkgs-19.09"
+ "nixpkgs-20.03"
+ "nixpkgs-unstable"
+ ];
+
+ testNames = [
+ "intern"
+ "extern"
+ "clamav"
+ ];
+
+ # Generate an attribute set containing one test per releases
+ genTests = testName: {
+ name = testName;
+ value = listToAttrs (map (genTest testName) (builtins.attrNames releases));
+ };
+
+in listToAttrs (map genTests testNames)
diff --git a/tests/extern.nix b/tests/extern.nix
index cde05d8..6a4f6e7 100644
--- a/tests/extern.nix
+++ b/tests/extern.nix
@@ -14,7 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
-import <nixpkgs/nixos/tests/make-test.nix> {
+{ pkgs ? import <nixpkgs> {}}:
+
+import (pkgs.path + "/nixos/tests/make-test.nix") {
nodes = {
server = { config, pkgs, ... }:
diff --git a/tests/intern.nix b/tests/intern.nix
index 5abf379..62e03a8 100644
--- a/tests/intern.nix
+++ b/tests/intern.nix
@@ -14,7 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
-import <nixpkgs/nixos/tests/make-test.nix> {
+{ pkgs ? import <nixpkgs> {}}:
+
+import (pkgs.path + "/nixos/tests/make-test.nix") {
machine =
{ config, pkgs, ... }:
diff --git a/tests/lib/pkgs.nokvm.nix b/tests/lib/pkgs.nokvm.nix
index fa13fde..8832f08 100644
--- a/tests/lib/pkgs.nokvm.nix
+++ b/tests/lib/pkgs.nokvm.nix
@@ -1,5 +1,6 @@
+{ pkgs }:
+
let
- pkgs = (import <nixpkgs> { system = builtins.currentSystem; config = {}; });
patchedMachinePM = pkgs.writeTextFile {
name = "Machine.pm.patched-to-wait-longer-for-vm";
text = builtins.replaceStrings ["alarm 600;"] ["alarm 1200;"] (builtins.readFile (<nixpkgs>+"/nixos/lib/test-driver/Machine.pm"));