mirror of
https://github.com/Noratrieb/libuwuc.git
synced 2026-01-14 19:55:07 +01:00
tests
This commit is contained in:
parent
ae189e8b18
commit
043c960708
15 changed files with 206 additions and 23 deletions
35
test_c.sh
35
test_c.sh
|
|
@ -1,5 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cargo build
|
||||
./uwuc-gcc hello.c -o target/hello
|
||||
./target/hello
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
cargo build --manifest-path "$SCRIPT_DIR/Cargo.toml"
|
||||
|
||||
test_dir=$(mktemp -d)
|
||||
|
||||
clean() {
|
||||
rm -r "${test_dir}"
|
||||
}
|
||||
|
||||
for test in tests/c/*; do
|
||||
name=$(basename $test .c)
|
||||
|
||||
"$SCRIPT_DIR/uwuc-gcc" "$test" -o "$test_dir/$name"
|
||||
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "error: failed to compile test $test"
|
||||
clean
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTPUT=$("$test_dir/$name")
|
||||
code="$?"
|
||||
if [ "$code" -ne "0" ]; then
|
||||
echo "error: test failed with code $code: $test, running $test_dir/$name"
|
||||
echo "------ output:"
|
||||
echo "$OUTPUT"
|
||||
echo "-----"
|
||||
fi
|
||||
done
|
||||
|
||||
clean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue