Merge pull request #1837 from git-for-windows/azure-pipelines

Set up CI with Azure Pipelines
This commit is contained in:
Jameson Miller
2018-09-24 16:57:30 -04:00
committed by Johannes Schindelin
56 changed files with 648 additions and 182 deletions

View File

@@ -1,3 +1,5 @@
[![Build Status](https:/dev.azure.com/git/git/_apis/build/status/test-git.git)](https://dev.azure.com/git/git/_build/latest?definitionId=2)
Git - fast, scalable, distributed revision control system
=========================================================

325
azure-pipelines.yml Normal file
View File

@@ -0,0 +1,325 @@
resources:
- repo: self
fetchDepth: 1
phases:
- phase: linux_clang
displayName: linux-clang
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev apache2-bin &&
export CC=clang || exit 1
ci/install-dependencies.sh
ci/run-build-and-tests.sh || {
ci/print-test-failures.sh
exit 1
}
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-build-and-tests.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'linux-clang'
platform: Linux
publishRunAttachments: false
condition: succeededOrFailed()
- phase: linux_gcc
displayName: linux-gcc
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev apache2-bin || exit 1
ci/install-dependencies.sh
ci/run-build-and-tests.sh || {
ci/print-test-failures.sh
exit 1
}
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-build-and-tests.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'linux-gcc'
platform: Linux
publishRunAttachments: false
condition: succeededOrFailed()
- phase: osx_clang
displayName: osx-clang
condition: succeeded()
queue:
name: Hosted macOS
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
export CC=clang
ci/install-dependencies.sh
ci/run-build-and-tests.sh || {
ci/print-test-failures.sh
exit 1
}
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-build-and-tests.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'osx-clang'
platform: macOS
publishRunAttachments: false
condition: succeededOrFailed()
- phase: osx_gcc
displayName: osx-gcc
condition: succeeded()
queue:
name: Hosted macOS
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
ci/install-dependencies.sh
ci/run-build-and-tests.sh || {
ci/print-test-failures.sh
exit 1
}
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-build-and-tests.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'osx-gcc'
platform: macOS
publishRunAttachments: false
condition: succeededOrFailed()
- phase: gettext_poison
displayName: GETTEXT_POISON
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev &&
export jobname=GETTEXT_POISON || exit 1
ci/run-build-and-tests.sh || {
ci/print-test-failures.sh
exit 1
}
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-build-and-tests.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'gettext-poison'
platform: Linux
publishRunAttachments: false
condition: succeededOrFailed()
- phase: windows
displayName: Windows
condition: succeeded()
queue:
name: Hosted
timeoutInMinutes: 240
steps:
- powershell: |
# Helper to check the error level of the latest command (exit with error when appropriate)
function c() { if (!$?) { exit(1) } }
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no; c
cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\; c
}
# Add build agent's MinGit to PATH
$env:PATH = $env:AGENT_HOMEDIRECTORY +"\externals\\git\cmd;" +$env:PATH
# Helper to initialize (or update) a Git worktree
function init ($path, $url, $set_origin) {
if (Test-Path $path) {
cd $path; c
if (Test-Path .git) {
git init; c
} else {
git status
}
} else {
git init $path; c
cd $path; c
}
git config core.autocrlf false; c
git config core.untrackedCache true; c
if (($set_origin -ne 0) -and !(git config remote.origin.url)) {
git remote add origin $url; c
}
git fetch --depth=1 $url master; c
git reset --hard FETCH_HEAD; c
git clean -df; c
}
# Initialize Git for Windows' SDK
$sdk_path = "$(Build.SourcesDirectory)\git-sdk-64"
init "$sdk_path" "https://dev.azure.com/git-for-windows/git-sdk-64/_git/git-sdk-64" 0
init usr\src\build-extra https://github.com/git-for-windows/build-extra 1
cd "$(Build.SourcesDirectory)"; c
$env:HOME = "$(Build.SourcesDirectory)"
$env:MSYSTEM = "MINGW64"
git-sdk-64\git-cmd --command=usr\\bin\\bash.exe -lc @"
. ci/lib.sh
make -j10 DEVELOPER=1 NO_PERL=1 || exit 1
NO_PERL=1 NO_SVN_TESTS=1 GIT_TEST_SKIP_REBASE_P=1 GIT_TEST_OPTS=\"--no-chain-lint --no-bin-wrappers --quiet --write-junit-xml\" time make -j15 -k DEVELOPER=1 test || {
NO_PERL=1 NO_SVN_TESTS=1 GIT_TEST_SKIP_REBASE_P=1 GIT_TEST_OPTS=\"-i -v -x\" make -k -C t failed; exit 1
}
save_good_tree
"@
c
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
}
displayName: 'build & test'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'windows'
platform: Windows
publishRunAttachments: false
condition: succeededOrFailed()
- phase: linux32
displayName: Linux32
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common &&
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable" &&
sudo apt-get update &&
sudo apt-get -y install docker-ce &&
sudo AGENT_OS="$AGENT_OS" BUILD_BUILDNUMBER="$BUILD_BUILDNUMBER" BUILD_REPOSITORY_URI="$BUILD_REPOSITORY_URI" BUILD_SOURCEBRANCH="$BUILD_SOURCEBRANCH" BUILD_SOURCEVERSION="$BUILD_SOURCEVERSION" SYSTEM_PHASENAME="$SYSTEM_PHASENAME" SYSTEM_TASKDEFINITIONSURI="$SYSTEM_TASKDEFINITIONSURI" SYSTEM_TEAMPROJECT="$SYSTEM_TEAMPROJECT" CC=$CC MAKEFLAGS=-j3 bash -lxc ci/run-linux32-docker.sh || exit 1
sudo chmod a+r t/out/TEST-*.xml
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-linux32-docker.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
mergeTestResults: true
testRunTitle: 'linux32'
platform: Linux
publishRunAttachments: false
condition: succeededOrFailed()
- phase: static_analysis
displayName: StaticAnalysis
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get install -y coccinelle &&
export jobname=StaticAnalysis &&
ci/run-static-analysis.sh || exit 1
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/run-static-analysis.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- phase: documentation
displayName: Documentation
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- bash: |
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
sudo apt-get update &&
sudo rm /var/lib/apt/lists/lock &&
sudo apt-get install -y asciidoc xmlto asciidoctor &&
export ALREADY_HAVE_ASCIIDOCTOR=yes. &&
export jobname=Documentation &&
ci/test-documentation.sh || exit 1
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
displayName: 'ci/test-documentation.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)

