tests now properly report compilation errors

remove _w suffix from lily.Target functions
This commit is contained in:
koniifer 2025-02-01 01:55:42 +00:00
parent 48b788abf7
commit dce0ee996e
4 changed files with 32 additions and 8 deletions

11
build
View file

@ -185,8 +185,14 @@ EOF
run_test() {
file=$1 name=$2 output="" rc=0 failed=0
parse_test "$file"
hbc "$file" $hbc_flags >"$BUILD_PATH/test/$name.o" || return 1
$linker "$BUILD_PATH/test/$name.o" -o "$BUILD_PATH/test/$name" || return 1
hbc "$file" $hbc_flags >"$BUILD_PATH/test/$name.o" 2>&1
rc=$?
[ $rc -ne 0 ] && {
# todo: quiet mode to hide compilation errors.
error "$name: compilation failed: $(cat "$BUILD_PATH/test/$name.o")"
return 1
}
$linker "$BUILD_PATH/test/$name.o" -o "$BUILD_PATH/test/$name" || die "linking failed:"
if [ -n "$timeout_val" ]; then
output=$(timeout "$timeout_val" "$BUILD_PATH/test/$name" $args_input 2>&1)
@ -231,6 +237,7 @@ do_tests() {
wait
rm -r "$tmpfile" "$BUILD_PATH/test"
}
do_build() {
mkdir -p "$BUILD_PATH/$target" || die "failed to create $BUILD_PATH/$target"
[ -w "$BUILD_PATH/$target" ] || die "no write permission"

View file

@ -46,23 +46,23 @@ $panic := fn(message: ?[]u8): never {
// ! exit, memcpy, memmove, and memset are all temporary wrapper functions
$exit := fn(code: int): never {
Target.exit_w(code)
Target.exit(code)
die
}
$memcpy := fn(dest: @Any(), src: @Any(), size: uint): void {
if TypeOf(dest).kind() != .Pointer | TypeOf(src).kind() != .Pointer @error("memcpy requires a pointer")
Target.memcpy_w(@bitcast(dest), @bitcast(src), size)
Target.memcpy(@bitcast(dest), @bitcast(src), size)
}
$memmove := fn(dest: @Any(), src: @Any(), size: uint): void {
if TypeOf(dest).kind() != .Pointer | TypeOf(src).kind() != .Pointer @error("memmove requires a pointer")
Target.memmove_w(@bitcast(dest), @bitcast(src), size)
Target.memmove(@bitcast(dest), @bitcast(src), size)
}
$memset := fn(dest: @Any(), src: u8, size: uint): void {
if TypeOf(dest).kind() != .Pointer @error("memset requires a pointer")
Target.memset_w(@bitcast(dest), src, size)
Target.memset(@bitcast(dest), src, size)
}
_qs_partition := fn($func: type, array: @Any(), start: uint, end: uint): uint {

View file

@ -19,9 +19,8 @@ Target := enum {
.LibC => return Self.libc,
}
}
/* ! memmove, memcpy, memset, exit, currently suffixed with `_w` to distinguish them from the wrapper functions */;
/* todo: reorganise these */;
.{alloc, alloc_zeroed, realloc, dealloc, memmove: memmove_w, memcpy: memcpy_w, memset: memset_w, exit: exit_w, getrandom, page_size, calculate_pages, fork} := Self.Lib(Self.current());
.{alloc, alloc_zeroed, realloc, dealloc, memmove, memcpy, memset, exit, getrandom, page_size, calculate_pages, fork} := Self.Lib(Self.current());
.{printf_str} := Self.Lib(.LibC);
.{LogMsg} := Self.Lib(.AbleOS)
}

View file

@ -0,0 +1,18 @@
/*
* exit: 0
*/
lily := @use("../../lily/lib.hb")
main := fn(): u8 {
allocator := lily.alloc.RawAllocator.new()
defer allocator.deinit()
b := allocator.alloc(u8, 100)
if b == null return 1
c := allocator.alloc(u8, 100)
if c == null return 1
d := allocator.realloc(u8, c, 100)
if d == null return 1
if d != c return 1
return 0
}