run-tests: make nixosSearch compatible with --copy-src

This commit is contained in:
Erik Arvstedt 2021-12-14 19:51:17 +01:00
parent 2069f62abc
commit f13ffe0146
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
3 changed files with 21 additions and 3 deletions

View File

@ -15,4 +15,4 @@ trap "atExit" EXIT
rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src
echo "Copied src" echo "Copied src"
_nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}" _nixBitcoinInCopiedSrc=1 $tmp/src/test/run-tests.sh "${args[@]}"

View File

@ -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

View File

@ -95,7 +95,7 @@ while :; do
;; ;;
--copy-src|-c) --copy-src|-c)
shift shift
if [[ ! $_nixBitcoinInCopySrc ]]; then if [[ ! $_nixBitcoinInCopiedSrc ]]; then
. "$scriptDir/lib/copy-src.sh" . "$scriptDir/lib/copy-src.sh"
exit exit
fi fi
@ -271,12 +271,17 @@ flake() {
nixosSearch() { nixosSearch() {
if ! checkFlakeSupport "nixosSearch"; then return; fi 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 if [[ $outLinkPrefix ]]; then
# Add gcroots for flake-info # Add gcroots for flake-info
nix build $scriptDir/nixos-search#flake-info -o "$outLinkPrefix-flake-info" nix build $scriptDir/nixos-search#flake-info -o "$outLinkPrefix-flake-info"
fi fi
echo "Running flake-info (nixos-search)" 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 # A basic subset of tests to keep the total runtime within