diff --git a/test/lib/copy-src.sh b/test/lib/copy-src.sh index 93be40c..39e6995 100644 --- a/test/lib/copy-src.sh +++ b/test/lib/copy-src.sh @@ -15,4 +15,4 @@ trap "atExit" EXIT rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src echo "Copied src" -_nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}" +_nixBitcoinInCopiedSrc=1 $tmp/src/test/run-tests.sh "${args[@]}" diff --git a/test/lib/create-git-repo.sh b/test/lib/create-git-repo.sh new file mode 100644 index 0000000..4f635c5 --- /dev/null +++ b/test/lib/create-git-repo.sh @@ -0,0 +1,13 @@ +# Create and maintain a minimal git repo at the root of the copied src +( + cd "$scriptDir/.." + amend=--amend + if [[ ! -e .git ]]; then + git init + amend= + fi + git add . + if ! git diff --quiet --cached; then + git commit -a $amend -m - + fi +) >/dev/null diff --git a/test/run-tests.sh b/test/run-tests.sh index 06ac514..f30c5a2 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -95,7 +95,7 @@ while :; do ;; --copy-src|-c) shift - if [[ ! $_nixBitcoinInCopySrc ]]; then + if [[ ! $_nixBitcoinInCopiedSrc ]]; then . "$scriptDir/lib/copy-src.sh" exit fi @@ -271,12 +271,17 @@ flake() { nixosSearch() { if ! checkFlakeSupport "nixosSearch"; then return; fi + if [[ $_nixBitcoinInCopiedSrc ]]; then + # flake-info requires that its target flake is under version control + . "$scriptDir/lib/create-git-repo.sh" + fi + if [[ $outLinkPrefix ]]; then # Add gcroots for flake-info nix build $scriptDir/nixos-search#flake-info -o "$outLinkPrefix-flake-info" fi echo "Running flake-info (nixos-search)" - nix run $scriptDir/nixos-search#flake-info -- flake ../. + nix run $scriptDir/nixos-search#flake-info -- flake "$scriptDir/.." } # A basic subset of tests to keep the total runtime within