Commit bd41294f authored by Dr. Martin Goik's avatar Dr. Martin Goik

Processing multiple .zip archive arguments

parent 0b4d77e4
......@@ -10,72 +10,82 @@ SRCREPRESENT=src/main/java/de/hdm_stuttgart/mi/sd1/task2/ChangeAmount.java
TESTJAR=sd1_2019summer_exam-0.9-fat-tests.jar
# Strings like e.g. "Aufgabe 2" referencing "Aufgabe 2: (30/50)"
declare -a MARKERS=("Aufgabe 1" "Aufgabe 2")
declare -a MARKERS=("Task 1" "Task 2")
# Hands off beyond this line
#--------------------------------------------------------------------------------------------
zip=$1
fbname=$(basename "$zip" .zip)
evaluateProject() {
rm -rf ~/results.log /tmp/Reference
cp -r $PROJECTREF /tmp/Reference
pushd /tmp/Reference
zip=$1
fbname=$(basename "$zip" .zip)
rm -rf /tmp/Reference
cp -r $PROJECTREF /tmp/Reference
pushd /tmp/Reference 1> /dev/null
mvn -T4 clean > /dev/null 2>&1
rm -rf src/main/java
popd
popd 1> /dev/null
mkdir Unpack;pushd Unpack
unzip ../$fbname.zip > /dev/null
pomFileCount=`find . -name pom.xml|wc -l`
if [[ 1 = $pomFileCount ]]; then
mkdir Unpack;pushd Unpack 1> /dev/null
unzip ../$fbname.zip > /dev/null
pomFileCount=`find . -name pom.xml|wc -l`
if [[ 1 = $pomFileCount ]]; then
projectDir=`find . -name pom.xml`
projectDir=${projectDir%/*}
echo "Found project $projectDir"
if [ -f "${projectDir}"/$SRCREPRESENT ]; then
echo "Found $projectDir/$SRCREPRESENT"
cp -r /tmp/Reference .
cp -r "$projectDir"/src/main/java Reference/src/main
pushd Reference
pushd Reference 1> /dev/null
mvn -T4 compile test-compile > /dev/null 2>&1
if [ $? -eq 0 ] ; then
mvn -T4 -Dmaven.test.skip=true package > /dev/null 2>&1
result=""
for mark in "${MARKERS[@]}"; do
result+=`java -jar target/$TESTJAR | grep "$mark"|sed 's/^[ ]*//'`
result+=" "
done
mvnOutput=`java -jar target/$TESTJAR`
# for mark in "${MARKERS[@]}"; do
# result+=`java -jar target/$TESTJAR | grep "$mark"|sed 's/^[ ]*//'`
# result+=" "
# done
result=$mvnOutput
else
echo "$projectDir does not compile"
exit 1;
result="$projectDir does not compile"
fi
popd
echo "$fbname $result" >> ~/results.log
popd 1> /dev/null
echo "$fbname"
echo "$result"
#Cleanup user project
pushd "$projectDir"
pushd "$projectDir" 1> /dev/null
rm -rf *.iml .idea A1.log
mvn clean > /dev/null 2>&1
popd
popd 1> /dev/null
rm ../"$fbname".zip
zip -r ../"$fbname".zip "$projectDir" > /dev/null 2>&1
else
echo "$fbname : ${projectDir}/$SRCREPRESENT not found"
exit 1
fi
else
echo "$fbname : Found more than one directory component" >> ~/results.log
else
echo "$fbname : Found more than one directory component"
exit 1
fi
popd # return from Unpack
rm -rf Unpack
echo "---------------------------------------"
cat ~/results.log
echo "+++++++++++++++++++++++++++++++++++++++"
uid=`echo $1| sed -e s/.zip//`
grep $uid ~/bonusprojekte.csv
echo "---------------------------------------"
fi
popd 1> /dev/null # return from Unpack
rm -rf Unpack
echo "-----------------------------------------------------"
uid=`echo $1| sed -e s/.zip//`
grep $uid ~/bonusprojekte.csv
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
for zip in "$@"
do
evaluateProject $zip
done
#end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment