Merge branch 'jk/do-not-run-httpd-tests-as-root'
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:06:05 +0000 (10:06 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 17:06:05 +0000 (10:06 -0700)
* jk/do-not-run-httpd-tests-as-root:
t/lib-httpd: require SANITY prereq

1  2 
t/lib-httpd.sh
diff --combined t/lib-httpd.sh
index 252cbf163bcff90aabe39a48219e00565f577ffe,d8918821e6e19aafd1411000aefb8c0583092e96..8b67021a6bb95c8a2e6ed2530267e338f2351082
  # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
  #
  
 -if test -z "$GIT_TEST_HTTPD"
 +test_tristate GIT_TEST_HTTPD
 +if test "$GIT_TEST_HTTPD" = false
  then
 -      skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)"
 +      skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)"
        test_done
  fi
  
+ if ! test_have_prereq SANITY; then
+       test_skip_or_die $GIT_TEST_HTTPD \
+               "Cannot run httpd tests as root"
+ fi
  HTTPD_PARA=""
  
  for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
@@@ -77,7 -81,8 +82,7 @@@ GIT_VALGRIND_OPTIONS=$GIT_VALGRIND_OPTI
  
  if ! test -x "$LIB_HTTPD_PATH"
  then
 -      skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'"
 -      test_done
 +      test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'"
  fi
  
  HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
@@@ -89,20 -94,19 +94,20 @@@ the
        then
                if ! test $HTTPD_VERSION -ge 2
                then
 -                      skip_all="skipping test, at least Apache version 2 is required"
 -                      test_done
 +                      test_skip_or_die $GIT_TEST_HTTPD \
 +                              "at least Apache version 2 is required"
                fi
                if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
                then
 -                      skip_all="Apache module directory not found.  Skipping tests."
 -                      test_done
 +                      test_skip_or_die $GIT_TEST_HTTPD \
 +                              "Apache module directory not found"
                fi
  
                LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH"
        fi
  else
 -      error "Could not identify web server at '$LIB_HTTPD_PATH'"
 +      test_skip_or_die $GIT_TEST_HTTPD \
 +              "Could not identify web server at '$LIB_HTTPD_PATH'"
  fi
  
  prepare_httpd() {
@@@ -156,8 -160,9 +161,8 @@@ start_httpd() 
                >&3 2>&4
        if test $? -ne 0
        then
 -              skip_all="skipping test, web server setup failed"
                trap 'die' EXIT
 -              test_done
 +              test_skip_or_die $GIT_TEST_HTTPD "web server setup failed"
        fi
  }