solutions/build.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 29 Sep 2024 18:46:02 +0100
changeset 965 94f5cce73a4f
parent 921 bb54e7aa1a3f
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
921
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
#!/usr/bin/env -S scala-cli shebang -no-indent
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
//> using scala "3.3.1"
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
//> using toolkit latest
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
// course work directories
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
val cws = List("cw1", "cw2", "cw3", "cw4", "cw5")
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
// main files that need testing
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
val files = Map("cw1" -> "cw1.sc", 
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
                "cw2" -> "lexer.sc",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
		 		"cw3" -> "parser.sc",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
		 		"cw4" -> "compiler.sc",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
		 		"cw5" -> "fun_llvm.sc"
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
		)
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
// test files used as input
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
val test_files = Map(
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
    "cw1" -> Nil,
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
    "cw2" -> List("collatz.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
		  "collatz2.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
		  "factors.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
		  "fib.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
		  "loops.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
		  "primes.while"),
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
    "cw3" -> List("collatz.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
		  "collatz2.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
		  "factors.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
		  "fib.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
		  "loops.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
		  "primes.while"),
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
    "cw4" -> List("collatz2.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
		  "fib.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
		  "forloop.while",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
		  "forloop2.while"),
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
    "cw5" -> List("fact.fun",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
		  	"hanoi.fun",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
		    "mand.fun",
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
			"mand2.fun")
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
)   
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
for (cw <- cws) {
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
	val main_file = files(cw)
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
	for (arg <- test_files(cw)) {
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
		println(s"Testing $cw/$main_file with $arg")
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
		val subdir = os.pwd / cw
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
		os.proc("amm", main_file, "test", arg).call(cwd = subdir)
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
	}
bb54e7aa1a3f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
}