Skip to content

Commit

Permalink
tests.references: migrate from nixosTest to runNixOSTest
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
ShamrockLee committed Mar 16, 2024
1 parent 9b54fb4 commit abf7172
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pkgs/build-support/trivial-builders/test/references/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -114,11 +120,12 @@ testers.nixosTest {
samples
testScriptBin
;
inherit guestTestScriptBin;
};
meta = {
maintainers = with lib.maintainers; [
roberth
ShamrockLee
];
};
}
})

0 comments on commit abf7172

Please sign in to comment.