Skip to content

Instantly share code, notes, and snippets.

@mstoykov
Created October 21, 2017 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstoykov/175fb04278146288f4c9ab11a3a8a31d to your computer and use it in GitHub Desktop.
Save mstoykov/175fb04278146288f4c9ab11a3a8a31d to your computer and use it in GitHub Desktop.
#!/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