From 4cafea7c7b230f5b25162c988dcd75145515f0be Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Nov 2024 18:51:23 +0100 Subject: [PATCH] Add a utility function for creating/registering a simple flake --- tests/functional/flakes/commit-lock-file-summary.sh | 8 +------- tests/functional/flakes/common.sh | 9 +++++++++ tests/functional/flakes/dubious-query.sh | 7 ++----- tests/functional/flakes/edit.sh | 7 +------ tests/functional/flakes/shebang.sh | 8 +------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/tests/functional/flakes/commit-lock-file-summary.sh b/tests/functional/flakes/commit-lock-file-summary.sh index 21504eb21..314d43ec3 100644 --- a/tests/functional/flakes/commit-lock-file-summary.sh +++ b/tests/functional/flakes/commit-lock-file-summary.sh @@ -4,15 +4,9 @@ source ./common.sh TODO_NixOS -requireGit +createFlake1 -flake1Dir=$TEST_ROOT/flake1 lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake - -createGitRepo "$flake1Dir" "" -createSimpleGitFlake "$flake1Dir" -nix registry add --registry "$registry" flake1 "git+file://$flake1Dir" - createGitRepo "$lockfileSummaryFlake" "--initial-branch=main" # Test that the --commit-lock-file-summary flag and its alias work diff --git a/tests/functional/flakes/common.sh b/tests/functional/flakes/common.sh index cc9b2e466..0a020a1d7 100644 --- a/tests/functional/flakes/common.sh +++ b/tests/functional/flakes/common.sh @@ -38,12 +38,21 @@ EOF } createSimpleGitFlake() { + requireGit local flakeDir="$1" writeSimpleFlake "$flakeDir" git -C "$flakeDir" add flake.nix simple.nix shell.nix simple.builder.sh config.nix git -C "$flakeDir" commit -m 'Initial' } +# Create a simple Git flake and add it to the registry as "flake1". +createFlake1() { + flake1Dir="$TEST_ROOT/flake1" + createGitRepo "$flake1Dir" "" + createSimpleGitFlake "$flake1Dir" + nix registry add --registry "$registry" flake1 "git+file://$flake1Dir" +} + writeDependentFlake() { local flakeDir="$1" cat > "$flakeDir/flake.nix" < "$scriptDir/shebang.sh" <