This repository has been archived on 2025-07-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fp/test0/presubmit.sh
AKP 4452a7b30f
Add practise test (test0)
Squashed commit of the following:

commit cec03384fa88ae8f74adee81491ea40865aa2f3f
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:42:15 2023 +0100

    Question 5

commit 11aa1f2e3b4ed9410c88c5fc19a23963e4f4722e
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:21:41 2023 +0100

    Question 4

commit e6aaadb45869c3d5cc57a69bcc0862be883834e8
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:13:04 2023 +0100

    Question 3.2

commit f74fd8d782a283596bdbca21d28b2522b9ff29fc
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:29:41 2023 +0100

    Question 3.1

commit d3e03478ba3a54bada957c5b3ec45cbd0ee8e5d9
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:23:53 2023 +0100

    Question two

commit 6f9d44a0a3439abf12010eab9bb06a9a93dcb943
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:11:59 2023 +0100

    Question 1
2023-10-26 14:06:25 +01:00

58 lines
1.2 KiB
Bash

#!/bin/sh
if [ "$1" = "" ]
then
echo "You forgot to add the assignment name, e.g. 'Assessed1'."
echo "Please run the script again with the right argument."
exit 1
fi
if ! [ -f "$1.hs" ]
then
echo "File '$1.hs' not found."
echo "Are you in the correct directory?"
exit 1
fi
echo "Trying to compile your submission..."
# Create temporary directory
temp_dir=$(mktemp -d)
ghc $1.hs -odir $temp_dir -hidir $temp_dir
if [ $? -ne 0 ]
then
echo ""
echo "Your file '$1.hs' did not compile."
echo "Please fix it before submitting."
exit 1
fi
if ! [ -f "$temp_dir/$1.o" ]
then
echo ""
echo "The module name in '$1.hs' does match not the filename '$1'."
echo "Please make sure you that"
echo -e "\t(i) your file is called something like 'AssessedX.hs'"
echo -e "\t(ii) you did not change the top of the template"
echo "and try again."
exit 1
fi
ghc -XSafe $1.hs -odir $temp_dir -hidir $temp_dir
if [ $? -ne 0 ]
then
echo ""
echo "Your file did not compile with '-XSafe.'"
echo "Did you remove '{-# LANGUAGE Safe #-}' from the template?"
exit 1
fi
echo ""
echo "All checks passed."
echo "You are ready to submit!"
# Cleanup temporary directory
rm -r $temp_dir