File tree Expand file tree Collapse file tree 3 files changed +116
-74
lines changed
Expand file tree Collapse file tree 3 files changed +116
-74
lines changed Original file line number Diff line number Diff line change 4040 extra-files = callTest ./extra-files.nix { } ;
4141 enable-except-in-tests = callTest ./enable-except-in-tests.nix { } ;
4242 failing-tests = callTest ./failing-tests.nix { } ;
43+ nixpkgs-module = callTest ./nixpkgs-module.nix { } ;
4344 no-flake = callTest ./no-flake.nix { } ;
4445 lib-tests = callTest ./lib-tests.nix { } ;
4546 maintainers = callTest ./maintainers.nix { } ;
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ linkFarmFromDrvs ,
4+ nixvimConfiguration ,
5+ runCommandNoCCLocal ,
6+ self ,
7+ system ,
8+ } :
9+ let
10+ # Writes a runCommand style derivation based on a nixvim module's output
11+ testModule =
12+ {
13+ name ,
14+ module ,
15+ drvArgs ,
16+ script ,
17+ } :
18+ let
19+ configuration = nixvimConfiguration . extendModules {
20+ modules = lib . toList module ;
21+ } ;
22+ finalDrvArgs = {
23+ __structuredAttrs = true ;
24+ } // drvArgs ( configuration . _module . args // configuration ) ;
25+ in
26+ runCommandNoCCLocal name finalDrvArgs script ;
27+
28+ # Writes a test derivation that checks specific variables have the expected values
29+ testExpectations =
30+ {
31+ name ,
32+ module ,
33+ drvArgs ,
34+ expectations ,
35+ } :
36+ let
37+ checks = lib . concatLines (
38+ lib . mapAttrsToList ( name : expected : ''
39+ ${ lib . toShellVar "_expected" expected }
40+ if [ "${ "$" + name } " != "$_expected" ]; then
41+ error+='- Expected ${ name } to be "'"$_expected"'" but found "'"${ "$" + name } "'"'
42+ fi
43+ '' ) expectations
44+ ) ;
45+ in
46+ testModule {
47+ inherit name module drvArgs ;
48+ script = ''
49+ error=""
50+ ${ checks }
51+ if [ -n "$error" ]; then
52+ echo "${ name } failed:"
53+ echo "$error"
54+ exit 1
55+ fi
56+ touch $out
57+ '' ;
58+ } ;
59+
60+ # Further simplifies `testExpectations` when all the expectations relate to attrs in `pkgs`
61+ testPkgsExpectations =
62+ {
63+ name ,
64+ module ,
65+ expectations ,
66+ } :
67+ testExpectations {
68+ inherit name module expectations ;
69+ drvArgs = { pkgs , ... } : lib . mapAttrs ( name : _ : pkgs . ${ name } or null ) expectations ;
70+ } ;
71+ in
72+ linkFarmFromDrvs "nixpkgs-module-tests" [
73+
74+ ( testPkgsExpectations {
75+ name = "overlays-are-applied" ;
76+ module = {
77+ nixpkgs . overlays = [
78+ ( final : prev : {
79+ foobar = "foobar" ;
80+ } )
81+ ] ;
82+ } ;
83+ expectations = {
84+ foobar = "foobar" ;
85+ } ;
86+ } )
87+
88+ ( testPkgsExpectations {
89+ name = "overlays-can-be-stacked" ;
90+ module = {
91+ nixpkgs . pkgs = import self . inputs . nixpkgs {
92+ inherit system ;
93+ overlays = [
94+ ( final : prev : {
95+ foobar = "foobar" ;
96+ conflict = "a" ;
97+ } )
98+ ] ;
99+ } ;
100+ nixpkgs . overlays = [
101+ ( final : prev : {
102+ hello = "world" ;
103+ conflict = "b" ;
104+ } )
105+ ] ;
106+
107+ } ;
108+ expectations = {
109+ foobar = "foobar" ;
110+ hello = "world" ;
111+ conflict = "b" ;
112+ } ;
113+ } )
114+
115+ ]
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments