blob: 192321838d06c2a426972bec015e705adfb569d6 [file] [log] [blame]
#!/bin/bash -x
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright 2009-2017 Oracle and/or its affiliates. All rights reserved.
#
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
# Other names may be trademarks of their respective owners.
#
# The contents of this file are subject to the terms of either the GNU
# General Public License Version 2 only ("GPL") or the Common
# Development and Distribution License("CDDL") (collectively, the
# "License"). You may not use this file except in compliance with the
# License. You can obtain a copy of the License at
# http://www.netbeans.org/cddl-gplv2.html
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
# specific language governing permissions and limitations under the
# License. When distributing the software, include this License Header
# Notice in each file and include the License file at
# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the GPL Version 2 section of the License file that
# accompanied this code. If applicable, add the following below the
# License Header, with the fields enclosed by brackets [] replaced by
# your own identifying information:
# "Portions Copyrighted [year] [name of copyright owner]"
#
# Contributor(s):
#
# The Original Software is NetBeans. The Initial Developer of the Original
# Software is Sun Microsystems, Inc. Portions Copyright 2009-2010 Sun
# Microsystems, Inc. All Rights Reserved.
#
# If you wish your version of this file to be governed by only the CDDL
# or only the GPL Version 2, indicate your decision by adding
# "[Contributor] elects to include this software in this distribution
# under the [CDDL or GPL Version 2] license." If you do not indicate a
# single choice of license, a recipient has the option to distribute
# your version of this file under either the CDDL, the GPL Version 2 or
# to extend the choice of license to its licensees as provided above.
# However, if you add GPL Version 2 code and therefore, elected the GPL
# Version 2 license, then the option applies only if the new code is
# made subject to such option by the copyright holder.
do_index() {
rm -rf cache
mkdir -p cache
for g in `pwd`/data/*; do
NAME=`basename $g`;
PROJECTS=`find $PWD/data/group1/ -maxdepth 1 -mindepth 1 -type d`
USERDIR="`pwd`/cache/userdir"
rm -rf "$USERDIR"
(cd ../indexer; ant "-Drun.args=--nosplash --nogui -J-Xmx128m --category-id '$NAME' --category-name '$NAME-display-name' --cache-target ../tests/cache/temp.zip --category-root-dir '$g' --category-projects '$PROJECTS'" "-Dtest.user.dir=$USERDIR" "$@" run)
(cd cache; unzip temp.zip; rm temp.zip)
rm -rf "$USERDIR"
done
}
#XXX: copied from cmdline/test/scripted/harness
write_passed_results_file() {
cat >$RESULT_FILE <<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="0" hostname="foo" name="$TEST_NAME" tests="1" time="0" timestamp="`date`">
<properties/>
<testcase classname="$TEST_NAME" name="main" time="0" />
</testsuite>
EOF
}
write_failure_results_file() {
cat >$RESULT_FILE <<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="1" hostname="foo" name="$TEST_NAME" tests="1" time="0" timestamp="`date`">
<properties/>
<testcase classname="$TEST_NAME" name="main" time="0">
<failure message="Test failed" type="junit.framework.AssertionFailedError"><![CDATA[$1]]></failure>
</testcase>
</testsuite>
EOF
}
do_index "$@"
(cd ../web/web.main; ant jar)
OUT=`mktemp`;
trap "rm $OUT" EXIT
java -jar ../web/web.main/dist/web.main.jar --port 0 cache >"$OUT" &
trap "kill %1" EXIT
while [ -z "$PORT" ] ; do
sleep 1s;
PORT=`cat "$OUT" | grep "Running on port: " | cut -d ':' -f 2 | tr -d ' '`;
done
rm -rf results
mkdir results
for tc in `find testcases -name "*.tc" -type d`; do
REQUEST=`cat $tc/request | grep -v '^#'`;
TEST_NAME=`echo ${tc#testcases/} | tr '/' '-'`;
RESULT_FILE="`pwd`/results/TEST-$TEST_NAME.xml"
if wget -O - "http://localhost:${PORT}$REQUEST" | diff -w - $tc/response; then
write_passed_results_file
else
write_failure_results_file
fi;
done
exit 0