Alice Kober-Sotzek | ed6afea | 2019-08-07 17:12:11 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # This script starts the local testsite in debug mode. If the flag "-u" is |
| 18 | # passed, Gerrit is built from the current state of the repository and the |
| 19 | # testsite is refreshed. The path to the testsite needs to be provided by |
| 20 | # the variable GERRIT_TESTSITE or as parameter (after any used flags). |
| 21 | # The testsite can be stopped by interrupting this script. |
| 22 | |
| 23 | SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") |
| 24 | GERRIT_CODE_DIR="$SCRIPT_DIR/.." |
| 25 | cd "$GERRIT_CODE_DIR" |
| 26 | |
| 27 | UPDATE=false |
| 28 | while getopts ':u' flag; do |
| 29 | case "${flag}" in |
| 30 | u) UPDATE=true ;; |
| 31 | esac |
| 32 | done |
| 33 | shift $(($OPTIND-1)) |
| 34 | |
| 35 | if [ "$#" -lt 1 ] |
| 36 | then |
| 37 | if [ -z ${GERRIT_TESTSITE+x} ] |
| 38 | then |
| 39 | echo "Path to local testsite is neither set as GERRIT_TESTSITE nor passed as first argument. Stopping." |
| 40 | exit 1 |
| 41 | fi |
| 42 | else |
| 43 | GERRIT_TESTSITE="$1" |
| 44 | fi |
| 45 | |
| 46 | if [ "$UPDATE" = true ] |
| 47 | then |
| 48 | echo "Refreshing testsite" |
| 49 | bazel build gerrit |
| 50 | if [ $? -ne 0 ] |
| 51 | then |
| 52 | echo "Build failed. Stopping." |
| 53 | exit 1 |
| 54 | fi |
| 55 | $(bazel info output_base)/external/local_jdk/bin/java -jar bazel-bin/gerrit.war init --batch -d "$GERRIT_TESTSITE" |
| 56 | if [ $? -ne 0 ] |
| 57 | then |
| 58 | echo "Patching the testsite failed. Stopping." |
| 59 | exit 1 |
| 60 | fi |
| 61 | fi |
| 62 | |
| 63 | $(bazel info output_base)/external/local_jdk/bin/java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 bazel-bin/gerrit.war daemon -d "$GERRIT_TESTSITE" --console-log |