Skip to content

Commit

Permalink
examples for lecture
Browse files Browse the repository at this point in the history
  • Loading branch information
jpolitz committed Nov 21, 2022
1 parent 6d3984e commit d2e8c88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions GradeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ class ExecHelpers {
In Java 9 and later, new String(out.readAllBytes()) would be a better
option, but using Java 8 for compatibility with ieng6.
*/
static String streamToString(InputStream out) {
Stream<String> lines = new BufferedReader(new InputStreamReader(out)).lines();
static String streamToString(InputStream out) throws IOException {
String result = "";
for(Object o: lines.toArray()) {
result += (String)o + "\n";
while(true) {
int c = out.read();
if(c == -1) { break; }
result += (char)c;
System.out.println(System.currentTimeMillis() + "; just read: " + (char)c);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion TestListExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import org.junit.*;

public class TestListExamples {
@Test(timeout = 100)
@Test(timeout = 8000)
public void testTimeout() {
while(true) {}
}
Expand Down
6 changes: 5 additions & 1 deletion grade.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Create your grading script here

CPATH='.:lib/hamcrest-core-1.3.jar:lib/junit-4.13.2.jar'

rm -rf student-submission
git clone $1 student-submission
echo 'Finished cloning'


cp student-submission/ListExamples.java ./
javac -cp $CPATH *.java
java -cp $CPATH org.junit.runner.JUnitCore TestListExamples


0 comments on commit d2e8c88

Please sign in to comment.