commit f6592003af9cd04c23a4990f6194b62532570ec8 from: Stefan Sperling date: Wed Apr 17 16:36:53 2024 UTC add a basic regression test for 'got clone' over HTTP commit - 18c37abb9e744da66fee2a2417d0ee132d05aed7 commit + f6592003af9cd04c23a4990f6194b62532570ec8 blob - a628193de0dbc52a980b83ef2f3fd49071ce4605 blob + eec407df5b695539c76de24f3f2392b433fbf1a3 --- regress/cmdline/clone.sh +++ regress/cmdline/clone.sh @@ -861,7 +861,137 @@ EOF fi test_done "$testroot" "$ret" } + +test_clone_basic_http() { + local testroot=`test_init clone_basic_http` + local testurl=http://127.0.0.1:${GOT_TEST_HTTP_PORT} + local commit_id=`git_show_head $testroot/repo` + + timeout 5 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \ + > $testroot/http-server.log & + + sleep 1 # server starts up + + # Test our custom HTTP server with git clone. Should succeed. + git clone -q $testurl/repo $testroot/repo-clone-with-git + ret=$? + if [ $ret -ne 0 ]; then + echo "git clone command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + # Test got clone with our custom HTTP server. + got clone -q $testurl/repo $testroot/repo-clone + ret=$? + if [ $ret -ne 0 ]; then + echo "got clone command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + + kill %1 + wait %1 # wait for http-server + + got log -l0 -p -r $testroot/repo > $testroot/log-repo + ret=$? + if [ $ret -ne 0 ]; then + echo "got log command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + got log -l0 -p -r $testroot/repo-clone | \ + sed 's@master, origin/master@master@g' \ + > $testroot/log-repo-clone + + cmp -s $testroot/log-repo $testroot/log-repo-clone + ret=$? + if [ $ret -ne 0 ]; then + echo "log -p output of cloned repository differs" >&2 + test_done "$testroot" "$ret" + return 1 + fi + + got ref -l -r $testroot/repo > $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + echo "got ref command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + + echo "HEAD: refs/heads/master" > $testroot/stdout.expected + echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected + + cmp -s $testroot/stdout $testroot/stdout.expected + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + got ref -l -r $testroot/repo-clone > $testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + echo "got ref command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + + echo "HEAD: refs/heads/master" > $testroot/stdout.expected + echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected + echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \ + >> $testroot/stdout.expected + echo "refs/remotes/origin/master: $commit_id" \ + >> $testroot/stdout.expected + + cmp -s $testroot/stdout $testroot/stdout.expected + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + + cat > $testroot/got.conf.expected < $testroot/config.expected <