View File

@@ -3,7 +3,7 @@
# Install dependencies required to build and test Git on Linux and macOS
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
P4WHENCE=http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
@@ -37,7 +37,8 @@ osx-clang|osx-gcc)
brew update --quiet
# Uncomment this if you want to run perf tests:
# brew install gnu-time
brew install git-lfs gettext
test -z "$BREW_INSTALL_PACKAGES" ||
brew install $BREW_INSTALL_PACKAGES
brew link --force gettext
brew install caskroom/cask/perforce
;;

View File

@@ -1,5 +1,49 @@
# Library of functions shared by all CI scripts
if test true = "$TRAVIS"
then
# We are running within Travis CI
CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
CI_COMMIT="$TRAVIS_COMMIT"
CI_JOB_ID="$TRAVIS_JOB_ID"
CI_JOB_NUMBER="$TRAVIS_JOB_NUMBER"
CI_OS_NAME="$TRAVIS_OS_NAME"
CI_REPO_SLUG="$TRAVIS_REPO_SLUG"
cache_dir="$HOME/travis-cache"
url_for_job_id () {
echo "https://travis-ci.org/$CI_REPO_SLUG/jobs/$1"
}
BREW_INSTALL_PACKAGES="git-lfs gettext"
export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
export GIT_TEST_OPTS="--verbose-log -x --immediate"
elif test -n "$SYSTEM_TASKDEFINITIONSURI"
then
# We are running in Azure Pipelines
CI_BRANCH="$BUILD_SOURCEBRANCH"
CI_COMMIT="$BUILD_SOURCEVERSION"
CI_JOB_ID="$BUILD_BUILDID"
CI_JOB_NUMBER="$BUILD_BUILDNUMBER"
CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)"
test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
CC="${CC:-gcc}"
# use a subdirectory of the cache dir (because the file share is shared
# among *all* phases)
cache_dir="$HOME/test-cache/$SYSTEM_PHASENAME"
url_for_job_id () {
echo "$SYSTEM_TASKDEFINITIONSURI$SYSTEM_TEAMPROJECT/_build/results?buildId=$1"
}
BREW_INSTALL_PACKAGES=
export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
export GIT_TEST_OPTS="--quiet --write-junit-xml"
fi
skip_branch_tip_with_tag () {
# Sometimes, a branch is pushed at the same time the tag that points
# at the same commit as the tip of the branch is pushed, and building
@@ -13,10 +57,10 @@ skip_branch_tip_with_tag () {
# we can skip the build because we won't be skipping a build
# of a tag.
if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
test "$TAG" != "$TRAVIS_BRANCH"
if TAG=$(git describe --exact-match "$CI_BRANCH" 2>/dev/null) &&
test "$TAG" != "$CI_BRANCH"
then
echo "$(tput setaf 2)Tip of $TRAVIS_BRANCH is exactly at $TAG$(tput sgr0)"
echo "$(tput setaf 2)Tip of $CI_BRANCH is exactly at $TAG$(tput sgr0)"
exit 0
fi
}
@@ -25,7 +69,7 @@ skip_branch_tip_with_tag () {
# job if we encounter the same tree again and can provide a useful info
# message.
save_good_tree () {
echo "$(git rev-parse $TRAVIS_COMMIT^{tree}) $TRAVIS_COMMIT $TRAVIS_JOB_NUMBER $TRAVIS_JOB_ID" >>"$good_trees_file"
echo "$(git rev-parse $CI_COMMIT^{tree}) $CI_COMMIT $CI_JOB_NUMBER $CI_JOB_ID" >>"$good_trees_file"
# limit the file size
tail -1000 "$good_trees_file" >"$good_trees_file".tmp
mv "$good_trees_file".tmp "$good_trees_file"
@@ -35,7 +79,7 @@ save_good_tree () {
# successfully before (e.g. because the branch got rebased, changing only
# the commit messages).
skip_good_tree () {
if ! good_tree_info="$(grep "^$(git rev-parse $TRAVIS_COMMIT^{tree}) " "$good_trees_file")"
if ! good_tree_info="$(grep "^$(git rev-parse $CI_COMMIT^{tree}) " "$good_trees_file")"
then
# Haven't seen this tree yet, or no cached good trees file yet.
# Continue the build job.
@@ -45,18 +89,18 @@ skip_good_tree () {
echo "$good_tree_info" | {
read tree prev_good_commit prev_good_job_number prev_good_job_id
if test "$TRAVIS_JOB_ID" = "$prev_good_job_id"
if test "$CI_JOB_ID" = "$prev_good_job_id"
then
cat <<-EOF
$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
$(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
This commit has already been built and tested successfully by this build job.
To force a re-build delete the branch's cache and then hit 'Restart job'.
EOF
else
cat <<-EOF
$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
$(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
This commit's tree has already been built and tested successfully in build job $prev_good_job_number for commit $prev_good_commit.
The log of that build job is available at https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$prev_good_job_id
The log of that build job is available at $(url_for_job_id $prev_good_job_id)
To force a re-build delete the branch's cache and then hit 'Restart job'.
EOF
fi
@@ -81,7 +125,6 @@ check_unignored_build_artifacts ()
# and installing dependencies.
set -ex
cache_dir="$HOME/travis-cache"
good_trees_file="$cache_dir/good-trees"
mkdir -p "$cache_dir"
@@ -91,13 +134,11 @@ skip_good_tree
if test -z "$jobname"
then
jobname="$TRAVIS_OS_NAME-$CC"
jobname="$CI_OS_NAME-$CC"
fi
export DEVELOPER=1
export DEFAULT_TEST_TARGET=prove
export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
export GIT_TEST_OPTS="--verbose-log -x --immediate"
export GIT_TEST_CLONE_2GB=YesPlease
if [ "$jobname" = linux-gcc ]; then
export CC=gcc-8

26
ci/mount-fileshare.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
die () {
echo "$*" >&2
exit 1
}
test $# = 4 ||
die "Usage: $0 <share> <username> <password> <mountpoint"
mkdir -p "$4" || die "Could not create $4"
case "$(uname -s)" in
Linux)
sudo mount -t cifs -o vers=3.0,username="$2",password="$3",dir_mode=0777,file_mode=0777,serverino "$1" "$4"
;;
Darwin)
pass="$(echo "$3" | sed -e 's/\//%2F/g' -e 's/+/%2B/g')" &&
mount -t smbfs,soft "smb://$2:$pass@${1#//}" "$4"
;;
*)
die "No support for $(uname -s)"
;;
esac ||
die "Could not mount $4"

View File

@@ -3,7 +3,7 @@
# Print output of failing tests
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
# Tracing executed commands would produce too much noise in the loop below.
set +x
@@ -69,7 +69,7 @@ do
fi
done
if [ $combined_trash_size -gt 0 ]
if [ -n "$TRAVIS_JOB_ID" -a $combined_trash_size -gt 0 ]
then
echo "------------------------------------------------------------------------"
echo "Trash directories embedded in this log can be extracted by running:"

View File

@@ -3,7 +3,7 @@
# Build and test Git
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
ln -s "$cache_dir/.prove" t/.prove

View File

@@ -3,7 +3,7 @@
# Download and run Docker image to build and test 32-bit Git
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
docker pull daald/ubuntu32:xenial

View File

@@ -3,7 +3,7 @@
# Perform various static code analysis checks
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
make --jobs=2 coccicheck

View File

@@ -6,7 +6,7 @@
# supported) and a commit hash.
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
test $# -ne 2 && echo "Unexpected number of parameters" && exit 1
test -z "$GFW_CI_TOKEN" && echo "GFW_CI_TOKEN not defined" && exit

View File

@@ -3,8 +3,9 @@
# Perform sanity checks on documentation and build it.
#
. ${0%/*}/lib-travisci.sh
. ${0%/*}/lib.sh
test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
gem install asciidoctor
make check-builtins

1
t/.gitignore vendored
View File

@@ -2,3 +2,4 @@
/test-results
/.prove
/chainlinttmp
/out/

View File

@@ -170,6 +170,15 @@ appropriately before running "make".
implied by other options like --valgrind and
GIT_TEST_INSTALLED.
--no-bin-wrappers::
By default, the test suite uses the wrappers in
`../bin-wrappers/` to execute `git` and friends. With this option,
`../git` and friends are run directly. This is not recommended
in general, as the wrappers contain safeguards to ensure that no
files from an installed Git are used, but can speed up test runs
especially on platforms where running shell scripts is expensive
(most notably, Windows).
--root=<directory>::
Create "trash" directories used to store all temporary data during
testing under <directory>, instead of the t/ directory.

View File

@@ -7,6 +7,7 @@ static const char *usage_msg = "\n"
" test-tool date parse [date]...\n"
" test-tool date approxidate [date]...\n"
" test-tool date timestamp [date]...\n"
" test-tool date getnanos [start-nanos]\n"
" test-tool date is64bit\n"
" test-tool date time_t-is64bit\n";
@@ -82,6 +83,15 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now)
}
}
static void getnanos(const char **argv, struct timeval *now)
{
double seconds = getnanotime() / 1.0e9;
if (*argv)
seconds -= strtod(*argv, NULL);
printf("%lf\n", seconds);
}
int cmd__date(int argc, const char **argv)
{
struct timeval now;
@@ -108,6 +118,8 @@ int cmd__date(int argc, const char **argv)
parse_approxidate(argv+1, &now);
else if (!strcmp(*argv, "timestamp"))
parse_approx_timestamp(argv+1, &now);
else if (!strcmp(*argv, "getnanos"))
getnanos(argv+1, &now);
else if (!strcmp(*argv, "is64bit"))
return sizeof(timestamp_t) == 8 ? 0 : 1;
else if (!strcmp(*argv, "time_t-is64bit"))

View File

@@ -37,5 +37,4 @@ test_expect_success "fetch with $VERSION_B" '
test_cmp expect actual
'
stop_git_daemon
test_done

View File

@@ -13,7 +13,6 @@
#
# test_expect_success ...
#
# stop_git_daemon
# test_done
test_tristate GIT_TEST_GIT_DAEMON
@@ -43,7 +42,7 @@ start_git_daemon() {
mkdir -p "$GIT_DAEMON_DOCUMENT_ROOT_PATH"
trap 'code=$?; stop_git_daemon; (exit $code); die' EXIT
test_atexit 'stop_git_daemon'
say >&3 "Starting git daemon ..."
mkfifo git_daemon_output

View File

@@ -74,15 +74,6 @@ cli="$TRASH_DIRECTORY/cli"
git="$TRASH_DIRECTORY/git"
pidfile="$TRASH_DIRECTORY/p4d.pid"
# Sometimes "prove" seems to hang on exit because p4d is still running
cleanup () {
if test -f "$pidfile"
then
kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
fi
}
trap cleanup EXIT
# git p4 submit generates a temp file, which will
# not get cleaned up if the submission fails. Don't
# clutter up /tmp on the test machine.
@@ -141,6 +132,7 @@ start_p4d () {
# p4d failed to start
return 1
fi
test_atexit kill_p4d
# build a p4 user so author@example.com has an entry
p4_add_user author

View File

@@ -138,6 +138,7 @@ check_sub_test_lib_test_err () {
)
}
cat >/dev/null <<\DDD
test_expect_success 'pretend we have a fully passing test suite' "
run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF &&
for i in 1 2 3
@@ -824,6 +825,25 @@ test_expect_success 'tests clean up even on failures' "
> 1..2
EOF
"
DDD
test_expect_success 'test_atexit is run' "
test_must_fail run_sub_test_lib_test \
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
> ../../clean-atexit &&
test_atexit rm ../../clean-atexit &&
> ../../also-clean-atexit &&
test_atexit rm ../../also-clean-atexit &&
> ../../dont-clean-atexit &&
(exit 1)
'
test_done
EOF
test_path_exists dont-clean-atexit &&
test_path_is_missing clean-atexit &&
test_path_is_missing also-clean-atexit
"
test_expect_success 'test_oid setup' '
test_oid_init

View File

@@ -155,7 +155,8 @@ test_trace () {
expect="$1"
shift
GIT_TRACE=1 test-tool run-command "$@" run-command true 2>&1 >/dev/null | \
sed -e 's/.* run_command: //' -e '/trace: .*/d' >actual &&
sed -e 's/.* run_command: //' -e '/trace: .*/d' \
-e '/RUNTIME_PREFIX requested/d' >actual &&
echo "$expect true" >expect &&
test_cmp expect actual
}

View File

@@ -211,5 +211,4 @@ test_expect_success FAKENC 'hostname interpolation works after LF-stripping' '
test_cmp expect actual
'
stop_git_daemon
test_done

View File

@@ -326,8 +326,4 @@ test_expect_success 'submit from worktree' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -610,8 +610,4 @@ test_expect_success 'Update a file in git side and submit to P4 using client vie
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -333,8 +333,4 @@ test_expect_success SYMLINKS 'empty symlink target' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -105,8 +105,4 @@ test_expect_success 'branch with shell char' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -108,8 +108,4 @@ test_expect_failure 'two labels on the same changelist' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -98,8 +98,4 @@ test_expect_success 'no config, edited' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -300,9 +300,4 @@ test_expect_success 'use --git-dir option and GIT_DIR' '
test_path_is_file "$git"/cli_file2.t
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -542,8 +542,4 @@ test_expect_success 'submit --update-shelve' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -83,8 +83,4 @@ test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -836,8 +836,4 @@ test_expect_success 'quotes on both sides' '
git_verify "cdir 1/file11" "cdir 1/file12"
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -360,8 +360,4 @@ test_expect_failure 'Add keywords in git which do not match the default p4 value
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -259,9 +259,4 @@ test_expect_success 'importing labels with missing revisions' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -211,8 +211,4 @@ test_expect_success 'wildcard files requiring keyword scrub' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -138,8 +138,4 @@ test_expect_success 'not preserving user with mixed authorship' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -242,8 +242,4 @@ test_expect_success P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW \
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -422,8 +422,4 @@ test_expect_success 'cleanup chmod after submit cancel' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -138,8 +138,4 @@ test_expect_failure 'move with lock taken' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -64,8 +64,4 @@ test_expect_success 'clone, then sync with exclude' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -146,8 +146,4 @@ test_expect_success 'Clone repo with self-sizing block size' '
test_line_count \> 10 log
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -53,8 +53,4 @@ test_expect_failure 'Clone UC repo with lc name' '
test_must_fail git p4 clone //depot/uc/...
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -31,8 +31,4 @@ test_expect_success 'EDITOR with options' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -193,8 +193,4 @@ test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -67,8 +67,4 @@ test_expect_success 'Delete iso8859-1 encoded paths and clone' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -185,8 +185,4 @@ test_expect_success 'Run git p4 submit in repo configured with large file system
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -287,8 +287,4 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -43,8 +43,4 @@ test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
git p4 clone --dest="$git" //depot
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -127,8 +127,4 @@ test_expect_success 'Clone repo subdir with all history' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -59,8 +59,4 @@ test_expect_success SYMLINKS 'change symbolic link to file' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -54,8 +54,4 @@ test_expect_success 'Clone repo root path with all history' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -92,8 +92,4 @@ test_expect_success 'check log message of changelist with more jobs' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -36,8 +36,4 @@ test_expect_success 'symlinked directory' '
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -96,8 +96,4 @@ test_expect_success 'submit description with extra info lines from verbose p4 ch
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -174,8 +174,5 @@ test_expect_success 'unshelve specifying the origin' '
test_path_is_file file_to_shelve
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -72,9 +72,4 @@ test_expect_success 'git operation with expired ticket' '
)
'
test_expect_success 'kill p4d' '
kill_p4d
'
test_done

View File

@@ -927,6 +927,35 @@ test_when_finished () {
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
}
# This function can be used to schedule some commands to be run
# unconditionally at the end of the test script, e.g. to stop a daemon:
#
# test_expect_success 'test git daemon' '
# git daemon &
# daemon_pid=$! &&
# test_atexit "kill $daemon_pid" &&
# hello world
# '
test_atexit () {
# We cannot detect when we are in a subshell in general, but by
# doing so on Bash is better than nothing (the test will
# silently pass on other shells).
test "${BASH_SUBSHELL-0}" = 0 ||
error "bug in test script: test_atexit does nothing in a subshell"
test_atexit_cleanup="{ $*
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup"
}
test_atexit_handler () {
test : != "$test_atexit_cleanup" || return 0
setup_malloc_check
test_eval_ "$test_atexit_cleanup"
test_atexit_cleanup=:
teardown_malloc_check
}
# Most tests can use the created repository, but some may need to create more.
# Usage: test_create_repo <directory>
test_create_repo () {

View File

@@ -95,6 +95,13 @@ done,*)
test "$(cat "$BASE.exit")" = 0
exit
;;
*' --write-junit-xml '*)
# record how to call this script *with* --verbose-log, in case
# we encounter a breakage
junit_rerun_options_sq="$(printf '%s\n' "$0" --verbose-log -x "$@" |
sed -e "s/'/'\\\\''/g" -e "s/^/'/" -e "s/\$/'/" |
tr '\012' ' ')"
;;
esac
# For repeatability, reset the environment to known value.
@@ -294,6 +301,8 @@ do
test -z "$HARNESS_ACTIVE" && quiet=t; shift ;;
--with-dashes)
with_dashes=t; shift ;;
--no-bin-wrappers)
no_bin_wrappers=t; shift ;;
--no-color)
color=; shift ;;
--va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
@@ -339,6 +348,9 @@ do
-V|--verbose-log)
verbose_log=t
shift ;;
--write-junit-xml)
write_junit_xml=t
shift ;;
*)
echo "error: unknown test option '$1'" >&2; exit 1 ;;
esac
@@ -465,6 +477,7 @@ test_external_has_tap=0
die () {
code=$?
test_atexit_handler || code=$?
if test -n "$GIT_EXIT_OK"
then
exit $code
@@ -486,11 +499,48 @@ trap 'exit $?' INT
# the test_expect_* functions instead.
test_ok_ () {
if test -n "$write_junit_xml"
then
write_junit_xml_testcase "$*"
fi
test_success=$(($test_success + 1))
say_color "" "ok $test_count - $@"
}
test_failure_ () {
if test -n "$write_junit_xml"
then
if test -z "$GIT_TEST_TEE_OUTPUT_FILE"
then
# clean up
test_atexit_handler
# re-run with --verbose-log
echo "# Re-running: $junit_rerun_options_sq" >&2
cd "$TEST_DIRECTORY" &&
eval "${TEST_SHELL_PATH}" "$junit_rerun_options_sq" \
>/dev/null 2>&1
status=$?
say_color "" "$(test 0 = $status ||
echo "not ")ok $test_count - (re-ran with trace)"
say "1..$test_count"
GIT_EXIT_OK=t
exit $status
fi
junit_insert="<failure message=\"not ok $test_count -"
junit_insert="$junit_insert $(xml_attr_encode "$1")\">"
junit_insert="$junit_insert $(xml_attr_encode \
"$(cat "$GIT_TEST_TEE_OUTPUT_FILE")")"
>"$GIT_TEST_TEE_OUTPUT_FILE"
junit_insert="$junit_insert</failure>"
junit_insert="$junit_insert<system-err>$(xml_attr_encode \
"$(cat "$GIT_TEST_TEE_OUTPUT_FILE.err")")</system-err>"
>"$GIT_TEST_TEE_OUTPUT_FILE.err"
write_junit_xml_testcase "$1" " $junit_insert"
fi
test_failure=$(($test_failure + 1))
say_color error "not ok $test_count - $1"
shift
@@ -499,11 +549,19 @@ test_failure_ () {
}
test_known_broken_ok_ () {
if test -n "$write_junit_xml"
then
write_junit_xml_testcase "$* (breakage fixed)"
fi
test_fixed=$(($test_fixed+1))
say_color error "ok $test_count - $@ # TODO known breakage vanished"
}
test_known_broken_failure_ () {
if test -n "$write_junit_xml"
then
write_junit_xml_testcase "$* (known breakage)"
fi
test_broken=$(($test_broken+1))
say_color warn "not ok $test_count - $@ # TODO known breakage"
}
@@ -761,6 +819,17 @@ test_start_ () {
test_count=$(($test_count+1))
maybe_setup_verbose
maybe_setup_valgrind
if test -n "$write_junit_xml"
then
junit_start=$(test-tool date getnanos)
# append to future <system-err>; truncate output
test -z "$GIT_TEST_TEE_OUTPUT_FILE" || {
cat "$GIT_TEST_TEE_OUTPUT_FILE" \
>>"$GIT_TEST_TEE_OUTPUT_FILE.err"
>"$GIT_TEST_TEE_OUTPUT_FILE"
}
fi
}
test_finish_ () {
@@ -798,6 +867,13 @@ test_skip () {
case "$to_skip" in
t)
if test -n "$write_junit_xml"
then
message="$(xml_attr_encode "$skipped_reason")"
write_junit_xml_testcase "$1" \
" <skipped message=\"$message\" />"
fi
say_color skip >&3 "skipping test: $@"
say_color skip "ok $test_count # skip $1 ($skipped_reason)"
: true
@@ -813,9 +889,61 @@ test_at_end_hook_ () {
:
}
write_junit_xml () {
case "$1" in
--truncate)
>"$junit_xml_path"
junit_have_testcase=
shift
;;
esac
printf '%s\n' "$@" >>"$junit_xml_path"
}
xml_attr_encode () {
# We do not translate CR to &#x0d; because BSD sed does not handle
# \r in the regex. In practice, the output should not even have any
# carriage returns.
printf '%s\n' "$@" |
sed -e 's/&/\&amp;/g' -e "s/'/\&apos;/g" -e 's/"/\&quot;/g' \
-e 's/</\&lt;/g' -e 's/>/\&gt;/g' \
-e 's/ /\&#x09;/g' -e 's/$/\&#x0a;/' -e '$s/&#x0a;$//' |
tr -d '\012\015'
}
write_junit_xml_testcase () {
junit_attrs="name=\"$(xml_attr_encode "$this_test.$test_count $1")\""
shift
junit_attrs="$junit_attrs classname=\"$this_test\""
junit_attrs="$junit_attrs time=\"$(test-tool \
date getnanos $junit_start)\""
write_junit_xml "$(printf '%s\n' \
" <testcase $junit_attrs>" "$@" " </testcase>")"
junit_have_testcase=t
}
test_atexit_cleanup=:
test_done () {
GIT_EXIT_OK=t
test -n "$immediate" || test_atexit_handler
if test -n "$write_junit_xml" && test -n "$junit_xml_path"
then
test -n "$junit_have_testcase" || {
junit_start=$(test-tool date getnanos)
write_junit_xml_testcase "all tests skipped"
}
# adjust the overall time
junit_time=$(test-tool date getnanos $junit_suite_start)
sed "s/<testsuite [^>]*/& time=\"$junit_time\"/" \
<"$junit_xml_path" >"$junit_xml_path.new"
mv "$junit_xml_path.new" "$junit_xml_path"
write_junit_xml " </testsuite>" "</testsuites>"
fi
if test -z "$HARNESS_ACTIVE"
then
test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
@@ -984,20 +1112,25 @@ then
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
else # normal case, use ../bin-wrappers only unless $with_dashes:
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
if ! test -x "$git_bin_dir/git"
if test -n "$no_bin_wrappers"
then
if test -z "$with_dashes"
then
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
fi
with_dashes=t
else
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
if ! test -x "$git_bin_dir/git"
then
if test -z "$with_dashes"
then
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
fi
with_dashes=t
fi
PATH="$git_bin_dir:$PATH"
fi
PATH="$git_bin_dir:$PATH"
GIT_EXEC_PATH=$GIT_BUILD_DIR
if test -n "$with_dashes"
then
PATH="$GIT_BUILD_DIR:$PATH"
PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"
fi
fi
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
@@ -1051,6 +1184,7 @@ then
else
mkdir -p "$TRASH_DIRECTORY"
fi
# Use -P to resolve symlinks in our working directory so that the cwd
# in subprocesses like git equals our $PWD (for pathname comparisons).
cd -P "$TRASH_DIRECTORY" || exit 1
@@ -1064,6 +1198,19 @@ then
test_done
fi
if test -n "$write_junit_xml"
then
junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"
mkdir -p "$junit_xml_dir"
junit_xml_base=${0##*/}
junit_xml_path="$junit_xml_dir/TEST-${junit_xml_base%.sh}.xml"
junit_attrs="name=\"${junit_xml_base%.sh}\""
junit_attrs="$junit_attrs timestamp=\"$(TZ=UTC \
date +%Y-%m-%dT%H:%M:%S)\""
write_junit_xml --truncate "<testsuites>" " <testsuite $junit_attrs>"
junit_suite_start=$(test-tool date getnanos)
fi
# Provide an implementation of the 'yes' utility
yes () {
if test $# = 0