diff options
author | Roland Grunberg <rgrunber@redhat.com> | 2013-08-28 14:09:33 -0400 |
---|---|---|
committer | Roland Grunberg <rgrunber@redhat.com> | 2013-08-28 14:09:33 -0400 |
commit | ba0467e5b48796e1733412f3126c15e4f2bb2c18 (patch) | |
tree | 55fdae9145c8b7327c5edc14e854437dabd6df93 /prepAllTestBundles.sh | |
download | testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.tar.gz testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.tar.xz testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.zip |
Initial Commit.
Diffstat (limited to 'prepAllTestBundles.sh')
-rwxr-xr-x | prepAllTestBundles.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/prepAllTestBundles.sh b/prepAllTestBundles.sh new file mode 100755 index 0000000..9b134f2 --- /dev/null +++ b/prepAllTestBundles.sh @@ -0,0 +1,61 @@ +#! /bin/bash + +# Copyright (C) 2013, Red Hat, Inc. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html + +# Run Eclipse Test Bundles + +# The definiton of an Eclipse Test Bundle for our purposes is any packaged +# OSGi bundle containing a pom.xml with a packaging type of +# 'eclipse-test-plugin' + +# Takes a single argument (absolute path of folder containing test bundles) + +if [ ! $# -eq 1 ]; then + echo "USAGE : $0 PATH/TO/BUNDLES/DIRECTORY" + exit 1 +fi + +testBundleFolder=$1 + +for jar in `find ${testBundleFolder} -name "*.jar"`; do + jarPomPath=`jar -tf ${jar} | grep 'pom.xml'` + unzip -p ${jar} ${jarPomPath} | grep -q '<packaging>eclipse-test-plugin</packaging>' + if [ $? -eq 0 ]; then + jarPomPath=`jar -tf ${jar} | grep 'pom.xml'` + bsname=`unzip -p ${jar} META-INF/MANIFEST.MF | grep 'Bundle-SymbolicName' | sed 's/Bundle-SymbolicName: \([a-zA-Z.]*\)\(;\)\?.*/\1/'` + + # Detect SWTBot Tests + useSWTBot='false' + unzip -p ${jar} META-INF/MANIFEST.MF | grep -q 'swtbot' + if [ $? -eq 0 ]; then + useSWTBot='true' + fi + + # Find Test class(es) + testclass=`unzip -p ${jar} ${jarPomPath} | grep '<testClass>' | sed 's/.*<testClass>\(.*\)<\/testClass>.*/\1/'` + if [ "${testclass}" = '' ]; then + testclass=`jar -tf ${jar} | grep '/AllTests.class' | tr '/' '.' | sed 's/\.class//'` + fi + if [ "${testclass}" = '' ]; then + testclasses=`jar -tf ${jar} | grep -E '/[^/]*Test.*\.class' | grep -vE '/[^/]*Abstract.*\.class' | grep -v '\\$' | tr '/' '.' | sed 's/\.class//'` + else + testclasses="${testclass}" + fi + + for testclass in ${testclasses} ; do + sed -i "/<target name=\"linuxtoolsTests\">/ a \\ + <exec executable=\"\${basedir}/updateTestBundleXML.sh\"> \\ + <arg value=\"${bsname}\" /> \\ + <arg value=\"${testclass}\" /> \\ + <arg value=\"${useSWTBot}\" /> \\ + </exec> \\ + <runTests testPlugin=\"${bsname}\" testClass=\"${testclass}\" />" \ + target/test.xml + done + + fi +done |