mirror of
https://github.com/NixOS/nix
synced 2025-07-10 08:53:55 +02:00
initialize test suite for git fetchers
solves #9388 This utilizes nixos vm tests to allow: - writing tests for fetchTree and fetchGit involving actual networking. - writing small independent test cases by automating local and remote repository setup per test case. This adds: - a gitea module setting up a gitea server - a setup module that simplifies writing test cases by automating the repo setup. - a simple git http test case Other improvements: For all nixos tests, add capability of overriding the nix version to test against. This should make it easier to prevent regressions. If a new test is added it can simply be ran against any older nix version without having to backport the test. For example, for running the container tests against nix 2.12.0: `nix build "$(nix eval --raw .#hydraJobs.tests.containers --impure --apply 't: (t.forNix "2.12.0").drvPath')^*" -L`
This commit is contained in:
parent
75d509eb08
commit
813c113b9e
4 changed files with 252 additions and 7 deletions
|
@ -5,14 +5,28 @@ let
|
|||
nixos-lib = import (nixpkgs + "/nixos/lib") { };
|
||||
|
||||
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
||||
runNixOSTestFor = system: test: nixos-lib.runTest {
|
||||
imports = [ test ];
|
||||
hostPkgs = nixpkgsFor.${system}.native;
|
||||
defaults = {
|
||||
nixpkgs.pkgs = nixpkgsFor.${system}.native;
|
||||
runNixOSTestFor = system: test:
|
||||
(nixos-lib.runTest {
|
||||
imports = [ test ];
|
||||
hostPkgs = nixpkgsFor.${system}.native;
|
||||
defaults = {
|
||||
nixpkgs.pkgs = nixpkgsFor.${system}.native;
|
||||
nix.checkAllErrors = false;
|
||||
};
|
||||
_module.args.nixpkgs = nixpkgs;
|
||||
_module.args.system = system;
|
||||
})
|
||||
// {
|
||||
# allow running tests against older nix versions via `nix eval --apply`
|
||||
# Example:
|
||||
# nix build "$(nix eval --raw --impure .#hydraJobs.tests.fetch-git --apply 't: (t.forNix "2.19.2").drvPath')^*"
|
||||
forNix = nixVersion: runNixOSTestFor system {
|
||||
imports = [test];
|
||||
defaults.nixpkgs.overlays = [(curr: prev: {
|
||||
nix = (builtins.getFlake "nix/${nixVersion}").packages.${system}.nix;
|
||||
})];
|
||||
};
|
||||
};
|
||||
_module.args.nixpkgs = nixpkgs;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
|
@ -40,4 +54,6 @@ in
|
|||
setuid = lib.genAttrs
|
||||
["i686-linux" "x86_64-linux"]
|
||||
(system: runNixOSTestFor system ./setuid.nix);
|
||||
|
||||
fetch-git = runNixOSTestFor "x86_64-linux" ./fetch-git;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue