Oh dear - I'm so frustrated - I cant find the error. My wife asked me the whole time, what I do all the time for our school ... Hhhmmm :-)
What I have done is:
* new Prototype for java packages
import sys, os, shutil, subprocess
__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""
# Make package directory, put support files into it
os.mkdir("{{ QUESTION.parameters.package }}")
[shutil.move(f, "{{ QUESTION.parameters.package }}") for f in os.listdir() if f.endswith(".java")]
# Put student answer class into package directory
with open("{{ QUESTION.parameters.package }}/{{ QUESTION.parameters.class}}.java", "w") as f:
print(__student_answer__, file=f)
# Build test class in package directory too
tester = """package {{ QUESTION.parameters.package }};
public class __Tester__ {
public static void main(String[] args) {
{{TEST.testcode}}
}
}
"""
with open("{{ QUESTION.parameters.package }}/__Tester__.java", "w") as f:
print(tester, file=f)
# Compile and run
if (subprocess.call(["javac", "{{ QUESTION.parameters.package }}/__Tester__.java"]) != 0 or
subprocess.call(["java", "{{ QUESTION.parameters.package }}/__Tester__"]) != 0):
print("Error")
print("** Further testing aborted **", file=sys.stderr)
print("Well Done?")
* I have two java files: one for the answer and an additional
* Parameter set to {"package": "Bsp206", "class": "IqTester"}
* My testcase is simple:
System.out.println("DEBUG0");
IqTester iqt = new IqTester();
iqt.start();
But: Nothing happens! No output - nothing! Could anyone please help!
Thanks, thanks, thanks
PS (On my ubuntu laptop javac and java works fine ...)