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

Using single zips rather than ensembles

parent 436c4df6
#!/bin/bash
# TODO: devine marker string variable
# TODO: show non-compiling projects in logfile
#rm -rf Unpack
# The original examination project skeleton
PROJECTREF=~/GoikLectures/Klausuren/Sd1/2017Summer/Exam
PROJECTREF=~/GoikLectures/Klausuren/Sd1/2019summer/Exam
# Representative of archive integrity
SRCREPRESENT=src/main/java/de/hdm_stuttgart/mi/sd1/aufgabe1/HandyAbrechnung.java
# File representative of archive integrity
SRCREPRESENT=src/main/java/de/hdm_stuttgart/mi/sd1/task2/ChangeAmount.java
# The executable jar archive containing unit tests
TESTJAR=sd1_2017sommer_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)"
declare -a MARKERS=("Aufgabe 1" "Aufgabe 2")
# No changes beyond this line
# Hands off beyond this line
#--------------------------------------------------------------------------------------------
mkdir -p Unpack
zip=$1
fbname=$(basename "$zip" .zip)
rm -rf ~/results.log /tmp/Reference
cp -r $PROJECTREF /tmp/Reference
pushd /tmp/Reference
mvn -T4 clean;
mvn -T4 clean > /dev/null 2>&1
rm -rf src/main/java
popd
for zip in $( ls *.zip); do
fbname=$(basename "$zip" .zip)
echo $fbname
mkdir Unpack;pushd Unpack
unzip ../$fbname.zip
pomFileCount=`find . -name pom.xml|wc -l`
if [[ 1 = $pomFileCount ]]; then
projectDir=`find . -name pom.xml`
projectDir=${projectDir%/*}
echo "Found project $projectDir"
mkdir Unpack;pushd Unpack
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
mvn -T4 compile test-compile
if [ $? -eq 0 ] ; then
mvn -T4 -Dmaven.test.skip=true package
result=""
for mark in "${MARKERS[@]}"; do
result+=`java -jar target/$TESTJAR | grep "$mark"|sed 's/^[ ]*//'`
result+=" "
done
else
result="$projectDir does not compile"
fi
popd
echo "$fbname $result" >> ~/results.log
#Cleanup user project
pushd $projectDir
rm -rf *.iml .idea A1.log
mvn clean
popd
rm ../$fbname.zip
zip -r ../$fbname.zip $projectDir
else
echo "$fbname : $SRCREPRESENT not found" >> ~/results.log
fi
if [ -f "${projectDir}"/$SRCREPRESENT ]; then
echo "Found $projectDir/$SRCREPRESENT"
cp -r /tmp/Reference .
cp -r "$projectDir"/src/main/java Reference/src/main
pushd Reference
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
else
echo "$projectDir does not compile"
exit 1;
fi
popd
echo "$fbname $result" >> ~/results.log
#Cleanup user project
pushd "$projectDir"
rm -rf *.iml .idea A1.log
mvn clean > /dev/null 2>&1
popd
rm ../"$fbname".zip
zip -r ../"$fbname".zip "$projectDir" > /dev/null 2>&1
else
echo "$fbname : Found more than one directory component" >> ~/results.log
echo "$fbname : ${projectDir}/$SRCREPRESENT not found"
exit 1
fi
popd # return from Unpack
rm -rf Unpack
done
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 "---------------------------------------"
echo Results at ~/results.log
#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