Reputation: 3674
I am a PhD student of software testing. I made a script to test all the classes in a specific folder. However to make it fully automatic I would need a script that extract all the jar files in a respective folder and copy both the paths before and after extracting the jar file. For example
If I have AAA.jar at location /Users/mian/Systems/AAA.jar and AAA.jar on extraction create the folders and class org/apple/orange/banana.class then I would like to separately assign org/apple/orange/ to variable VAR1 and /Users/mian/Systems/org/apple/orange/ to VAR2.
The script I have so far is this
#!/bin/bash
STR1="/Users/mian/QualitasCorpus/Systems/freecs/freecs-1.3.20100406/bin/freecs-1.3.20100406/lib/"
STR2="freecs.commands."
for i in $( ls $STR1 ); do
if [[ $i == *.class ]]
then
echo " @@@@@@@@@@@@@@@@@@ The Class under test is "$i" @@@@@@@@@@@@@@@@@@@@@@@@@@@@" >> result.traces
java yeti.YetiWithDaikon -java -time=10s -nologs -ADFDPlus -testModules="$STR2${i%.*}" >> result.traces
echo " %%%%%%%%%%%%%%%%%%%% The Class is finished testing %%%%%%%%%%%%%%%%%%%%%%%%%" >> result.traces
fi
done
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >> result.traces
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ End of Folder @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >> result.traces
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >> result.traces
mv result.traces resultsOf"$STR2"traces
Upvotes: 1
Views: 1173
Reputation: 3084
This script writes info about the jar file. Names of variables are included in echo.
#!/bin/bash
echo ""
STR1=$(dirname $(realpath $1".jar"))
unzip -qo $1".jar" -d $1 #unzip jar file to working_directory/jarname/
list=$(tree $1 -Rnfi --noreport | grep ".class") #gets the raw .class file list
list=$(echo $list | sed -e 's/'$1'\.//g') #removes the first foldername
list=$(echo $list | sed -e 's/\/class//g') #removes the last .class
list2=$list
list=$(echo $list | sed -e 's/\//\./g') #changes / to .
OLD_IFS=$IFS
IFS=$'\n'" "
echo -e "STR1=\033[34m"$STR1"\033[0m\n"
echo -e "FOLDER=\033[31m"$1"\033[0m\n"
for STR2 in $list
do
echo -e "STR2=\033[32m"$STR2"\033[0m"
done
echo ""
for STR3 in $list2
do
echo -e "STR3=\033[33m"$STR3"\033[0m"
done
echo ""
IFS=$OLD_IFS
Usage:
You have a jar file called freecs.jar. Run it with:
SCRIPTNAME jarfilename
without the .jar
extension.
Upvotes: 1