Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Jun 26, 2024
1 parent c55c9dd commit 69b5a4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 50 deletions.
11 changes: 0 additions & 11 deletions tests/functional/flakes/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ EOF

nix flake check $flakeDir

cat > $flakeDir/flake.nix <<EOF
{
outputs = { self }: {
overlay = finalll: prev: {
};
};
}
EOF

#(! nix flake check $flakeDir)

cat > $flakeDir/flake.nix <<EOF
{
outputs = { self, ... }: {
Expand Down
46 changes: 9 additions & 37 deletions tests/functional/flakes/show.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

source ./common.sh

exit 0 # FIXME

flakeDir=$TEST_ROOT/flake
mkdir -p "$flakeDir"

Expand All @@ -17,9 +15,9 @@ 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} == {};
assert show_output.packages.output.children.someOtherSystem.filtered;
assert show_output.packages.output.children.${builtins.currentSystem}.children.default.derivationName == "simple";
assert show_output.legacyPackages.skipped;
true
'

Expand All @@ -28,8 +26,8 @@ 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} == {};
assert show_output.packages.output.children.someOtherSystem.children.default.derivationName == "simple";
assert show_output.legacyPackages.skipped;
true
'

Expand All @@ -38,34 +36,7 @@ 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 == { };
assert show_output.legacyPackages.output.children.${builtins.currentSystem}.children.hello.derivationName == "simple";
true
'

Expand All @@ -82,10 +53,11 @@ cat >flake.nix <<EOF
}
EOF
nix flake show --json --legacy --all-systems > show-output.json
jq < 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";
#assert show_output.legacyPackages.output.children.${builtins.currentSystem}.AAAAAASomeThingsFailToEvaluate == { };
assert show_output.legacyPackages.output.children.${builtins.currentSystem}.children.simple.derivationName == "simple";
true
'
4 changes: 2 additions & 2 deletions tests/functional/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cat << EOF > flake.nix
}
EOF
nix fmt ./file ./folder | grep 'Formatting: ./file ./folder'
#nix flake check
#nix flake show | grep -P "package 'formatter'"
nix flake check
nix flake show | grep -P "package.*\[formatter\]"

clearStore

0 comments on commit 69b5a4a

Please sign in to comment.