blob: 014eba957537333f0e169b3c04468e146114663a [file] [log] [blame]
Alice Kober-Sotzeked6afea2019-08-07 17:12:11 +02001#!/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
23SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")")
24GERRIT_CODE_DIR="$SCRIPT_DIR/.."
25cd "$GERRIT_CODE_DIR"
26
27UPDATE=false
28while getopts ':u' flag; do
29 case "${flag}" in
30 u) UPDATE=true ;;
31 esac
32done
33shift $(($OPTIND-1))
34
35if [ "$#" -lt 1 ]
36then
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
42else
43 GERRIT_TESTSITE="$1"
44fi
45
46if [ "$UPDATE" = true ]
47then
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
61fi
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