# Shell library to run an HTTP server for use in tests. # Ends the test early if httpd tests should not be run, # for example because the user has not enabled them. # # Usage: # # . ./test-lib.sh # . "$TEST_DIRECTORY"/lib-httpd.sh # start_httpd # # test_expect_success '...' ' # ... # ' # # test_expect_success ... # # stop_httpd # test_done # # Can be configured using the following variables. # # GIT_TEST_HTTPD enable HTTPD tests # LIB_HTTPD_PATH web server path # LIB_HTTPD_MODULE_PATH web server modules path # LIB_HTTPD_PORT listening port # LIB_HTTPD_DAV enable DAV # LIB_HTTPD_SVN enable SVN at given location (e.g. "svn") # LIB_HTTPD_SSL enable SSL # # Copyright (c) 2008 Clemens Buchacher # if test -n $NO_CURL { global skip_all := ''skipping test, git built without http support'' test_done } if test -n $NO_EXPAT && test -n $LIB_HTTPD_DAV { global skip_all := ''skipping test, git built without expat support'' test_done } test_tristate GIT_TEST_HTTPD if test $GIT_TEST_HTTPD = false { global skip_all := '"Network testing disabled (unset GIT_TEST_HTTPD to enable)'" test_done } if ! test_have_prereq NOT_ROOT { test_skip_or_die $GIT_TEST_HTTPD \ "Cannot run httpd tests as root" } global HTTPD_PARA := ''"" for DEFAULT_HTTPD_PATH in ['/usr/sbin/httpd' '/usr/sbin/apache2]' { if test -x $DEFAULT_HTTPD_PATH { break } } for DEFAULT_HTTPD_MODULE_PATH in ['/usr/libexec/apache2' \ '/usr/lib/apache2/modules' \ '/usr/lib64/httpd/modules' \ '/usr/lib/httpd/modules]' { if test -d $DEFAULT_HTTPD_MODULE_PATH { break } } matchstr $[uname] { Darwin { global HTTPD_PARA := ""$HTTPD_PARA -DDarwin"" } } global LIB_HTTPD_PATH := $(LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH") global LIB_HTTPD_PORT := $(LIB_HTTPD_PORT-${this_test#t}) global TEST_PATH := ""$TEST_DIRECTORY"/lib-httpd" global HTTPD_ROOT_PATH := ""$PWD"/httpd" global HTTPD_DOCUMENT_ROOT_PATH := "$HTTPD_ROOT_PATH/www" # hack to suppress apache PassEnv warnings global GIT_VALGRIND := $GIT_VALGRIND; export GIT_VALGRIND global GIT_VALGRIND_OPTIONS := $GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS global GIT_TRACE := $GIT_TRACE; export GIT_TRACE if ! test -x $LIB_HTTPD_PATH { test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'" } global HTTPD_VERSION := $[$LIB_HTTPD_PATH -v | \ sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q] if test -n $HTTPD_VERSION { if test -z $LIB_HTTPD_MODULE_PATH { if ! test $HTTPD_VERSION -ge 2 { test_skip_or_die $GIT_TEST_HTTPD \ "at least Apache version 2 is required" } if ! test -d $DEFAULT_HTTPD_MODULE_PATH { test_skip_or_die $GIT_TEST_HTTPD \ "Apache module directory not found" } global LIB_HTTPD_MODULE_PATH := $DEFAULT_HTTPD_MODULE_PATH } } else { test_skip_or_die $GIT_TEST_HTTPD \ "Could not identify web server at '$LIB_HTTPD_PATH'" } proc install_script { write_script "$HTTPD_ROOT_PATH/$1" <"$TEST_PATH/$1" } proc prepare_httpd { mkdir -p $HTTPD_DOCUMENT_ROOT_PATH cp "$TEST_PATH"/passwd $HTTPD_ROOT_PATH install_script broken-smart-http.sh install_script error.sh ln -s $LIB_HTTPD_MODULE_PATH "$HTTPD_ROOT_PATH/modules" if test -n $LIB_HTTPD_SSL { global HTTPD_PROTO := 'https' env RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \ -config "$TEST_PATH/ssl.cnf" \ -new -x509 -nodes \ -out "$HTTPD_ROOT_PATH/httpd.pem" \ -keyout "$HTTPD_ROOT_PATH/httpd.pem" global GIT_SSL_NO_VERIFY := 't' export GIT_SSL_NO_VERIFY global HTTPD_PARA := ""$HTTPD_PARA -DSSL"" } else { global HTTPD_PROTO := 'http' } global HTTPD_DEST := "127.0.0.1:$LIB_HTTPD_PORT" global HTTPD_URL := "$HTTPD_PROTO://$HTTPD_DEST" global HTTPD_URL_USER := "$HTTPD_PROTO://user%40host@$HTTPD_DEST" global HTTPD_URL_USER_PASS := "$HTTPD_PROTO://user%40host:pass%40host@$HTTPD_DEST" if test -n $LIB_HTTPD_DAV || test -n $LIB_HTTPD_SVN { global HTTPD_PARA := ""$HTTPD_PARA -DDAV"" if test -n $LIB_HTTPD_SVN { global HTTPD_PARA := ""$HTTPD_PARA -DSVN"" global LIB_HTTPD_SVNPATH := $rawsvnrepo global svnrepo := ""http://127.0.0.1:$LIB_HTTPD_PORT/"" global svnrepo := ""$svnrepo$LIB_HTTPD_SVN"" export LIB_HTTPD_SVN LIB_HTTPD_SVNPATH } } } proc start_httpd { prepare_httpd > !3 !2 > !4 trap 'code=$?; stop_httpd; (exit $code); die' EXIT $LIB_HTTPD_PATH -d $HTTPD_ROOT_PATH \ -f "$TEST_PATH/apache.conf" $HTTPD_PARA \ -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \ > !3 !2 > !4 if test $Status -ne 0 { trap 'die' EXIT cat "$HTTPD_ROOT_PATH"/error.log > !4 !2 >/dev/null test_skip_or_die $GIT_TEST_HTTPD "web server setup failed" } } proc stop_httpd { trap 'die' EXIT $LIB_HTTPD_PATH -d $HTTPD_ROOT_PATH \ -f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop } proc test_http_push_nonff { global REMOTE_REPO := $1 global LOCAL_REPO := $2 global BRANCH := $3 global EXPECT_CAS_RESULT := $(4-failure) test_expect_success 'non-fast-forward push fails' ' cd "$REMOTE_REPO" && HEAD=$(git rev-parse --verify HEAD) && cd "$LOCAL_REPO" && git checkout $BRANCH && echo "changed" > path2 && git commit -a -m path2 --amend && test_must_fail git push -v origin >output 2>&1 && (cd "$REMOTE_REPO" && test $HEAD = $(git rev-parse --verify HEAD)) ' test_expect_success 'non-fast-forward push show ref status' ' grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output ' test_expect_success 'non-fast-forward push shows help message' ' test_i18ngrep "Updates were rejected because" output ' test_expect_$(EXPECT_CAS_RESULT) 'force with lease aka cas' ' HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) && test_when_finished ''''' (cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD") ''''' && ( cd "$LOCAL_REPO" && git push -v --force-with-lease=$BRANCH:$HEAD origin ) && git rev-parse --verify "$BRANCH" >expect && ( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) >actual && test_cmp expect actual ' } proc setup_askpass_helper { test_expect_success 'setup askpass helper' ' write_script "$TRASH_DIRECTORY/askpass" <<-\EOF && echo >>"$TRASH_DIRECTORY/askpass-query" "askpass: $*" && case "$*" in *Username*) what=user ;; *Password*) what=pass ;; esac && cat "$TRASH_DIRECTORY/askpass-$what" EOF GIT_ASKPASS="$TRASH_DIRECTORY/askpass" && export GIT_ASKPASS && export TRASH_DIRECTORY ' } proc set_askpass { >"$TRASH_DIRECTORY/askpass-query" && echo $1 >"$TRASH_DIRECTORY/askpass-user" && echo $2 >"$TRASH_DIRECTORY/askpass-pass" } proc expect_askpass { global dest := "$HTTPD_DEST$(3+/$3)" do { matchstr $1 { none { } pass { echo "askpass: Password for 'http://$2@$dest': " } both { echo "askpass: Username for 'http://$dest': " echo "askpass: Password for 'http://$2@$dest': " } * { false } } } >"$TRASH_DIRECTORY/askpass-expect" && test_cmp "$TRASH_DIRECTORY/askpass-expect" \ "$TRASH_DIRECTORY/askpass-query" } (CommandList children: [ (If arms: [ (if_arm cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Name "$NO_CURL"))})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skip_all) op: Equal rhs: {(SQ <"skipping test, git built without http support">)} spids: [107] ) ] spids: [107] ) (C {(test_done)}) ] spids: [-1 104] ) ] spids: [-1 115] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test)} {(-n)} {(DQ ($ VSub_Name "$NO_EXPAT"))}) (C {(test)} {(-n)} {(DQ ($ VSub_Name "$LIB_HTTPD_DAV"))}) ] op_id: Op_DAmp ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skip_all) op: Equal rhs: {(SQ <"skipping test, git built without expat support">)} spids: [141] ) ] spids: [141] ) (C {(test_done)}) ] spids: [-1 138] ) ] spids: [-1 149] ) (C {(test_tristate)} {(GIT_TEST_HTTPD)}) (If arms: [ (if_arm cond: [(C {(test)} {(DQ ($ VSub_Name "$GIT_TEST_HTTPD"))} {(Lit_Other "=")} {(false)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skip_all) op: Equal rhs: {(DQ ("Network testing disabled (unset GIT_TEST_HTTPD to enable)"))} spids: [171] ) ] spids: [171] ) (C {(test_done)}) ] spids: [-1 168] ) ] spids: [-1 179] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(test_have_prereq)} {(NOT_ROOT)})] negated:True) terminator: ) ] action: [ (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("Cannot run httpd tests as root"))} ) ] spids: [-1 191] ) ] spids: [-1 204] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:HTTPD_PARA) op:Equal rhs:{(DQ )} spids:[207])] spids: [207] ) (ForEach iter_name: DEFAULT_HTTPD_PATH iter_words: [{(SQ )} {(SQ )}] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [(C {(test)} {(-x)} {(DQ ($ VSub_Name "$DEFAULT_HTTPD_PATH"))})] action: [(ControlFlow token:)] spids: [-1 240] ) ] spids: [-1 246] ) ] spids: [226 248] ) spids: [217 -1] ) (ForEach iter_name: DEFAULT_HTTPD_MODULE_PATH iter_words: [ {(SQ )} {(SQ )} {(SQ )} {(SQ )} ] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [(C {(test)} {(-d)} {(DQ ($ VSub_Name "$DEFAULT_HTTPD_MODULE_PATH"))})] action: [(ControlFlow token:)] spids: [-1 293] ) ] spids: [-1 299] ) ] spids: [279 301] ) spids: [256 -1] ) (Case to_match: { (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [306 308] ) } arms: [ (case_arm pat_list: [{(Darwin)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PARA) op: Equal rhs: {(DQ ($ VSub_Name "$HTTPD_PARA") (" -DDarwin"))} spids: [317] ) ] spids: [317] ) ] spids: [313 314 324 -1] ) ] spids: [304 310 326] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIB_HTTPD_PATH) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_Hyphen arg_word: {(DQ ($ VSub_Name "$DEFAULT_HTTPD_PATH"))} ) spids: [330 336] ) } spids: [329] ) ] spids: [329] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIB_HTTPD_PORT) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_Hyphen arg_word: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_Pound arg_word:{(t)}) spids: [342 346] ) } ) spids: [339 347] ) } spids: [338] ) ] spids: [338] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TEST_PATH) op: Equal rhs: {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-httpd)} spids: [350] ) ] spids: [350] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_ROOT_PATH) op: Equal rhs: {(DQ ($ VSub_Name "$PWD")) (/httpd)} spids: [356] ) ] spids: [356] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_DOCUMENT_ROOT_PATH) op: Equal rhs: {($ VSub_Name "$HTTPD_ROOT_PATH") (/www)} spids: [362] ) ] spids: [362] ) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_VALGRIND) op: Equal rhs: {($ VSub_Name "$GIT_VALGRIND")} spids: [370] ) ] spids: [370] ) terminator: ) (C {(export)} {(GIT_VALGRIND)}) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_VALGRIND_OPTIONS) op: Equal rhs: {($ VSub_Name "$GIT_VALGRIND_OPTIONS")} spids: [378] ) ] spids: [378] ) terminator: ) (C {(export)} {(GIT_VALGRIND_OPTIONS)}) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_TRACE) op: Equal rhs: {($ VSub_Name "$GIT_TRACE")} spids: [386] ) ] spids: [386] ) terminator: ) (C {(export)} {(GIT_TRACE)}) (If arms: [ (if_arm cond: [ (Pipeline children: [(C {(test)} {(-x)} {(DQ ($ VSub_Name "$LIB_HTTPD_PATH"))})] negated: True ) ] action: [ (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("no web server found at '") ($ VSub_Name "$LIB_HTTPD_PATH") ("'"))} ) ] spids: [-1 407] ) ] spids: [-1 420] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_VERSION) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {($ VSub_Name "$LIB_HTTPD_PATH")} {(-v)}) (C {(sed)} {(-n)} {(SQ <"s/^Server version: Apache\\/\\([0-9]*\\)\\..*$/\\1/p; q">)} ) ] negated: False ) ] ) left_token: spids: [424 440] ) } spids: [423] ) ] spids: [423] ) (If arms: [ (if_arm cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Name "$HTTPD_VERSION"))})] action: [ (If arms: [ (if_arm cond: [(C {(test)} {(-z)} {(DQ ($ VSub_Name "$LIB_HTTPD_MODULE_PATH"))})] action: [ (If arms: [ (if_arm cond: [ (Pipeline children: [(C {(test)} {($ VSub_Name "$HTTPD_VERSION")} {(-ge)} {(2)})] negated: True ) ] action: [ (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("at least Apache version 2 is required"))} ) ] spids: [-1 483] ) ] spids: [-1 497] ) (If arms: [ (if_arm cond: [ (Pipeline children: [ (C {(test)} {(-d)} {(DQ ($ VSub_Name "$DEFAULT_HTTPD_MODULE_PATH"))}) ] negated: True ) ] action: [ (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("Apache module directory not found"))} ) ] spids: [-1 513] ) ] spids: [-1 527] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIB_HTTPD_MODULE_PATH) op: Equal rhs: {(DQ ($ VSub_Name "$DEFAULT_HTTPD_MODULE_PATH"))} spids: [531] ) ] spids: [531] ) ] spids: [-1 467] ) ] spids: [-1 537] ) ] spids: [-1 453] ) ] else_action: [ (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("Could not identify web server at '") ($ VSub_Name "$LIB_HTTPD_PATH") ("'"))} ) ] spids: [539 554] ) (FuncDef name: install_script body: (BraceGroup children: [ (SimpleCommand words: [{(write_script)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH") (/) ($ VSub_Number "$1"))}] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(DQ ($ VSub_Name "$TEST_PATH") (/) ($ VSub_Number "$1"))} spids: [573] ) ] ) ] spids: [562] ) spids: [557 561] ) (FuncDef name: prepare_httpd body: (BraceGroup children: [ (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name "$HTTPD_DOCUMENT_ROOT_PATH"))}) (C {(cp)} {(DQ ($ VSub_Name "$TEST_PATH")) (/passwd)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH"))}) (C {(install_script)} {(broken-smart-http.sh)}) (C {(install_script)} {(error.sh)}) (C {(ln)} {(-s)} {(DQ ($ VSub_Name "$LIB_HTTPD_MODULE_PATH"))} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH") (/modules))} ) (If arms: [ (if_arm cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Name "$LIB_HTTPD_SSL"))})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PROTO) op: Equal rhs: {(https)} spids: [651] ) ] spids: [651] ) (SimpleCommand words: [ {(openssl)} {(req)} {(-config)} {(DQ ($ VSub_Name "$TEST_PATH") (/ssl.cnf))} {(-new)} {(-x509)} {(-nodes)} {(-out)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH") (/httpd.pem))} {(-keyout)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH") (/httpd.pem))} ] more_env: [ (env_pair name: RANDFILE_PATH val: {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH")) (/.rnd)} spids: [656] ) ] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:GIT_SSL_NO_VERIFY) op: Equal rhs: {(t)} spids: [702] ) ] spids: [702] ) (C {(export)} {(GIT_SSL_NO_VERIFY)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PARA) op: Equal rhs: {(DQ ($ VSub_Name "$HTTPD_PARA") (" -DSSL"))} spids: [711] ) ] spids: [711] ) ] spids: [-1 648] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PROTO) op: Equal rhs: {(http)} spids: [721] ) ] spids: [721] ) ] spids: [718 725] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_DEST) op: Equal rhs: {(127.0.0.1) (Lit_Other ":") ($ VSub_Name "$LIB_HTTPD_PORT")} spids: [728] ) ] spids: [728] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_URL) op: Equal rhs: {($ VSub_Name "$HTTPD_PROTO") (Lit_Other ":") (//) ($ VSub_Name "$HTTPD_DEST")} spids: [734] ) ] spids: [734] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_URL_USER) op: Equal rhs: {($ VSub_Name "$HTTPD_PROTO") (Lit_Other ":") (//user) (Lit_Other "%") (40host) (Lit_Other "@") ($ VSub_Name "$HTTPD_DEST") } spids: [741] ) ] spids: [741] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_URL_USER_PASS) op: Equal rhs: {($ VSub_Name "$HTTPD_PROTO") (Lit_Other ":") (//user) (Lit_Other "%") (40host) (Lit_Other ":") (pass) (Lit_Other "%") (40host) (Lit_Other "@") ($ VSub_Name "$HTTPD_DEST") } spids: [751] ) ] spids: [751] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test)} {(-n)} {(DQ ($ VSub_Name "$LIB_HTTPD_DAV"))}) (C {(test)} {(-n)} {(DQ ($ VSub_Name "$LIB_HTTPD_SVN"))}) ] op_id: Op_DPipe ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PARA) op: Equal rhs: {(DQ ($ VSub_Name "$HTTPD_PARA") (" -DDAV"))} spids: [790] ) ] spids: [790] ) (If arms: [ (if_arm cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Name "$LIB_HTTPD_SVN"))})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HTTPD_PARA) op: Equal rhs: {(DQ ($ VSub_Name "$HTTPD_PARA") (" -DSVN"))} spids: [812] ) ] spids: [812] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIB_HTTPD_SVNPATH) op: Equal rhs: {(DQ ($ VSub_Name "$rawsvnrepo"))} spids: [819] ) ] spids: [819] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:svnrepo) op: Equal rhs: {(DQ ("http://127.0.0.1:") ($ VSub_Name "$LIB_HTTPD_PORT") (/))} spids: [825] ) ] spids: [825] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:svnrepo) op: Equal rhs: {(DQ ($ VSub_Name "$svnrepo") ($ VSub_Name "$LIB_HTTPD_SVN"))} spids: [833] ) ] spids: [833] ) (C {(export)} {(LIB_HTTPD_SVN)} {(LIB_HTTPD_SVNPATH)}) ] spids: [-1 809] ) ] spids: [-1 847] ) ] spids: [-1 787] ) ] spids: [-1 850] ) ] spids: [587] ) spids: [583 586] ) (FuncDef name: start_httpd body: (BraceGroup children: [ (SimpleCommand words: [{(prepare_httpd)}] redirects: [ (Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(3)} spids:[864]) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(4)} spids:[867]) ] ) (C {(trap)} {(SQ <"code=$?; stop_httpd; (exit $code); die">)} {(EXIT)}) (SimpleCommand words: [ {(DQ ($ VSub_Name "$LIB_HTTPD_PATH"))} {(-d)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH"))} {(-f)} {(DQ ($ VSub_Name "$TEST_PATH") (/apache.conf))} {($ VSub_Name "$HTTPD_PARA")} {(-c)} {(DQ ("Listen 127.0.0.1:") ($ VSub_Name "$LIB_HTTPD_PORT"))} {(-k)} {(start)} ] redirects: [ (Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(3)} spids:[918]) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(4)} spids:[921]) ] ) (If arms: [ (if_arm cond: [(C {(test)} {($ VSub_QMark "$?")} {(-ne)} {(0)})] action: [ (C {(trap)} {(SQ )} {(EXIT)}) (SimpleCommand words: [{(cat)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH")) (/error.log)}] redirects: [ (Redir op_id: Redir_GreatAnd fd: -1 arg_word: {(4)} spids: [955] ) (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [958] ) ] ) (C {(test_skip_or_die)} {($ VSub_Name "$GIT_TEST_HTTPD")} {(DQ ("web server setup failed"))} ) ] spids: [-1 936] ) ] spids: [-1 971] ) ] spids: [859] ) spids: [855 858] ) (FuncDef name: stop_httpd body: (BraceGroup children: [ (C {(trap)} {(SQ )} {(EXIT)}) (C {(DQ ($ VSub_Name "$LIB_HTTPD_PATH"))} {(-d)} {(DQ ($ VSub_Name "$HTTPD_ROOT_PATH"))} {(-f)} {(DQ ($ VSub_Name "$TEST_PATH") (/apache.conf))} {($ VSub_Name "$HTTPD_PARA")} {(-k)} {(stop)} ) ] spids: [980] ) spids: [976 979] ) (FuncDef name: test_http_push_nonff body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:REMOTE_REPO) op: Equal rhs: {($ VSub_Number "$1")} spids: [1029] ) ] spids: [1029] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LOCAL_REPO) op: Equal rhs: {($ VSub_Number "$2")} spids: [1033] ) ] spids: [1033] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BRANCH) op: Equal rhs: {($ VSub_Number "$3")} spids: [1037] ) ] spids: [1037] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:EXPECT_CAS_RESULT) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_Hyphen arg_word:{(failure)}) spids: [1042 1046] ) } spids: [1041] ) ] spids: [1041] ) (C {(test_expect_success)} {(SQ <"non-fast-forward push fails">)} { (SQ <"\n"> <"\t\tcd \"$REMOTE_REPO\" &&\n"> <"\t\tHEAD=$(git rev-parse --verify HEAD) &&\n"> <"\n"> <"\t\tcd \"$LOCAL_REPO\" &&\n"> <"\t\tgit checkout $BRANCH &&\n"> <"\t\techo \"changed\" > path2 &&\n"> <"\t\tgit commit -a -m path2 --amend &&\n"> <"\n"> <"\t\ttest_must_fail git push -v origin >output 2>&1 &&\n"> <"\t\t(cd \"$REMOTE_REPO\" &&\n"> <"\t\t test $HEAD = $(git rev-parse --verify HEAD))\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"non-fast-forward push show ref status">)} { (SQ <"\n"> < "\t\tgrep \"^ ! \\[rejected\\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$\" output\n" > <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"non-fast-forward push shows help message">)} {(SQ <"\n"> <"\t\ttest_i18ngrep \"Updates were rejected because\" output\n"> <"\t">)} ) (C {(test_expect_) (${ VSub_Name EXPECT_CAS_RESULT)} {(SQ <"force with lease aka cas">)} { (SQ <"\n"> <"\t\tHEAD=$(\tcd \"$REMOTE_REPO\" && git rev-parse --verify HEAD ) &&\n"> <"\t\ttest_when_finished "> ) (EscapedLiteralPart token:) (SQ <"\n"> <"\t\t\t(cd \"$REMOTE_REPO\" && git update-ref HEAD \"$HEAD\")\n"> <"\t\t">) (EscapedLiteralPart token:) (SQ <" &&\n"> <"\t\t(\n"> <"\t\t\tcd \"$LOCAL_REPO\" &&\n"> <"\t\t\tgit push -v --force-with-lease=$BRANCH:$HEAD origin\n"> <"\t\t) &&\n"> <"\t\tgit rev-parse --verify \"$BRANCH\" >expect &&\n"> <"\t\t(\n"> <"\t\t\tcd \"$REMOTE_REPO\" && git rev-parse --verify HEAD\n"> <"\t\t) >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t"> ) } ) ] spids: [1026] ) spids: [1021 1025] ) (FuncDef name: setup_askpass_helper body: (BraceGroup children: [ (C {(test_expect_success)} {(SQ <"setup askpass helper">)} { (SQ <"\n"> <"\t\twrite_script \"$TRASH_DIRECTORY/askpass\" <<-\\EOF &&\n"> <"\t\techo >>\"$TRASH_DIRECTORY/askpass-query\" \"askpass: $*\" &&\n"> <"\t\tcase \"$*\" in\n"> <"\t\t*Username*)\n"> <"\t\t\twhat=user\n"> <"\t\t\t;;\n"> <"\t\t*Password*)\n"> <"\t\t\twhat=pass\n"> <"\t\t\t;;\n"> <"\t\tesac &&\n"> <"\t\tcat \"$TRASH_DIRECTORY/askpass-$what\"\n"> <"\t\tEOF\n"> <"\t\tGIT_ASKPASS=\"$TRASH_DIRECTORY/askpass\" &&\n"> <"\t\texport GIT_ASKPASS &&\n"> <"\t\texport TRASH_DIRECTORY\n"> <"\t"> ) } ) ] spids: [1144] ) spids: [1140 1143] ) (FuncDef name: set_askpass body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-query))} spids: [1183] ) ] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$1"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-user))} spids: [1198] ) ] ) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Number "$2"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-pass))} spids: [1213] ) ] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [1180] ) spids: [1176 1179] ) (FuncDef name: expect_askpass body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dest) op: Equal rhs: {($ VSub_Name "$HTTPD_DEST") (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_Plus arg_word: {(Lit_Slash /) ($ VSub_Number "$3")} ) spids: [1231 1236] ) } spids: [1229] ) ] spids: [1229] ) (AndOr children: [ (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list:[{(none)}] spids:[125212531256-1]) (case_arm pat_list: [{(pass)}] action: [ (C {(echo)} { (DQ ("askpass: Password for 'http://") ($ VSub_Number "$2") ("@") ($ VSub_Name "$dest") ("': ") ) } ) ] spids: [1259 1260 1274 -1] ) (case_arm pat_list: [{(both)}] action: [ (C {(echo)} {(DQ ("askpass: Username for 'http://") ($ VSub_Name "$dest") ("': "))} ) (C {(echo)} { (DQ ("askpass: Password for 'http://") ($ VSub_Number "$2") ("@") ($ VSub_Name "$dest") ("': ") ) } ) ] spids: [1277 1278 1301 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [(C {(false)})] spids: [1304 1305 1311 -1] ) ] spids: [1243 1249 1314] ) ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-expect))} spids: [1319] ) ] spids: [1240] ) (C {(test_cmp)} {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-expect))} {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/askpass-query))} ) ] op_id: Op_DAmp ) ] spids: [1226] ) spids: [1222 1225] ) ] )