mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
shellcheck fix: tests/functional/flakes/check.sh
This commit is contained in:
parent
9bf8e7b730
commit
26a10453c3
2 changed files with 33 additions and 29 deletions
|
|
@ -106,7 +106,6 @@
|
|||
enable = true;
|
||||
excludes = [
|
||||
# We haven't linted these files yet
|
||||
''^tests/functional/flakes/check\.sh$''
|
||||
''^tests/functional/flakes/config\.sh$''
|
||||
''^tests/functional/flakes/flakes\.sh$''
|
||||
''^tests/functional/flakes/follow-paths\.sh$''
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
source common.sh
|
||||
|
||||
flakeDir=$TEST_ROOT/flake3
|
||||
mkdir -p $flakeDir
|
||||
mkdir -p "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
overlay = final: prev: {
|
||||
|
|
@ -14,9 +14,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
nix flake check $flakeDir
|
||||
nix flake check "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
overlay = finalll: prev: {
|
||||
|
|
@ -25,9 +25,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
(! nix flake check $flakeDir)
|
||||
(! nix flake check "$flakeDir")
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self, ... }: {
|
||||
overlays.x86_64-linux.foo = final: prev: {
|
||||
|
|
@ -36,10 +36,11 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
checkRes=$(nix flake check $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
# shellcheck disable=SC2015
|
||||
checkRes=$(nix flake check "$flakeDir" 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet "error: overlay is not a function, but a set instead"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
nixosModules.foo = {
|
||||
|
|
@ -50,9 +51,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
nix flake check $flakeDir
|
||||
nix flake check "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
nixosModules.foo = assert false; {
|
||||
|
|
@ -63,9 +64,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
(! nix flake check $flakeDir)
|
||||
(! nix flake check "$flakeDir")
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
nixosModule = { config, pkgs, ... }: {
|
||||
|
|
@ -75,9 +76,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
nix flake check $flakeDir
|
||||
nix flake check "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
packages.system-1.default = "foo";
|
||||
|
|
@ -86,13 +87,14 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
nix flake check $flakeDir
|
||||
nix flake check "$flakeDir"
|
||||
|
||||
checkRes=$(nix flake check --all-systems --keep-going $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
# shellcheck disable=SC2015
|
||||
checkRes=$(nix flake check --all-systems --keep-going "$flakeDir" 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet "packages.system-1.default"
|
||||
echo "$checkRes" | grepQuiet "packages.system-2.default"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
apps.system-1.default = {
|
||||
|
|
@ -108,9 +110,9 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
nix flake check --all-systems $flakeDir
|
||||
nix flake check --all-systems "$flakeDir"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
apps.system-1.default = {
|
||||
|
|
@ -122,10 +124,11 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
checkRes=$(nix flake check --all-systems $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
# shellcheck disable=SC2015
|
||||
checkRes=$(nix flake check --all-systems "$flakeDir" 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet "unknown-attr"
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
formatter.system-1 = "foo";
|
||||
|
|
@ -133,11 +136,12 @@ cat > $flakeDir/flake.nix <<EOF
|
|||
}
|
||||
EOF
|
||||
|
||||
checkRes=$(nix flake check --all-systems $flakeDir 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
# shellcheck disable=SC2015
|
||||
checkRes=$(nix flake check --all-systems "$flakeDir" 2>&1 && fail "nix flake check --all-systems should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet "formatter.system-1"
|
||||
|
||||
# Test whether `nix flake check` builds checks.
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
checks.$system.foo = with import ./config.nix; mkDerivation {
|
||||
|
|
@ -152,7 +156,7 @@ cp "${config_nix}" "$flakeDir/"
|
|||
|
||||
expectStderr 0 nix flake check "$flakeDir" | grepQuiet 'running 1 flake check'
|
||||
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: {
|
||||
checks.$system.foo = with import ./config.nix; mkDerivation {
|
||||
|
|
@ -170,8 +174,8 @@ fi
|
|||
|
||||
# Ensure non-substitutable (read: usually failed) checks are actually run
|
||||
# https://github.com/NixOS/nix/pull/13574
|
||||
cp "$config_nix" $flakeDir/
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
cp "$config_nix" "$flakeDir"/
|
||||
cat > "$flakeDir"/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: with import ./config.nix; {
|
||||
checks.${system}.expectedToFail = derivation {
|
||||
|
|
@ -185,5 +189,6 @@ EOF
|
|||
|
||||
# NOTE: Regex pattern is used for compatibility with older daemon versions
|
||||
# We also can't expect a specific status code. Earlier daemons return 1, but as of 2.31, we return 100
|
||||
checkRes=$(nix flake check $flakeDir 2>&1 && fail "nix flake check should have failed" || true)
|
||||
# shellcheck disable=SC2015
|
||||
checkRes=$(nix flake check "$flakeDir" 2>&1 && fail "nix flake check should have failed" || true)
|
||||
echo "$checkRes" | grepQuiet -E "builder( for .*)? failed with exit code 1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue