mirror of
https://github.com/NixOS/nix
synced 2025-07-12 19:05:08 +02:00
Put functional tests in tests/functional
I think it is bad for these reasons when `tests/` contains a mix of
functional and integration tests
- Concepts is harder to understand, the documentation makes a good
unit vs functional vs integration distinction, but when the
integration tests are just two subdirs within `tests/` this is not
clear.
- Source filtering in the `flake.nix` is more complex. We need to
filter out some of the dirs from `tests/`, rather than simply pick
the dirs we want and take all of them. This is a good sign the
structure of what we are trying to do is not matching the structure
of the files.
With this change we have a clean:
```shell-session
$ git show 'HEAD:tests'
tree HEAD:tests
functional/
installer/
nixos/
```
(cherry picked from commit 68c81c7375
)
This commit is contained in:
parent
7242521265
commit
30dcc19d1f
598 changed files with 93 additions and 93 deletions
87
tests/functional/flakes/show.sh
Normal file
87
tests/functional/flakes/show.sh
Normal file
|
@ -0,0 +1,87 @@
|
|||
source ./common.sh
|
||||
|
||||
flakeDir=$TEST_ROOT/flake
|
||||
mkdir -p "$flakeDir"
|
||||
|
||||
writeSimpleFlake "$flakeDir"
|
||||
cd "$flakeDir"
|
||||
|
||||
|
||||
# By default: Only show the packages content for the current system and no
|
||||
# legacyPackages at all
|
||||
nix flake show --json > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output.packages.someOtherSystem.default == {};
|
||||
assert show_output.packages.${builtins.currentSystem}.default.name == "simple";
|
||||
assert show_output.legacyPackages.${builtins.currentSystem} == {};
|
||||
true
|
||||
'
|
||||
|
||||
# With `--all-systems`, show the packages for all systems
|
||||
nix flake show --json --all-systems > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output.packages.someOtherSystem.default.name == "simple";
|
||||
assert show_output.legacyPackages.${builtins.currentSystem} == {};
|
||||
true
|
||||
'
|
||||
|
||||
# With `--legacy`, show the legacy packages
|
||||
nix flake show --json --legacy > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output.legacyPackages.${builtins.currentSystem}.hello.name == "simple";
|
||||
true
|
||||
'
|
||||
|
||||
# Test that attributes are only reported when they have actual content
|
||||
cat >flake.nix <<EOF
|
||||
{
|
||||
description = "Bla bla";
|
||||
|
||||
outputs = inputs: rec {
|
||||
apps.$system = { };
|
||||
checks.$system = { };
|
||||
devShells.$system = { };
|
||||
legacyPackages.$system = { };
|
||||
packages.$system = { };
|
||||
packages.someOtherSystem = { };
|
||||
|
||||
formatter = { };
|
||||
nixosConfigurations = { };
|
||||
nixosModules = { };
|
||||
};
|
||||
}
|
||||
EOF
|
||||
nix flake show --json --all-systems > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output == { };
|
||||
true
|
||||
'
|
||||
|
||||
# Test that attributes with errors are handled correctly.
|
||||
# nixpkgs.legacyPackages is a particularly prominent instance of this.
|
||||
cat >flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: {
|
||||
legacyPackages.$system = {
|
||||
AAAAAASomeThingsFailToEvaluate = throw "nooo";
|
||||
simple = import ./simple.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
nix flake show --json --legacy --all-systems > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output.legacyPackages.${builtins.currentSystem}.AAAAAASomeThingsFailToEvaluate == { };
|
||||
assert show_output.legacyPackages.${builtins.currentSystem}.simple.name == "simple";
|
||||
true
|
||||
'
|
Loading…
Add table
Add a link
Reference in a new issue