author | Christian Urban <christian.urban@kcl.ac.uk> |
Mon, 03 Feb 2025 12:34:38 +0000 | |
changeset 978 | 8778d23fef92 |
permissions | -rw-r--r-- |
978
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
// for testing compilation |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
import scala.util.{Try, Success, Failure} |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
val res = { |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
if (os.exists(os.pwd / "br.class")) |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
os.proc("java", "br").call(cwd = os.pwd) |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
else if (os.exists(os.pwd / "br" / "br.class")) |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
os.proc("java", "br.br").call(cwd = os.pwd) |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
else throw new Exception("No CLASS file found") |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
} |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
if (res.exitCode != 0) { |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
throw new Exception("Unsuccessful call") |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
} |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
Try(res.out.text().replace("\n", "") == "23467") match { |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
case Success(v) => Console.println(s" Success. Printed ${res.out.text().replace("\n", "")}.") |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
case Failure(e) => Console.println(s" Fail. Printed ${res.out.text()} instead of \"2,3,4,6,7\"\n") ; throw(e) |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
} |
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |