Skip to content

Commit 66429aa

Browse files
committed
Cleanup and reorganize tooling
+ refactor Makefile to stay in synch with AuDoscore + bring back the PTC (public test cleaner) - but as preliminary shell script + replace Unicode "✓" / "✗" with ASCII "\u2713" / "\u2717" in PointsMerger to satisfy "-encoding ASCII" + add initial "tests/compare_interface_top/" - methods work ok, but functions have heavy type erasure in class file
1 parent 5ae1487 commit 66429aa

File tree

10 files changed

+199
-9
lines changed

10 files changed

+199
-9
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ compile-stage1: miniclean compile-stage0
5757
cat forbidden.out 1>&2 ; \
5858
exit 1 ; \
5959
fi
60+
cd $(cleanroomDirName); scalac $(COMPILER_ARGS) -cp ../$(interfacesDirName) *.scala
6061
make run-comparer
6162

6263
compile-stage2: miniclean compile-stage1
@@ -71,7 +72,6 @@ compile-stage2: miniclean compile-stage1
7172
echo "echo \"]\" 1>&2" >> loop.sh
7273

7374
compile-stage2-secret:
74-
cd $(cleanroomDirName); scalac $(COMPILER_ARGS) -cp ../$(interfacesDirName) *.scala
7575
scalac $(COMPILER_ARGS) -cp $(LIBALL):$(junitDirName):$(interfacesDirName):$(sutDirName) -d $(junitDirName) $(junitDirName)/$(SECRETTESTSOURCE)
7676
java -cp $(LIBALL):$(junitDirName):$(interfacesDirName):$(sutDirName) -Dpub=$(PUBLICTEST) tester.tools.CheckAnnotation $(SECRETTEST)
7777
java -cp $(LIBALL) tester.tools.ReplaceManager $(SECRETTEST) > compile2.sh
@@ -106,26 +106,26 @@ run: run-stage$(STAGE)
106106

107107

108108
help:
109-
@echo '==========================================================='
110-
@echo 'Welcome to AuDoscore - The Grading System for Java Homework'
111-
@echo '-----------------------------------------------------------'
109+
@echo '=========================================================================='
110+
@echo 'Welcome to AuDoscore/ScExFuSS - The Grading System for Java/Scala Homework'
111+
@echo '--------------------------------------------------------------------------'
112112
@echo 'This Makefile serves different purposes, but it is NOT used directly for the grading itself.'
113113
@echo 'Running test cases for grading is done through the test.sh shell script (see README for details).'
114-
@echo '-----------------------------------------------------------'
114+
@echo '--------------------------------------------------------------------------'
115115
@echo 'Developers/Users use this Makefile from the project root folder to make:'
116116
@echo '- build: freshly build the main library'
117117
@echo '- verify: run all provided tests from the tests folder'
118118
@echo '- clean: remove all generated artifacts (including the main library!)'
119-
@echo '-----------------------------------------------------------'
119+
@echo '--------------------------------------------------------------------------'
120120
@echo 'Testers use this Makefile from one of the provided test folders to make:'
121121
@echo '- test_run: run the test in the current folder (keeping temporary execution folder)'
122122
@echo '- test_verify: run and compare results of current test against its historical execution'
123123
@echo '- test_REBUILD: run and update historical execution of current test to its new results'
124124
@echo '- test_clean: remove temporary execution folder (i.e. generated artifacts)'
125-
@echo '-----------------------------------------------------------'
125+
@echo '--------------------------------------------------------------------------'
126126
@echo 'All other make targets are used by the test.sh shell script and should not be called directly.'
127127
@echo 'Enjoy!'
128-
@echo '==========================================================='
128+
@echo '=========================================================================='
129129

130130

131131
test_run:

tester/tools/PointsMerger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private static void merge(ArrayList<JSONObject> replacedExercises, JSONObject va
170170
}
171171
double localScore = getLocalPoint((Boolean) usedResult.get("success"), (String) usedResult.get("id"), (Boolean) usedResult.get("fromSecret"));
172172
localPoints += localScore;
173-
localSummary += ((Boolean) usedResult.get("success")) ? "" : "";
173+
localSummary += ((Boolean) usedResult.get("success")) ? "\u2713" : "\u2717";
174174
localSummary += String.format(" %1$6.2f", localScore) + " | ";
175175
localSummary += (String) usedResult.get("desc");
176176
Object error = usedResult.get("error");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
val topValFun: Int => Int = x => x + 1
2+
def topDefFun: Int => Int = x => x + 1
3+
def topDefMeth(x: Int): Int = x + 1
4+
5+
trait ToTestTrait {
6+
val traitValFun: Int => Int = x => x + 1
7+
def traitDefFun: Int => Int = x => x + 1
8+
def traitDefMeth(x: Int): Int = x + 1
9+
def companionCommon: Int => Int = x => x + 1
10+
}
11+
12+
object ToTest extends ToTestTrait {
13+
val objectValFun: Int => Int = x => x + 1
14+
def objectDefFun: Int => Int = x => x + 1
15+
def objectDefMeth(x: Int): Int = x + 1
16+
override def companionCommon: Int => Int = x => x + 1
17+
18+
@main
19+
def objectDefMethMainAnnotated(): Unit = {
20+
println(topValFun(42))
21+
}
22+
}
23+
24+
class ToTest extends ToTestTrait {
25+
val classValFun: Int => Int = x => x + 1
26+
def classDefFun: Int => Int = x => x + 1
27+
def classDefMeth(x: Int): Int = x + 1
28+
override def companionCommon: Int => Int = x => x + 1
29+
}
30+
31+
object TestObjectWithMain {
32+
def main(args: Array[String]): Unit = {
33+
println(42)
34+
println(topValFun(666))
35+
}
36+
}
37+
38+
@main
39+
def main(): Unit = {
40+
println(topValFun(4711))
41+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
make[1]: Verzeichnis „/ScExFuSS/tests/compare_interface_top/test.402801“ wird betreten
2+
if [ -d "interfaces" ]; then cd interfaces; scalac *.scala; fi
3+
cd student; scalac -cp ../interfaces *.scala
4+
make[1]: Verzeichnis „/ScExFuSS/tests/compare_interface_top/test.402801“ wird verlassen
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ERROR - Method public static int ToTest$package.topDefMeth(int)[ToTest$package] does not match or does not exist in student code
2+
Exception in thread "main" java.lang.Error
3+
at tester.tools.InterfaceComparator.main(InterfaceComparator.java:334)
4+
make[2]: *** [Makefile:85: run-comparer] Fehler 1
5+
make[1]: *** [Makefile:58: compile-stage1] Fehler 2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import org.junit.Test
2+
import org.junit.Assert.*
3+
import tester.annotations.*
4+
5+
@Exercises(Array(new Ex(exID = "SimpleTest", points = 42)))
6+
@CompareInterface(Array("ToTest$package"))
7+
class PublicTest extends JUnitWithPoints {
8+
@Points(exID = "SimpleTest", bonus = 1)
9+
@Test(timeout = 666)
10+
def publicTest(): Unit = {
11+
fail("Should never be executed.")
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import org.junit.Test
2+
import org.junit.Assert.*
3+
import tester.annotations.*
4+
5+
@SecretClass
6+
class SecretTest extends JUnitWithPoints {
7+
@Points(exID = "SimpleTest", bonus = 1)
8+
@Test(timeout = 666)
9+
def secretTest(): Unit = {
10+
fail("Should never be executed.")
11+
}
12+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
val topValFun: Int => Long = x => x - 1 // wrong types are intentional - BUT NOT DETECTED due to type erasure of "scala.Function1<java.lang.Object, java.lang.Object>" in .class!
2+
def topDefFun: Long => Long = x => x - 1 // wrong types are intentional - BUT NOT DETECTED due to type erasure of "scala.Function1<java.lang.Object, java.lang.Object>" in .class!
3+
def topDefMeth(x: Long): Long = x - 1 // wrong types are intentional - only this is found as scala generates "public static int topDefMeth(int);"
4+
5+
trait ToTestTrait {
6+
val traitValFun: Int => Int = x => x - 1
7+
def traitDefFun: Int => Int = x => x - 1
8+
def traitDefMeth(x: Int): Int = x - 1
9+
def companionCommon: Int => Int = x => x - 1
10+
}
11+
12+
object ToTest extends ToTestTrait {
13+
val objectValFun: Int => Int = x => x - 1
14+
def objectDefFun: Int => Int = x => x - 1
15+
def objectDefMeth(x: Int): Int = x - 1
16+
override def companionCommon: Int => Int = x => x - 1
17+
18+
@main
19+
def objectDefMethMainAnnotated(): Unit = {
20+
println(topValFun(42))
21+
}
22+
}
23+
24+
class ToTest extends ToTestTrait {
25+
val classValFun: Int => Int = x => x - 1
26+
def classDefFun: Int => Int = x => x - 1
27+
def classDefMeth(x: Int): Int = x - 1
28+
override def companionCommon: Int => Int = x => x - 1
29+
}
30+
31+
object TestObjectWithMain {
32+
def main(args: Array[String]): Unit = {
33+
println(42)
34+
println(topValFun(666))
35+
}
36+
}
37+
38+
@main
39+
def main(): Unit = {
40+
println(topValFun(4711))
41+
}

tools/pubtest_cleaner.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
declare -a wholeLinePatterns=(
4+
"@.*CompareInterface(.*"
5+
"@.*Exercises(.*" # includes @Ex
6+
"@.*Forbidden(.*"
7+
"@.*InitializeOnce(.*"
8+
"@.*NotForbidden(.*"
9+
"@.*Points(.*"
10+
"@.*Replace(.*"
11+
"@.*SecretClass\$"
12+
"import tester\..*"
13+
"import org\.junit\.Rule" "import org\.junit\.ClassRule"
14+
"@Rule" "@org\.junit\.Rule" "@ClassRule" "@org\.junit\.ClassRule"
15+
"public final PointsLogger" "public final static PointsSummary" "public static final PointsSummary"
16+
)
17+
18+
declare -a substringPatterns=(
19+
"extends JUnitWithPoints"
20+
)
21+
22+
function clean_file {
23+
file=$1
24+
if [[ $file == *.java || $file == *.scala ]];then
25+
for i in "${wholeLinePatterns[@]}"; do
26+
sed -i "/${i}/d" $file
27+
done
28+
for i in "${substringPatterns[@]}"; do
29+
sed -i "s/${i}//g" $file
30+
done
31+
fi
32+
}
33+
34+
function recursive_clean {
35+
start_dir=$1
36+
for file in "$start_dir"/*; do
37+
if [ ! -d "$file" ]; then
38+
clean_file $file
39+
else
40+
recursive_clean $file
41+
fi
42+
done
43+
}
44+
45+
46+
recursive=0
47+
arg=$1
48+
49+
if [ "x$arg" == "x-r" ]; then
50+
recursive=1
51+
shift
52+
arg=$1
53+
fi
54+
55+
## check input file? or directory?
56+
if [ -d $arg ]; then
57+
if [ $recursive -eq 1 ]; then
58+
echo "-r not supported yet!"
59+
exit 1
60+
#recursive_clean $arg
61+
else
62+
for file in "$arg"; do
63+
if [ -f $file ]; then
64+
clean_file $arg
65+
fi
66+
done
67+
fi
68+
elif [ -f $arg ]; then
69+
clean_file $arg
70+
else
71+
echo "$arg is not valid"
72+
exit 1
73+
fi

0 commit comments

Comments
 (0)