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 | |
download | testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.tar.gz testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.tar.xz testbundle-to-eclipse-test-ba0467e5b48796e1733412f3126c15e4f2bb2c18.zip |
Initial Commit.
-rw-r--r-- | alltest.xml | 56 | ||||
-rwxr-xr-x | prepAllTestBundles.sh | 61 | ||||
-rwxr-xr-x | prepRuntimeLocation.sh | 54 | ||||
-rw-r--r-- | swtbot-library.xml | 206 | ||||
-rwxr-xr-x | updateTestBundleXML.sh | 13 |
5 files changed, 390 insertions, 0 deletions
diff --git a/alltest.xml b/alltest.xml new file mode 100644 index 0000000..a398c43 --- /dev/null +++ b/alltest.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> + +<project name="testsuite" default="run" basedir="."> +<property name="test-classname" value="org.eclipse.linuxtools.internal.valgrind.massif.tests.AllTests" /> +<property name="test-plugin-name" value="org.eclipse.linuxtools.valgrind.massif.tests" /> + +<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/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 diff --git a/prepRuntimeLocation.sh b/prepRuntimeLocation.sh new file mode 100755 index 0000000..7e88643 --- /dev/null +++ b/prepRuntimeLocation.sh @@ -0,0 +1,54 @@ +#! /bin/bash + +mkdir target +pushd target + +# Prepare testing environment +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 +/usr/share/java/tycho/copy-platform-all $(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 + +# 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 + +cp swtbot-library.xml alltest.xml updateTestBundleXML.sh target/ diff --git a/swtbot-library.xml b/swtbot-library.xml new file mode 100644 index 0000000..e43c96c --- /dev/null +++ b/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/updateTestBundleXML.sh b/updateTestBundleXML.sh new file mode 100755 index 0000000..bf6cced --- /dev/null +++ b/updateTestBundleXML.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +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 |