CCM NG: Shell script has now subcommands for running tests
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4604 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
dd13055dba
commit
c74e733639
|
|
@ -2,15 +2,22 @@ ccm.sh is a helper script for building and running LibreCCM in a development
|
||||||
environment. It provides shortcuts for several Maven goals. The available
|
environment. It provides shortcuts for several Maven goals. The available
|
||||||
subcommands are:
|
subcommands are:
|
||||||
|
|
||||||
build-site [PROFILE] : Builds the Maven project site.
|
build-site [PROFILE] : Builds the Maven project site.
|
||||||
build [PROFILE] : Builds LibreCCM using the provided profile
|
build [PROFILE] : Builds LibreCCM using the
|
||||||
build-module MODULE [PROFILE]: Build a specific LibreCCM module.
|
provided profile
|
||||||
testccm [PROFILE] : Run tests for all modules.
|
build-module MODULE [PROFILE] : Build a specific LibreCCM
|
||||||
test-module MODULE [PROFILE] : Run tests for a specific LibreCCM module.
|
module.
|
||||||
install-runtime [RUNTIME] : Download and install a runtime (application
|
test-all [-s [-r RUNTIME]] [PROFILE] : Run tests for all modules.
|
||||||
server) into ./runtime
|
test-module [-s [-r RUNTIME]] MODULE [PROFILE] : Run tests for a specific
|
||||||
run [-r RUNTIME] [BUNDLE] : Run a runtime (application server)
|
LibreCCM module.
|
||||||
help : Show this help message.
|
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]: Run a specific testsuite or
|
||||||
|
a single test.
|
||||||
|
install-runtime [RUNTIME] : Download and install a
|
||||||
|
runtime (application server)
|
||||||
|
into ./runtime.
|
||||||
|
run [-r RUNTIME] [BUNDLE] : Run a runtime
|
||||||
|
(application server)
|
||||||
|
help : Show this help message.
|
||||||
|
|
||||||
build-site [PROFILE]
|
build-site [PROFILE]
|
||||||
====================
|
====================
|
||||||
|
|
@ -50,6 +57,75 @@ without a profile and to
|
||||||
|
|
||||||
with a profile.
|
with a profile.
|
||||||
|
|
||||||
|
test-all [-s [-r RUNTIME]] [PROFILE]
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Run all tests for all modules. If the -s flag is set a application server is
|
||||||
|
started in the background before the tests are run and stopped afterwards.
|
||||||
|
If no runtime is provided using -r RUNTIME Wildfly is used as runtime. See
|
||||||
|
the section "run" for Wildfly specific details.
|
||||||
|
|
||||||
|
If a profile is provided the profile is used to run the tests.
|
||||||
|
|
||||||
|
test-module [-s [-r RUNTIME]] MODULE [PROFILE]
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
Runs the tests for a specific module. If the -s flag is set a application
|
||||||
|
server is started in the background before the tests are run and stopped
|
||||||
|
afterwards. If no runtime is provided using -r RUNTIME Wildfly is used as
|
||||||
|
runtime. See the section "run" for Wildfly specific details.
|
||||||
|
|
||||||
|
This subcommand has one mandatory parameter: The module which tests are run.
|
||||||
|
Optionally a profile can be provided.
|
||||||
|
|
||||||
|
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]
|
||||||
|
================================================
|
||||||
|
|
||||||
|
Runs the a specific testsuite or a single test.
|
||||||
|
If the -s flag is set a application
|
||||||
|
server is started in the background before the tests are run and stopped
|
||||||
|
afterwards. If no runtime is provided using -r RUNTIME Wildfly is used as
|
||||||
|
runtime. See the section "run" for Wildfly specific details.
|
||||||
|
|
||||||
|
This subcommand has two mandatory parameter:
|
||||||
|
The module which contains the test(suite) to run and the test to run. The test
|
||||||
|
to run must be provided in the following syntax:
|
||||||
|
|
||||||
|
fully.qualified.classname.of.testclass[#test-method]
|
||||||
|
|
||||||
|
Optionally are profile can be provided.
|
||||||
|
|
||||||
|
Some examples:
|
||||||
|
|
||||||
|
Run all tests in the class org.libreccm.configuration.EqualsAndHashCodeTest in
|
||||||
|
the ccm-core module:
|
||||||
|
|
||||||
|
ccm.sh runtest ccm-core org.libreccm.configuration.EqualsAndHashCodeTest
|
||||||
|
|
||||||
|
Run all tests in the class org.libreccm.core.CcmObjectRepositoryTest in the
|
||||||
|
ccm-core module. This tests is run using Arquillian and requires a runtime and
|
||||||
|
is only run when an integration test profile is used:
|
||||||
|
|
||||||
|
ccm.sh runtest -s ccm-core org.libreccm.core.CcmObjectRepositoryTest
|
||||||
|
wildfly-remote-h2-mem
|
||||||
|
|
||||||
|
Or if you only want to run the saveChangedCcmObject test:
|
||||||
|
|
||||||
|
ccm.sh runtest -s ccm-core
|
||||||
|
org.libreccm.core.CcmObjectRepositoryTest#saveChangedCcmObject wildfly-remote-h2-mem
|
||||||
|
|
||||||
|
The last two examples used the default runtime (Wildfly). Invoking without a
|
||||||
|
specific runtime is equivalent to
|
||||||
|
|
||||||
|
ccm.sh runtest -s -r wildfly ccm-core org.libreccm.core.CcmObjectRepositoryTest wildfly-remote-h2-mem
|
||||||
|
|
||||||
|
ccm.sh runtest -s -r wildfly ccm-core org.libreccm.core.CcmObjectRepositoryTest#saveChangedCcmObject wildfly-remote-h2-mem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
install-runtime [RUNTIME]
|
install-runtime [RUNTIME]
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
|
|
||||||
272
ccm.sh
272
ccm.sh
|
|
@ -1,15 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
wildflyversion="10.1.0.Final"
|
# Provides shortcuts for working with LibreCCM
|
||||||
|
|
||||||
|
wildflyversion="10.1.0.Final"
|
||||||
|
wildflypidfile="./WILDFLY_PID"
|
||||||
|
|
||||||
|
# Build the project site.
|
||||||
|
#
|
||||||
|
# @param $1 (optional): Maven profile to use.
|
||||||
|
#
|
||||||
buildsite() {
|
buildsite() {
|
||||||
if [ -d "$1" ]; then
|
if [ -d "$1" ]; then
|
||||||
mvn clean package site site:stage -Dmaven.test.failure.ignore=true -P$2
|
mvn clean package site site:stage -Dmaven.test.failure.ignore=true -P$1
|
||||||
else
|
else
|
||||||
mvn clean package site site:stage -Dmaven.test.failure.ignore=true
|
mvn clean package site site:stage -Dmaven.test.failure.ignore=true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build all modules
|
||||||
|
#
|
||||||
|
# @param $1 (optional): Maven profile to use.
|
||||||
|
#
|
||||||
build() {
|
build() {
|
||||||
if [ -d "$1" ]; then
|
if [ -d "$1" ]; then
|
||||||
mvn clean package -P$1
|
mvn clean package -P$1
|
||||||
|
|
@ -18,6 +29,11 @@ build() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build a module
|
||||||
|
#
|
||||||
|
# @param $1 (mandantory): The artifact ID of the module to build.
|
||||||
|
# @param $2 (optional) : The profile to use.
|
||||||
|
#
|
||||||
buildmodule() {
|
buildmodule() {
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
|
|
@ -26,32 +42,216 @@ buildmodule() {
|
||||||
mvn clean package -pl $1 -am
|
mvn clean package -pl $1 -am
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Usage: ccm.sh build-module PROFILE [MODULE]"
|
echo "Usage: ccm.sh build-module MODULE [PROFILE]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
testccm() {
|
# Helper method for starting runtime for integration tests
|
||||||
if [ -n "$1" ]; then
|
# @param $1 (mandantory): Runtime to start
|
||||||
mvn clean test -P$1
|
#
|
||||||
else
|
starttestruntime() {
|
||||||
mvn clean test
|
if [ "$1"="wildfly" ]; then
|
||||||
fi
|
echo "Starting Wildfly $wildversion for running tests..."
|
||||||
}
|
wildflyhome=""
|
||||||
|
if [ -n "$JBOSS_HOME" ]; then
|
||||||
testmodule() {
|
echo "Setting wildflyhome to JBOSS_HOME"
|
||||||
if [ -n "$1" ]; then
|
wildflyhome=$JBOSS_HOME
|
||||||
if [ -n "$2" ]; then
|
elif [ -d "./runtime/wildfly-$wildflyversion" ]; then
|
||||||
mvn clean test -P$2 -pl $1 -am
|
echo "Setting wildflyhome..."
|
||||||
else
|
wildflyhome="./runtime/wildfly-$wildflyversion"
|
||||||
mvn clean test -pl $1 -am
|
else
|
||||||
|
echo "There is not Wildfly in ./runtime/ and JBOSS_HOME is not set."
|
||||||
|
echo "Please call install-runtime or set JBOSS_HOME"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Usage: ccm.sh test-module MODULE [PROFILE]"
|
pushd $wildflyhome
|
||||||
|
sh "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PID_FILE=$wildflypidfile ./bin/standalone.sh"
|
||||||
|
popd
|
||||||
|
echo "Waiting 120s for Wildfly to start up..."
|
||||||
|
sleep 120
|
||||||
|
|
||||||
|
if [ -n "$profile" ]; then
|
||||||
|
mvn clean test -P$profile
|
||||||
|
else
|
||||||
|
mvn clean test
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Stopping Wildfly..."
|
||||||
|
pushd $wildflyhome
|
||||||
|
kill $(<"$wildflypidfile")
|
||||||
|
popd
|
||||||
|
|
||||||
|
elif [ "$1"="tomee" ]; then
|
||||||
|
echo "Not implemented yet."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Unsupported runtime $1. Supported runtimes are wildfly and tomee."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Helper method for stopping the test runtime
|
||||||
|
#
|
||||||
|
# @param $1 (mandantory): Runtime to stop
|
||||||
|
#
|
||||||
|
stoptestruntime() {
|
||||||
|
if [ "$1" = "wildfly" ]; then
|
||||||
|
echo "Stopping Wildfly..."
|
||||||
|
|
||||||
|
wildflyhome=""
|
||||||
|
if [ -n "$JBOSS_HOME" ]; then
|
||||||
|
echo "Setting wildflyhome to JBOSS_HOME"
|
||||||
|
wildflyhome=$JBOSS_HOME
|
||||||
|
elif [ -d "./runtime/wildfly-$wildflyversion" ]; then
|
||||||
|
echo "Setting wildflyhome..."
|
||||||
|
wildflyhome="./runtime/wildfly-$wildflyversion"
|
||||||
|
else
|
||||||
|
echo "There is not Wildfly in ./runtime/ and JBOSS_HOME is not set."
|
||||||
|
echo "Please call install-runtime or set JBOSS_HOME"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd $wildflyhome
|
||||||
|
kill $(<"$wildflypidfile")
|
||||||
|
popd
|
||||||
|
elif [ "$1" = "tomee" ]; then
|
||||||
|
echo "Not implemented yet."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Unsupported runtime $1. Supported runtime are wildfly and tomee."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run all tests
|
||||||
|
testall() {
|
||||||
|
|
||||||
|
startruntime=false
|
||||||
|
runtime="wildfly"
|
||||||
|
profile=""
|
||||||
|
|
||||||
|
if [ "$1" = "-s" ]; then
|
||||||
|
startruntime=true
|
||||||
|
if [ "$2" = "-r" ]; then
|
||||||
|
runtime=$3
|
||||||
|
profile=$4
|
||||||
|
else
|
||||||
|
profile=$2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
starttestruntime $runtime
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$profile" ]; then
|
||||||
|
echo "Running tests for all modules with profile $profile..."
|
||||||
|
mvn clean test -P$profile
|
||||||
|
else
|
||||||
|
echo "Running tests for all modules..."
|
||||||
|
mvn clean test
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
stoptestruntime $runtime
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run tests for a module
|
||||||
|
testmodule() {
|
||||||
|
|
||||||
|
startruntime=false
|
||||||
|
runtime="wildfly"
|
||||||
|
module=""
|
||||||
|
profile=""
|
||||||
|
|
||||||
|
if [ "$1" = "-r" ]; then
|
||||||
|
startruntime=true
|
||||||
|
if [ "$2" = "-r" ]; then
|
||||||
|
runtime=$3
|
||||||
|
module=$4
|
||||||
|
profile=$5
|
||||||
|
else
|
||||||
|
module=$2
|
||||||
|
profile=$3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$module" ]; then
|
||||||
|
echo "Error: No module to test. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
starttestruntime $runtime
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$profile" ]; then
|
||||||
|
echo "Running tests for module $module with profile $profile..."
|
||||||
|
mvn clean test -P$profile -pl $module -am
|
||||||
|
else
|
||||||
|
echo "Running tests for module $module..."
|
||||||
|
mvn clean test -pl $module $am
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
stoptestruntime $runtime
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run a single testsuite or test
|
||||||
|
runtest() {
|
||||||
|
|
||||||
|
startruntime=false
|
||||||
|
runtime="wildfly"
|
||||||
|
module=""
|
||||||
|
testtorun=""
|
||||||
|
profile=""
|
||||||
|
|
||||||
|
if [ "$1" = "-r" ]; then
|
||||||
|
startruntime=true
|
||||||
|
if [ "$2" = "-r" ]; then
|
||||||
|
runtime=$3
|
||||||
|
module=$4
|
||||||
|
profile=$5
|
||||||
|
else
|
||||||
|
module=$2
|
||||||
|
profile=$3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z module ]; then
|
||||||
|
echo "No module provided. Please provide the module which contains the test to run. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z testtorun ]; then
|
||||||
|
echo "No test to run provided. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
starttestruntime $runtime
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$profile" ]; then
|
||||||
|
echo "Running tests for module $module with profile $profile..."
|
||||||
|
mvn clean test -Dtest=$testtorun -DfailIfNoTests=false -P$profile -pl $module -am
|
||||||
|
else
|
||||||
|
echo "Runnign tests for module $module..."
|
||||||
|
mvn clean test -D$testtorun -pl $module $am
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $startruntime ]; then
|
||||||
|
stoptestruntime $runtime
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
installruntime() {
|
installruntime() {
|
||||||
runtime=""
|
runtime=""
|
||||||
|
|
@ -177,7 +377,7 @@ run() {
|
||||||
else
|
else
|
||||||
echo "There is not Wildfly in ./runtime/ and JBOSS_HOME is not set."
|
echo "There is not Wildfly in ./runtime/ and JBOSS_HOME is not set."
|
||||||
echo "Please call install-runtime or set JBOSS_HOME"
|
echo "Please call install-runtime or set JBOSS_HOME"
|
||||||
echo 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting Wildfly in $wildflyhome..."
|
echo "Starting Wildfly in $wildflyhome..."
|
||||||
|
|
@ -233,16 +433,23 @@ showhelp() {
|
||||||
development environment. It provides shortcuts for several Maven goals. The
|
development environment. It provides shortcuts for several Maven goals. The
|
||||||
available subcommands are:
|
available subcommands are:
|
||||||
|
|
||||||
build-site [PROFILE] : Builds the Maven project site.
|
build-site [PROFILE] : Builds the Maven project
|
||||||
build [PROFILE] : Build all LibreCCM modules.
|
site.
|
||||||
build-module MODULE [PROFILE] : Build a specific LibreCCM module.
|
build [PROFILE] : Build all LibreCCM
|
||||||
testccm [PROFILE] [RUNTIME] : Run tests for all modules.
|
modules.
|
||||||
test-module MODULE [PROFILE] [RUNTIME] : Run tests for a specific LibreCCM
|
build-module MODULE [PROFILE] : Build a specific LibreCCM
|
||||||
module.
|
module.
|
||||||
install-runtime [RUNTIME] : Download and install a runtime
|
test-all [-s [-r RUNTIME]] [PROFILE] : Run tests for all modules.
|
||||||
(application server) into ./runtime
|
test-module [-s [-r RUNTIME]] MODULE [PROFILE] : Run tests for a specific
|
||||||
run [-r RUNTIME] [BUNDLE] : Run a runtime (application server)
|
LibreCCM module.
|
||||||
help : Show this help message.
|
run-test [-s [-r RUNTIME]] MODULE TEST [PROFILE]: Run a specific testsuite
|
||||||
|
or a single test.
|
||||||
|
install-runtime [RUNTIME] : Download and install a
|
||||||
|
runtime (application
|
||||||
|
server) into ./runtime
|
||||||
|
run [-r RUNTIME] [BUNDLE] : Run a runtime
|
||||||
|
(application server)
|
||||||
|
help : Show this help message.
|
||||||
|
|
||||||
A detailed description of the subcommands is provided in ccm-readme.txt"
|
A detailed description of the subcommands is provided in ccm-readme.txt"
|
||||||
|
|
||||||
|
|
@ -255,8 +462,9 @@ case $1 in
|
||||||
build-site) buildsite $2 ;;
|
build-site) buildsite $2 ;;
|
||||||
build) build $2 ;;
|
build) build $2 ;;
|
||||||
build-module) buildmodule $2 ;;
|
build-module) buildmodule $2 ;;
|
||||||
testccm) testccm $2 $3 ;;
|
test-all) testall $2 $3 $4 ;;
|
||||||
test-module) testmodule $2 $3 $4 ;;
|
test-module) testmodule $2 $3 $4 $5 ;;
|
||||||
|
run-test) runtest $2 $3 $4 $5 $6 ;;
|
||||||
install-runtime) installruntime $2 ;;
|
install-runtime) installruntime $2 ;;
|
||||||
run) run $2 $3 $4 ;;
|
run) run $2 $3 $4 ;;
|
||||||
stop-runtime) stopruntime $2 ;;
|
stop-runtime) stopruntime $2 ;;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue