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 ...@@ -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 TESTJAR=sd1_2019summer_exam-0.9-fat-tests.jar
# Strings like e.g. "Aufgabe 2" referencing "Aufgabe 2: (30/50)" # 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 # Hands off beyond this line
#-------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------
zip=$1 evaluateProject() {
fbname=$(basename "$zip" .zip)
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 1> /dev/null
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%/*}
rm -rf ~/results.log /tmp/Reference if [ -f "${projectDir}"/$SRCREPRESENT ]; then
cp -r $PROJECTREF /tmp/Reference cp -r /tmp/Reference .
pushd /tmp/Reference cp -r "$projectDir"/src/main/java Reference/src/main
mvn -T4 clean > /dev/null 2>&1 pushd Reference 1> /dev/null
rm -rf src/main/java mvn -T4 compile test-compile > /dev/null 2>&1
popd if [ $? -eq 0 ] ; then
mvn -T4 -Dmaven.test.skip=true package > /dev/null 2>&1
result=""
mkdir Unpack;pushd Unpack mvnOutput=`java -jar target/$TESTJAR`
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 # for mark in "${MARKERS[@]}"; do
echo "Found $projectDir/$SRCREPRESENT" # result+=`java -jar target/$TESTJAR | grep "$mark"|sed 's/^[ ]*//'`
cp -r /tmp/Reference . # result+=" "
cp -r "$projectDir"/src/main/java Reference/src/main # done
pushd Reference result=$mvnOutput
mvn -T4 compile test-compile > /dev/null 2>&1
if [ $? -eq 0 ] ; then else
mvn -T4 -Dmaven.test.skip=true package > /dev/null 2>&1 result="$projectDir does not compile"
result="" fi
for mark in "${MARKERS[@]}"; do popd 1> /dev/null
result+=`java -jar target/$TESTJAR | grep "$mark"|sed 's/^[ ]*//'` echo "$fbname"
result+=" " echo "$result"
done
else #Cleanup user project
echo "$projectDir does not compile" pushd "$projectDir" 1> /dev/null
exit 1; rm -rf *.iml .idea A1.log
mvn clean > /dev/null 2>&1
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"
exit 1
fi fi
popd popd 1> /dev/null # return from Unpack
echo "$fbname $result" >> ~/results.log rm -rf Unpack
#Cleanup user project echo "-----------------------------------------------------"
pushd "$projectDir" uid=`echo $1| sed -e s/.zip//`
rm -rf *.iml .idea A1.log grep $uid ~/bonusprojekte.csv
mvn clean > /dev/null 2>&1 echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
popd }
rm ../"$fbname".zip
zip -r ../"$fbname".zip "$projectDir" > /dev/null 2>&1 for zip in "$@"
else do
echo "$fbname : ${projectDir}/$SRCREPRESENT not found" evaluateProject $zip
exit 1 done
fi
else
echo "$fbname : Found more than one directory component" >> ~/results.log
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 "---------------------------------------"
#end #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