about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorYueh-Shun Li <shamrocklee@posteo.net>2024-03-02 17:26:15 +0800
committerYueh-Shun Li <shamrocklee@posteo.net>2024-03-17 04:21:26 +0800
commitabf7172bfafdd6f67d5df62d08d9cd2d4d107975 (patch)
treed43c8c3866565fd7882e6a205735a1b8be84a627 /pkgs
parent9b54fb452468f74e0f93cc339a85d7132527b6ab (diff)
tests.references: migrate from nixosTest to runNixOSTest
- Use testers.runNixOSTest instead of testers.nixosTest as nixosTest
  has become obsolete.

- Prepare for cross-platform testing.
    - Use the testScriptBin passthru'd by the references test package
      inside the guest pkgs.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/trivial-builders/test/references/default.nix23
1 files changed, 15 insertions, 8 deletions
diff --git a/pkgs/build-support/trivial-builders/test/references/default.nix b/pkgs/build-support/trivial-builders/test/references/default.nix
index 3e21c905321e4..abcba830300ba 100644
--- a/pkgs/build-support/trivial-builders/test/references/default.nix
+++ b/pkgs/build-support/trivial-builders/test/references/default.nix
@@ -90,21 +90,27 @@ let
     };
   });
 in
-testers.nixosTest {
-  name = "nixpkgs-trivial-builders";
-  nodes.machine = { ... }: {
+testers.runNixOSTest ({ config, lib, ... }:
+let
+  # Use the testScriptBin from guest pkgs.
+  # The attribute path to access the guest version of testScriptBin is
+  # tests.trivial-builders.references.config.node.pkgs.tests.trivial-builders.references.testScriptBin
+  # which is why passthru.guestTestScriptBin is provided.
+  guestTestScriptBin = config.node.pkgs.tests.trivial-builders.references.testScriptBin;
+in
+{
+  name = "nixpkgs-trivial-builders-references";
+  nodes.machine = { config, lib, pkgs, ... }: {
     virtualisation.writableStore = true;
 
     # Test runs without network, so we don't substitute and prepare our deps
     nix.settings.substituters = lib.mkForce [ ];
-    environment.etc."pre-built-paths".source = writeText "pre-built-paths" (
-      builtins.toJSON [ testScriptBin ]
-    );
+    system.extraDependencies = [ guestTestScriptBin ];
   };
   testScript =
     ''
       machine.succeed("""
-        ${lib.getExe testScriptBin} 2>/dev/console
+        ${lib.getExe guestTestScriptBin} 2>/dev/console
       """)
     '';
   passthru = {
@@ -114,6 +120,7 @@ testers.nixosTest {
       samples
       testScriptBin
       ;
+    inherit guestTestScriptBin;
   };
   meta = {
     maintainers = with lib.maintainers; [
@@ -121,4 +128,4 @@ testers.nixosTest {
       ShamrockLee
     ];
   };
-}
+})