Created
October 21, 2017 13:43
-
-
Save mstoykov/175fb04278146288f4c9ab11a3a8a31d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
keep=false | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-k|--keep) | |
keep=true | |
shift # past argument | |
;; | |
esac | |
done | |
solution=$(cat solution.rs) | |
test=$(cat test*.rs | grep -v 'extern') | |
combined_file=$(mktemp -p. solution_testXXXXX.rs) | |
cat << EOF > "${combined_file}" | |
mod solution { | |
${solution} | |
} | |
mod solution_test { | |
${test} | |
} | |
EOF | |
combined_exec_file=${combined_file%%.rs} | |
rustc --test "${combined_file}" -o "${combined_exec_file}" && ./"${combined_exec_file}" | |
if [ $keep != true ]; then | |
rm "${combined_file}" "${combined_exec_file}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment