Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/interop/interop-lib.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / interop / interop-lib.sh` 94 lines ยท 2019 bytes Raw Blame History 1 # Interoperability testing framework. Each script should source 2 # this after setting default $VERSION_A and $VERSION_B variables. 3 4 . ../../GIT-BUILD-OPTIONS 5 INTEROP_ROOT=$(pwd) 6 BUILD_ROOT=$INTEROP_ROOT/build 7 8 build_version () { 9 if test -z "$1" 10 then 11 echo >&2 "error: test script did not set default versions" 12 return 1 13 fi 14 15 if test "$1" = "." 16 then 17 git rev-parse --show-toplevel 18 return 0 19 fi 20 21 sha1=$(git rev-parse "$1^{tree}") || return 1 22 dir=$BUILD_ROOT/$sha1 23 24 if test -e "$dir/.built" 25 then 26 echo "$dir" 27 return 0 28 fi 29 30 echo >&2 "==> Building $1..." 31 32 mkdir -p "$dir" || return 1 33 34 (cd "$(git rev-parse --show-cdup)" && git archive --format=tar "$sha1") | 35 (cd "$dir" && tar x) || 36 return 1 37 38 for config in config.mak config.mak.autogen config.status 39 do 40 if test -e "$INTEROP_ROOT/../../$config" 41 then 42 cp "$INTEROP_ROOT/../../$config" "$dir/" || return 1 43 fi 44 done 45 46 ( 47 cd "$dir" && 48 make $2 $GIT_INTEROP_MAKE_OPTS >&2 && 49 touch .built 50 ) || return 1 51 52 echo "$dir" 53 } 54 55 # Old versions of git don't have bin-wrappers, so let's give a rough emulation. 56 wrap_git () { 57 write_script "$1" <<-EOF 58 GIT_EXEC_PATH="$2" 59 export GIT_EXEC_PATH 60 PATH="$2:\$PATH" 61 export GIT_EXEC_PATH 62 exec git "\$@" 63 EOF 64 } 65 66 generate_wrappers () { 67 mkdir -p .bin && 68 wrap_git .bin/git.a "$DIR_A" && 69 wrap_git .bin/git.b "$DIR_B" && 70 write_script .bin/git <<-\EOF && 71 echo >&2 fatal: test tried to run generic git: $* 72 exit 1 73 EOF 74 PATH=$(pwd)/.bin:$PATH 75 } 76 77 VERSION_A=${GIT_TEST_VERSION_A:-$VERSION_A} 78 VERSION_B=${GIT_TEST_VERSION_B:-$VERSION_B} 79 MAKE_OPTS_A=${GIT_INTEROP_MAKE_OPTS_A:-$MAKE_OPTS_A} 80 MAKE_OPTS_B=${GIT_INTEROP_MAKE_OPTS_B:-$MAKE_OPTS_B} 81 82 if ! DIR_A=$(build_version "$VERSION_A" "$MAKE_OPTS_A") || 83 ! DIR_B=$(build_version "$VERSION_B" "$MAKE_OPTS_B") 84 then 85 echo >&2 "fatal: unable to build git versions" 86 exit 1 87 fi 88 89 TEST_DIRECTORY=$INTEROP_ROOT/.. 90 TEST_OUTPUT_DIRECTORY=$INTEROP_ROOT 91 TEST_NO_CREATE_REPO=t 92 . "$TEST_DIRECTORY"/test-lib.sh 93 94 generate_wrappers || die "unable to set up interop test environment"