aboutsummaryrefslogtreecommitdiff
path: root/tests/flakes.sh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-07-13 13:17:10 +0200
committerEelco Dolstra <edolstra@gmail.com>2022-07-13 13:46:33 +0200
commit19190c2346b84916c64737d895b87b570c673b96 (patch)
tree6012eb2f9cce6a26b9a0ca21f15c88e8ee467836 /tests/flakes.sh
parent438776cce73832470a5d30b2e77312643402ec41 (diff)
tests/flakes.sh: Make sure flake7 is clean
Cherry-picked from the lazy-trees branch, where we no longer write a lock file if any of the inputs is dirty.
Diffstat (limited to 'tests/flakes.sh')
-rw-r--r--tests/flakes.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/flakes.sh b/tests/flakes.sh
index 9087e1978..265e4a456 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -28,6 +28,15 @@ flakeFollowsC=$TEST_ROOT/follows/flakeA/flakeB/flakeC
flakeFollowsD=$TEST_ROOT/follows/flakeA/flakeD
flakeFollowsE=$TEST_ROOT/follows/flakeA/flakeE
+initRepo() {
+ local repo="$1"
+ local extraArgs="$2"
+
+ git -C $repo init $extraArgs
+ git -C $repo config user.email "foobar@example.com"
+ git -C $repo config user.name "Foobar"
+}
+
for repo in $flake1Dir $flake2Dir $flake3Dir $flake7Dir $templatesDir $nonFlakeDir $flakeA $flakeB $flakeFollowsA; do
rm -rf $repo $repo.tmp
mkdir -p $repo
@@ -38,9 +47,7 @@ for repo in $flake1Dir $flake2Dir $flake3Dir $flake7Dir $templatesDir $nonFlakeD
extraArgs="--initial-branch=main"
fi
- git -C $repo init $extraArgs
- git -C $repo config user.email "foobar@example.com"
- git -C $repo config user.name "Foobar"
+ initRepo "$repo" "$extraArgs"
done
cat > $flake1Dir/flake.nix <<EOF
@@ -427,16 +434,17 @@ nix flake show $flake7Dir --json | jq
git -C $flake7Dir commit -a -m 'Initial'
# Test 'nix flake init' with benign conflicts
-rm -rf $flake7Dir && mkdir $flake7Dir && git -C $flake7Dir init
+rm -rf $flake7Dir && mkdir $flake7Dir && initRepo "$flake7Dir"
echo a > $flake7Dir/a
(cd $flake7Dir && nix flake init) # check idempotence
# Test 'nix flake init' with conflicts
-rm -rf $flake7Dir && mkdir $flake7Dir && git -C $flake7Dir init
+rm -rf $flake7Dir && mkdir $flake7Dir && initRepo "$flake7Dir"
echo b > $flake7Dir/a
pushd $flake7Dir
(! nix flake init) |& grep "refusing to overwrite existing file '$flake7Dir/a'"
popd
+git -C $flake7Dir commit -a -m 'Changed'
# Test 'nix flake new'.
rm -rf $flake6Dir