Add testbundle-to-eclipse-test scripts. Given a folder containing Eclipse test bundles built using Maven/Tycho, this script attempts to extract the necessary metadata allowing for the running of test bundles under the Eclipse Testing Framework. Change-Id: I9fe09fd782774efc1d4e4ddcdbebe64117b2bc84 Reviewed-on: https://git.eclipse.org/r/17273 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
diff --git a/testbundle-to-eclipse-test/alltest.xml b/testbundle-to-eclipse-test/alltest.xml new file mode 100644 index 0000000..b5dd783 --- /dev/null +++ b/testbundle-to-eclipse-test/alltest.xml
@@ -0,0 +1,56 @@ +<?xml version="1.0"?> + +<project name="testsuite" default="run" basedir="."> +<property name="test-classname" value="" /> +<property name="test-plugin-name" value="" /> + +<property name="library-file" value="${eclipse-home}/dropins/${subProjectName2}/plugins/org.eclipse.test/library.xml" /> + +<property name="swtbot-library-file" value="${basedir}/../../swtbot-library.xml" /> + +<!-- The property ${eclipse-home} should be passed into this script --> +<!-- Set a meaningful default value for when it is not. --> +<property name="eclipse-home" value="${basedir}/../.." /> + +<!-- This target holds all initialization code that needs to be done for --> +<!-- all tests that are to be run. Initialization for individual tests --> +<!-- should be done within the body of the suite target. --> +<target name="init"> +<tstamp /> +<delete> +<fileset dir="${eclipse-home}" includes="org*.xml" /> +</delete> +</target> + +<!-- This target defines the tests that need to be run. --> +<target name="suite"> +<property name="test-folder" value="${eclipse-home}/test_folder" /> +<delete dir="${test-folder}" quiet="true" /> +<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}"> +<property name="data-dir" value="${test-folder}" /> +<property name="plugin-name" value="${test-plugin-name}" /> +<property name="classname" value="${test-classname}" /> +</ant> +</target> + +<!-- This target holds code to cleanup the testing environment after --> +<!-- after all of the tests have been run. You can use this target to --> +<!-- delete temporary files that have been created. --> +<target name="cleanup"> +<mkdir dir="${results}/consolelogs" /> +<copy failonerror="false" file="${eclipse-home}/results/${test-classname}.txt" tofile="${results}/consolelogs/${test-classname}_${platform}.metadata.log.txt" /> +</target> + +<!-- This target runs the test suite. Any actions that need to happen --> +<!-- after all the tests have been run should go here. --> +<target name="run" depends="init,suite,cleanup"> +<ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> +<property name="includes" value="org*.xml" /> +<property name="output-file" value="${test-plugin-name}-${test-classname}.xml" /> +</ant> +</target> + +<target name="all" depends="run" description="Dummy target to run all tests"> +</target> + +</project>
diff --git a/testbundle-to-eclipse-test/eclipse-runTestBundles b/testbundle-to-eclipse-test/eclipse-runTestBundles new file mode 100755 index 0000000..fddc833 --- /dev/null +++ b/testbundle-to-eclipse-test/eclipse-runTestBundles
@@ -0,0 +1,19 @@ +#! /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 + +if [ ! $# -eq 1 ]; then + echo "USAGE : $0 PATH/TO/BUNDLES/DIRECTORY" + exit 1 +fi + +./prepRuntimeLocation.sh || exit 1 +./prepAllTestBundles.sh $1 || exit 1 + +pushd target + +./runtests.sh -os linux -ws gtk -arch `arch`
diff --git a/testbundle-to-eclipse-test/gatherBundles.sh b/testbundle-to-eclipse-test/gatherBundles.sh new file mode 100755 index 0000000..94909eb --- /dev/null +++ b/testbundle-to-eclipse-test/gatherBundles.sh
@@ -0,0 +1,109 @@ +#! /bin/sh + +# 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 + +prefix=$ROOT_PREFIX +sdk=$1'-sdk' +repo=$1 + +eclipse=$prefix$(rpm --eval '%{_libdir}')/eclipse + +datadir=$prefix/usr/share/eclipse +javadir=$prefix/usr/share/java +jnidir=$prefix/usr/lib/java + +mkdir -p $sdk/plugins $sdk/features +pushd $sdk + + (cd $eclipse; + ls -d plugins/* features/* 2>/dev/null) | + while read f; do + [ ! -e $f ] && ln -s $eclipse/$f $f + done + (cd $eclipse/dropins; ls -d * 2>/dev/null) | + while read f; do + if [ -e $eclipse/dropins/$f/eclipse ]; then + (cd $eclipse/dropins/$f/eclipse; + ls -d plugins/* features/* 2>/dev/null) | + while read g; do + [ ! -e $g ] && \ + ln -s $eclipse/dropins/$f/eclipse/$g $g + done + else + (cd $eclipse/dropins/$f; + ls -d plugins/* features/* 2>/dev/null) | + while read g; do + [ ! -e $g ] && \ + ln -s $eclipse/dropins/$f/$g $g + done + fi + done + (cd $datadir/dropins; ls -d * 2>/dev/null) | + while read f; do + if [ -e $datadir/dropins/$f/eclipse ]; then + (cd $datadir/dropins/$f/eclipse; + ls -d plugins/* features/* 2>/dev/null) | + while read g; do + [ ! -e $g ] && \ + ln -s $datadir/dropins/$f/eclipse/$g $g + done + else + (cd $datadir/dropins/$f; + ls -d plugins/* features/* 2>/dev/null) | + while read g; do + [ ! -e $g ] && \ + ln -s $datadir/dropins/$f/$g $g + done + fi + done + +for p in $(ls -d $eclipse/dropins/jdt/plugins/*); do + plugin=$(basename $p) + [ ! -e plugins/$plugin ] && ln -s $eclipse/dropins/jdt/plugins/$plugin plugins/$plugin +done +for f in $(ls -d $eclipse/dropins/jdt/features/*); do + feature=$(basename $f) + [ ! -e features/$feature ] && ln -s $eclipse/dropins/jdt/features/$feature features/$feature +done +for p in $(ls -d $eclipse/dropins/sdk/plugins/*); do + plugin=$(basename $p) + [ ! -e plugins/$plugin ] && ln -s $eclipse/dropins/sdk/plugins/$plugin plugins/$plugin +done +for f in $(ls -d $eclipse/dropins/sdk/features/*); do + feature=$(basename $f) + [ ! -e features/$feature ] && ln -s $eclipse/dropins/sdk/features/$feature features/$feature +done +for p in $(ls -d $eclipse/plugins/*); do + plugin=$(basename $p) + [ ! -e plugins/$plugin ] && ln -s $eclipse/plugins/$plugin plugins/$plugin +done +for f in $(ls -d $eclipse/features/*); do + feature=$(basename $f) + [ ! -e features/$feature ] && ln -s $eclipse/features/$feature features/$feature +done + +# jars in %%{_javadir} may not be uniquely named +id=1 +for p in $(find $javadir -name "*.jar"); do + unzip -p $p 'META-INF/MANIFEST.MF' | grep -q 'Bundle-SymbolicName' + if [ $? = 0 ]; then + plugin=${id}-$(basename $p) + [ ! -e plugins/$plugin ] && ln -s $p plugins/$plugin + id=$((${id} + 1)) + fi +done +id=1 +for p in $(find $jnidir -name "*.jar"); do + unzip -p $p 'META-INF/MANIFEST.MF' | grep -q 'Bundle-SymbolicName' + if [ $? = 0 ]; then + plugin=${id}-$(basename $p) + [ ! -e plugins/$plugin ] && ln -s $p plugins/$plugin + id=$((${id} + 1)) + fi +done + +popd
diff --git a/testbundle-to-eclipse-test/genRepo.sh b/testbundle-to-eclipse-test/genRepo.sh new file mode 100755 index 0000000..bce9813 --- /dev/null +++ b/testbundle-to-eclipse-test/genRepo.sh
@@ -0,0 +1,19 @@ +#! /bin/sh + +# 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 + +prefix=$ROOT_PREFIX +sdk=$1'-sdk' +repo=$1 + +java -jar $prefix/usr/lib*/eclipse/plugins/org.eclipse.equinox.launcher_*.jar -nosplash -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \ +-metadataRepository file:$repo \ +-artifactRepository file:$repo \ +-source $sdk \ +-compress -append -publishArtifacts + +rm -rf $sdk
diff --git a/testbundle-to-eclipse-test/prepAllTestBundles.sh b/testbundle-to-eclipse-test/prepAllTestBundles.sh new file mode 100755 index 0000000..37a5666 --- /dev/null +++ b/testbundle-to-eclipse-test/prepAllTestBundles.sh
@@ -0,0 +1,117 @@ +#! /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 + +# Prepare 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 +echo 'Eclipse-BundleShape: dir' > MANIFEST.MF + +extraIUs= + +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} ${jarPomPath} | sed '/<parent>/,/<\/parent>/ d' | sed '/<build>/,/<\/build>/ d' | grep '<artifactId>' | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\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) + includepatterns= + testclasses= + testclass=`unzip -p ${jar} ${jarPomPath} | grep '<testClass>' | sed 's/.*<testClass>\(.*\)<\/testClass>.*/\1/'` + if [ "${testclass}" = '' ]; then + # Check for custom includes + includepatterns=`unzip -p ${jar} ${jarPomPath} | sed -n '/<includes>/,/<\/includes>/p' | sed -n 's/.*<include>\(.*\)<\/include>.*/\1/p' | sed 's/\*\*/\.\*/'` + for pat in ${includepatterns}; do + testclasses="${testclasses} `jar -tf ${jar} | grep -E "${pat}" | grep '.class' | grep -v '\\$' | tr '/' '.' | sed 's/\.class//'`" + done + if [ "${includepatterns}" = '' ]; then + testclass=`jar -tf ${jar} | grep '/AllTests.class' | tr '/' '.' | sed 's/\.class//'` + fi + fi + if [ "${testclass}" = '' ]; then + if [ "${includepatterns}" = '' ]; then + # Use default includes + testclasses=`jar -tf ${jar} | grep -E '/(Test.*\.class|.*Test\.class)' | grep -vE '/(Abstract.*\.class|.*Abstract\.class)' | grep -v '\\$' | tr '/' '.' | sed 's/\.class//'` + fi + 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 + + # Collect any extra IUs from each test bundle's tycho-surefire-plugin + unzip -p ${jar} ${jarPomPath} | grep -q '<artifactId>tycho-surefire-plugin<\/artifactId>' + if [ $? -eq 0 ]; then + IUList=`unzip -p ${jar} ${jarPomPath} | sed -n '/<dependency>/,/<\/dependency>/ p' | grep -B 1 '<artifactId>'` + isFeature=0 + for elem in ${IUList}; do + echo ${elem} | grep -q '<type>eclipse-feature<\/type>' + if [ $? -eq 0 ]; then + isFeature=1 + fi + echo ${elem} | grep -q '<artifactId>' + if [ $? -eq 0 ]; then + extraIU=`echo ${elem} | sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/'` + if [ ${isFeature} -eq 1 ]; then + extraIU=${extraIU}'.feature.group' + fi + extraIUs="${extraIUs} ${extraIU}" + isFeature=0 + fi + done + fi + + # Make 'Eclipse-BundleShape: dir' + jarName=`basename ${jar}` + symJarName=`ls target-sdk/plugins/ | grep ${jarName}` + # Might be multiple symlinked jars providing same bundle (rare) + for file in ${symJarName}; do + rm target-sdk/plugins/${file} + done + cp ${jar} target-sdk/plugins/ + jar -umf ./MANIFEST.MF target-sdk/plugins/${jarName} + + fi +done + +# Always install the extra IUs +# Not by choice but because this is easier to do +extraIUs=`echo -n ${extraIUs} | tr ' ' '\n' | sort | uniq | tr '\n' ','` +sed -i "s/\"-installIUs \(.*\)\"/\"-installIUs \1,${extraIUs}\"/" target/test.xml + +rm ./MANIFEST.MF +pushd target +../genRepo.sh $(pwd)
diff --git a/testbundle-to-eclipse-test/prepRuntimeLocation.sh b/testbundle-to-eclipse-test/prepRuntimeLocation.sh new file mode 100755 index 0000000..d9eac09 --- /dev/null +++ b/testbundle-to-eclipse-test/prepRuntimeLocation.sh
@@ -0,0 +1,84 @@ +#! /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 + +mkdir target +pushd target + +# Prepare testing environment +if [ ! -e /usr/share/java/eclipse-testing ]; then + echo "/usr/share/java/eclipse-testing/ does not exist. Please install the package providing this location." + exit 1 +fi +cp -rp /usr/share/java/eclipse-testing/* ./ + +# Remove eclipse-tests p2 repo and generate for system +rm -rf features plugins content.jar artifacts.jar binary + +# Create directory of all system OSGi bundles +# Do not create into p2 repo yet (we must make test bundles have dir shape) +../gatherBundles.sh $(pwd) + +popd + +# Prepare the test.xml file + +sed -i 's/\${eclipse-home}\/plugins\/\${testPluginX}/\${testPluginX}/' target/test.xml +sed -i '/<fileset/,/<\/fileset>/ s/dir="\${eclipse-home}\/plugins"/dir="\${basedir}"/' target/test.xml +sed -i 's/refid="test.plugin.file" \/>/value="\${basedir}\/alltest.xml" \/>/' target/test.xml +sed -i 's/\${report}/\${testPlugin}/' target/test.xml + +# Support multiple XML reports from same bundle but different test classes +sed -i '/<attribute name="testPlugin"/ a <attribute name="testClass" \/>' target/test.xml +sed -i 's/@{testPlugin}\.xml/@{testPlugin}-@{testClass}\.xml/' target/test.xml +sed -i 's/\${testPlugin}\.xml/\${output-file}/' target/test.xml +sed -i 's/\${testPlugin}_\${platform}\.xml/\${output-file}/' target/test.xml + +# Insert our test task +sed -i '/<antcall target="quickTests" \/>/ d' target/test.xml +sed -i '/<antcall target="longRunningTests" \/>/ d' target/test.xml +sed -i '/<target name="all">/ a <antcall target="linuxtoolsTests" \/>' target/test.xml + +# A VERY dirty hack to mimic Tycho's improper usage of test bundle resources +sed -i '/<antcall target="configureTeamTest" \/>/ i \ +<path id="testbundle.paths"> \ + <dirset \ + dir="\${eclipse-home}" \ + includes="plugins/\${testPlugin}_*" \/> \ +<\/path> \ +<property \ + name="testBundlePath" \ + refid="testbundle.paths" \/> \ +<copy todir="\${eclipse-home}"> \ + <fileset dir="\${testBundlePath}" includes="**" \/> \ +</copy>' target/test.xml + + +# Define our test task +sed -i '/<target name="quickTests">/ i \ +<target name="linuxtoolsTests"> \ +<!-- Copy over the XML to generate a top-level report for all of the tests --> \ + <mkdir dir="\${results}\/origXml" \/> \ + <xslt style="\${repoLocation}\/splitter.xsl" basedir="\${results}\/xml" includes="*.xml" destdir="\${results}\/origXml"\/> \ + <!-- Aggregate XML report files --> \ + <junitreport todir="\${results}\/xml" tofile="org.eclipse.sdk.tests.xml"> \ + <fileset dir="\${results}/origXml" includes="*.xml" \/> \ + <\/junitreport> \ + <!-- Generate top-level HTML report --> \ + <xslt style="\${repoLocation}\/JUNIT.XSL" basedir="\${results}\/xml" includes="org.eclipse.sdk.tests.xml" destdir="\${results}\/html" \/> \ +<\/target>' target/test.xml + +sed -i 's/"-installIUs \(.*\)"/"-installIUs \1,org.eclipse.swtbot.eclipse.junit.headless"/' target/test.xml + +# Prepare the runtests.sh file +sed -i '/cp \${testslocation}\/\*\.properties/ a cp \${testslocation}\/{JUNIT.XSL,alltest.xml,updateTestBundleXML.sh,swtbot-library.xml} \.' target/runtests.sh +sed -i '/^properties=/ a testslocation=\$(pwd)' target/runtests.sh + +# Do not print test properties (output is annoying) +sed -i '/echoproperties/d' target/library.xml + +cp swtbot-library.xml alltest.xml updateTestBundleXML.sh target/
diff --git a/testbundle-to-eclipse-test/swtbot-library.xml b/testbundle-to-eclipse-test/swtbot-library.xml new file mode 100644 index 0000000..e43c96c --- /dev/null +++ b/testbundle-to-eclipse-test/swtbot-library.xml
@@ -0,0 +1,206 @@ +<?xml version="1.0"?> +<!-- + + +====================================================================== +this has been copied from o.e.test plugin with some targets for SWTBot +====================================================================== + + +--> + +<project name="swtbot-library-headless-junit4" default="usage" basedir="."> + + <target name="usage"> + <echo message="Please refer to the testframework.html in org.eclipse.test for instructions on usage." /> + </target> + + <target name="init"> + <!-- + Parameters: + (Mandatory) + data-dir - the directory for Eclipse to write its data + plugin-name - the name of the plugin to test + classname - the name of the test class + + (Optional - overrides defaults set in script) + testProduct - a string containing the product id to test. + testApplication - a string containing the application id to test. + vmargs - a string containing arguments to pass to the VM. + extraVMargs - allows separate setting of VM args from separate caller. + timeout - overrides default test timeout value (in milliseconds). + test-output - overrides default output file produced from test run. + plugin-path - path to root of plug-in + useEclipseExe - property setting forces test to launch via eclipse executable. + junit-report-output - output directory for junit reports produced for specified classname. + --> + + <tstamp> + <format property="TIMENOW" pattern="HHmmssSSSS" /> + </tstamp> + <!--property setting useEclipseExe launches tests using the eclipse executable--> + <condition property="launchTarget" value="eclipse-test"> + <isset property="useEclipseExe" /> + </condition> + <!--default launch target for launching tests--> + <property name="launchTarget" value="java-test" /> + + <!-- default product/application to launch --> + <condition property="testproduct.if.available" value="-product ${testProduct}"> + <isset property="testProduct" /> + </condition> + <property name="testproduct.if.available" value="" /> + + <condition property="testapplication.if.available" value="-testApplication ${testApplication}"> + <isset property="testApplication" /> + </condition> + + <property name="testapplication.if.available" value="" /> + + <!--default heap sizes when running performance tests--> + <condition property="vmargs" value=" -Xms256M -Xmx256M"> + <equals arg1="${test.target}" arg2="performance" /> + </condition> + <property name="extraVMargs" value="" /> + <property name="plugin-path" value="" /> + <property name="timeout" value="7200000" /> + <property name="test-output" value="${eclipse-home}/${classname}.xml" /> + <property name="junit-report-output" value="${eclipse-home}/results" /> + <mkdir dir="${junit-report-output}" /> + </target> + + <target name="swtbot-test" description="Eclipse application used to launch UI plugin tests." depends="init"> + <antcall target="${launchTarget}"> + <!--param name="application" value="org.eclipse.test.uitestapplication"/--> + <param name="application" value="org.eclipse.swtbot.eclipse.junit.headless.swtbottestapplication" /> + </antcall> + </target> + + <target name="java-test"> + <!--default vm args--> + <property name="vmargs" value="-Xms256m -Xmx512m" /> + + <!-- this argument is needed for macosx --> + <condition property="jvmOption" value="-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts"> + <os family="mac" /> + </condition> + + <property name="jvmOption" value="" /> + + <!--set default jvm to use for testing--> + <property name="jvm" value="${java.home}/bin/java" /> + + <property name="launcher-arg-line" value=" + -application ${application} + ${testproduct.if.available} + ${testapplication.if.available} + -data ${data-dir} + formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test-output} formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter + -testPluginName ${plugin-name} + -className ${classname} + -os ${os} + -ws ${ws} + -arch ${arch} + -consoleLog + -debug" /> + <property name="jvm-arg-line" value="${vmargs} ${extraVMargs} ${jvmOption}" /> + + <echo>======================================</echo> + <echo>Running swtbot junit tests in ${classname}</echo> + <echo>Command line args are ${launcher-arg-line}</echo> + <echo>JVM args are ${jvm-arg-line}</echo> + <echo>JUnit Result File: ${junit-report-output}/${classname}.xml.</echo> + <echo>Console output File: ${junit-report-output}/${classname}.txt.</echo> + <echo>======================================</echo> + + <fail unless="application" message="variable 'application' not defined." /> + <fail unless="data-dir" message="variable 'data-dir' not defined." /> + <fail unless="test-output" message="variable 'test-output' not defined" /> + <fail unless="plugin-name" message="variable 'plugin-name' not defined" /> + <fail unless="classname" message="variable 'classname' not defined" /> + <fail unless="os" message="variable 'os' not defined. os can be one of win32, linux, macosx" /> + <fail unless="ws" message="variable 'ws' not defined. ws can be one of win32, wpf, gtk, carbon, cocoa" /> + <fail unless="arch" message="variable 'arch' not defined. arch can be one of x86, x86_64, ppc" /> + + <pathconvert property="foundJunit3" setonempty="false" pathsep=" "> + <path> + <fileset dir="${eclipse-home}/plugins" includes="org.eclipse.swtbot.eclipse.junit3.headless*/META-INF/MANIFEST.MF" /> + <fileset dir="${eclipse-home}/plugins" includes="org.eclipse.swtbot.ant.optional.junit3*" /> + </path> + </pathconvert> + + <fail if="foundJunit3"> + . + Found org.eclipse.swtbot.eclipse.junit3.headless or org.eclipse.swtbot.ant.optional.junit3 in the plugins directory. + JUnit 3.x and 4.x don't play well together. + Please remove org.eclipse.swtbot.eclipse.junit3.headless and org.eclipse.swtbot.ant.optional.junit3 from the plugins dir. + </fail> + + <java fork="true" dir="." timeout="${timeout}" jvm="${jvm}" logError="true" classname="org.eclipse.core.launcher.Main" output="${junit-report-output}/${classname}.txt"> + <classpath> + <fileset dir="${eclipse-home}/plugins"> + <include name="org.eclipse.equinox.launcher_*.jar" /> + </fileset> + </classpath> + <arg line="${launcher-arg-line}" /> + <jvmarg line="${jvm-arg-line}" /> + <sysproperty key="PLUGIN_PATH" value="${plugin-path}" /> + </java> + + <echo>======================================</echo> + <echo>If you see errors above please see the file ${junit-report-output}/${classname}.txt for more information.</echo> + <echo>Errors are generally caused by missing or incorrect dependencies.</echo> + <echo>======================================</echo> + + <antcall target="collect-results" /> + </target> + + <target name="collect-results"> + <dirname property="output-dir" file="${test-output}" /> + <basename property="output-file-name" file="${test-output}" /> + <junitreport todir="${junit-report-output}" tofile="${classname}.xml"> + <fileset dir="${output-dir}"> + <include name="${output-file-name}" /> + </fileset> + </junitreport> + + <dirname property="swtbot.junit4.headless.dir" file="${ant.file.swtbot-library-headless-junit4}"/> + + <mkdir dir="${junit-report-output}/screenshots" /> + <move todir="${junit-report-output}/screenshots" failonerror="false"> + <fileset dir="${eclipse-home}/screenshots" includes="*.*" /> + </move> + + <xslt style="${swtbot.junit4.headless.dir}/JUNIT.XSL" basedir="${junit-report-output}" includes="${classname}.xml" destdir="${junit-report-output}"> + <param name="screenshot_dir" expression="screenshots"/> + <!-- + Only use this if you've set SWTBotPreferences#SCREENSHOT_FORMAT preference + Optional: possible values are bmp, gif, ico, jpeg, jpg, png or tiff + <param name="screenshot_format" expression="jpeg"/> + --> + </xslt> + + <!--save .log content and *.log content from configuration directory--> + <concat destfile="${junit-report-output}/${classname}.log"> + <fileset dir="${eclipse-home}" includes="${data-dir}/.metadata/*.log" /> + <fileset dir="${eclipse-home}" includes="configuration/*.log" /> + </concat> + </target> + + <target name="collect"> + <!-- + This target can be used to aggragate test runs from multiple test suites into a single report. + + Parameters to this target: + includes - the names of the files to include + output-file - the name of the output file to produce + --> + <junitreport todir="." tofile="${output-file}"> + <fileset dir="."> + <include name="${includes}" /> + </fileset> + </junitreport> + </target> + +</project> +
diff --git a/testbundle-to-eclipse-test/updateTestBundleXML.sh b/testbundle-to-eclipse-test/updateTestBundleXML.sh new file mode 100755 index 0000000..e1fa1de --- /dev/null +++ b/testbundle-to-eclipse-test/updateTestBundleXML.sh
@@ -0,0 +1,19 @@ +#! /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 + +bsname=$1 +classname=$2 +useSWTBot=$3 + +sed -i "s/<property name=\"test-classname\" value=\".*\" \/>/<property name=\"test-classname\" value=\"${classname}\" \/>/" alltest.xml +sed -i "s/<property name=\"test-plugin-name\" value=\".*\" \/>/<property name=\"test-plugin-name\" value=\"${bsname}\" \/>/" alltest.xml +sed -i 's/<ant target=".*-test" antfile=".*"/<ant target="ui-test" antfile="\${library-file}"/' alltest.xml + +if [ "${useSWTBot}" = 'true' ]; then + sed -i 's/<ant target=".*-test" antfile=".*"/<ant target="swtbot-test" antfile="\${swtbot-library-file}"/' alltest.xml +fi