From 7250bc91fc0c37035e720042246df94303a65e76 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 29 Aug 2013 14:57:42 -0400 Subject: Use 'dir' bundle shape for test bundles and mimic Tycho's test setup. - Eclipse test bundles should have a directory bundle shape (Eclipse-BundleShape: dir) - Eclipse test bundles' contents should be unpacked/placed into the directory from which the test suite is run to permit tests that access their test bundle resources improperly to pass. --- gatherBundles.sh | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ genRepo.sh | 23 +++++++++++ prepAllTestBundles.sh | 12 ++++++ prepRuntimeLocation.sh | 21 +++++++++- 4 files changed, 159 insertions(+), 2 deletions(-) create mode 100755 gatherBundles.sh create mode 100755 genRepo.sh diff --git a/gatherBundles.sh b/gatherBundles.sh new file mode 100755 index 0000000..a811c99 --- /dev/null +++ b/gatherBundles.sh @@ -0,0 +1,105 @@ +#! /bin/sh + +prefix=$ROOT_PREFIX +sdk=$1'-sdk' +launcher=$1'-launcher' +repo=$1 + +eclipse=$prefix$(rpm --eval '%{_libdir}')/eclipse + +datadir=$prefix/usr/share/eclipse +javadir=$prefix/usr/share/java +jnidir=$prefix/usr/lib/java +tycho_bundles_external=/usr/share/java/tycho/tycho-bundles-external.zip + +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/genRepo.sh b/genRepo.sh new file mode 100755 index 0000000..6fc92da --- /dev/null +++ b/genRepo.sh @@ -0,0 +1,23 @@ +#! /bin/sh + +prefix=$ROOT_PREFIX +sdk=$1'-sdk' +launcher=$1'-launcher' +repo=$1 + +tycho_bundles_external=/usr/share/java/tycho/tycho-bundles-external.zip + +# use the bundled equinox launcher to publish the p2 repo +mkdir -p $launcher +pushd $launcher +unzip $tycho_bundles_external + +java -jar 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 + +popd + +rm -rf $sdk $launcher diff --git a/prepAllTestBundles.sh b/prepAllTestBundles.sh index 9b134f2..136ffc0 100755 --- a/prepAllTestBundles.sh +++ b/prepAllTestBundles.sh @@ -20,6 +20,7 @@ if [ ! $# -eq 1 ]; then fi testBundleFolder=$1 +echo 'Eclipse-BundleShape: dir' > MANIFEST.MF for jar in `find ${testBundleFolder} -name "*.jar"`; do jarPomPath=`jar -tf ${jar} | grep 'pom.xml'` @@ -58,4 +59,15 @@ for jar in `find ${testBundleFolder} -name "*.jar"`; do done fi + + # Make 'Eclipse-BundleShape: dir' + jarName=`basename ${jar}` + symJarName=`ls target-sdk/plugins/ | grep ${jarName}` + rm target-sdk/plugins/${symJarName} + cp ${jar} target-sdk/plugins/ + jar -umf ./MANIFEST.MF target-sdk/plugins/${jarName} done + +rm ./MANIFEST.MF +pushd target +../genRepo.sh $(pwd) diff --git a/prepRuntimeLocation.sh b/prepRuntimeLocation.sh index 7e88643..ce3ee86 100755 --- a/prepRuntimeLocation.sh +++ b/prepRuntimeLocation.sh @@ -8,7 +8,10 @@ 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) + +# 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 @@ -30,6 +33,21 @@ sed -i '// d' target/test.xml sed -i '// d' target/test.xml sed -i '// a ' target/test.xml +# A VERY dirty hack to mimic Tycho's improper usage of test bundle resources +sed -i '// i \ + \ + \ +<\/path> \ + \ + \ + \ +' target/test.xml + + # Define our test task sed -i '// i \ \ @@ -47,7 +65,6 @@ sed -i '// i \ 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 -- cgit