Created
May 20, 2023 05:00
-
-
Save perillo/40d52c92169b3a1304963de6806f3563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
if [ ! -d exercises ]; then | |
echo "Must be run from the project root directory." | |
exit 1 | |
fi | |
build() { | |
zig build -Dhealed -Dhealed-path=patches/tmp -Dn="$1" | |
zig_ret=$? | |
if [ "$zig_ret" -eq 0 ]; then | |
echo "expected error" | |
exit 1 | |
fi | |
} | |
printf "1. Test FileNotFound error\n" | |
rm -rf patches/tmp | |
build 1 | |
printf "\n\n2. Test unexpected exit code\n" | |
mkdir -p patches/tmp | |
cat << EOF > patches/tmp/001_hello.zig | |
const std = @import("std"); | |
pub fn main() void { | |
std.os.exit(10); | |
} | |
EOF | |
build 1 | |
rm -rd patches/tmp | |
printf "\n\n3. Test unexpected termination\n" | |
mkdir -p patches/tmp | |
cat << EOF > patches/tmp/001_hello.zig | |
const std = @import("std"); | |
pub fn main() void { | |
std.os.abort(); | |
} | |
EOF | |
build 1 | |
rm -rd patches/tmp | |
printf "\n\n4. Test unexpected output\n" | |
mkdir -p patches/tmp | |
cat << EOF > patches/tmp/001_hello.zig | |
const std = @import("std"); | |
pub fn main() void { | |
std.debug.print("this is a test", .{}); | |
} | |
EOF | |
build 1 | |
rm -rd patches/tmp | |
printf "\n\n5. Test zig test failure\n" | |
mkdir -p patches/tmp | |
cat << EOF > patches/tmp/102_testing.zig | |
const std = @import("std"); | |
test "this is a test" { | |
try std.testing.expect(false); | |
} | |
EOF | |
build 102 | |
rm -rd patches/tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment