update tests for new test spec.

temporarily disable tests (need to update tester)
This commit is contained in:
koniifer 2025-02-03 18:51:49 +00:00
parent d4cf4ba08b
commit 5957cbdf5c
16 changed files with 66 additions and 72 deletions

20
build
View file

@ -75,16 +75,16 @@ parse_args() {
target=$2
shift
;;
-u | --test)
test="all"
;;
--test=?*)
if [ "${1#*=}" = "none" ]; then warn "'--test=none' is redundant"; fi
test=${1#*=}
;;
--test=)
die "'--test=' requires a non-empty option argument"
;;
# -u | --test)
# test="all"
# ;;
# --test=?*)
# if [ "${1#*=}" = "none" ]; then warn "'--test=none' is redundant"; fi
# test=${1#*=}
# ;;
# --test=)
# die "'--test=' requires a non-empty option argument"
# ;;
--target=?*) target=${1#*=} ;;
--target=)
die "'--target=' requires a non-empty option argument"

View file

@ -2,37 +2,30 @@
tests are written in [src/test](../../src/test/)
1. tests that test the language will be in the [lang](../../src/test/lang) subdirectory
2. tests that test lily will be in the [lily](../../src/test/lily) subdirectory
3. all tests should return `u8`, `void`, or `bool` as a status code.
> follow standard status code practices for value.<br>
3. all tests should return any integer or boolean value.
> follow standard practices for exit code.<br>
> `0` for success, `1` for error, etc
4. all tests should contain the test specification at the top of the file
- all test arguments are optional
> tests with no arguments will always pass
- delimiting whitespace is optional, provided each test argument is prepended with a newline and a `*`
- `timeout` is formatted like `0.5s`. if a test exceeds this time, it will fail.
> tests with no arguments will always pas
- `timeout` is the max length a test can run before failing
- `args` are given to the application executable
- `exit` is the exit status of the program (return code)
5. if test compilation fails, the test will be considered failed
6. tests for lily should try to limit the number of unrelated structures/functions tested.
7. tests for lang should be headless (not rely on lily at all)
the following are all of the (currently) supported test arguments:
```rust
/*
* exit: u8
* args: str
* stdout: str
* timeout: time
*/
```
a trivial example test:
```rust
/*
* timeout: 0.5s
*/
expected := .{
exit: 0,
timeout: 0.5,
stdout: "",
args: .[]
}
main := fn(): void {
main := fn(): void {
// test will fail after 0.5s
loop {}
}
}
```

View file

@ -11,7 +11,7 @@ Generator := struct {
}
}
// inlining this breaks it :(
add := fn(sum: uint, x: uint): uint {
$add := fn(sum: uint, x: uint): uint {
return sum + x
}

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
generic := fn(v: @Any()): uint {
if @TypeOf(v) == uint {

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
index := fn(buf: @Any()): u8 {
b := buf[0]

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
opaque := fn(v: @Any()): bool {
return v < 0

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
A := struct {
inner: u8,

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
opaque := fn(): ^u8 {
return @bitcast(0)

View file

@ -1,7 +1,7 @@
/*
* exit: 10
* timeout: 1s
*/
expected := .{
exit: 0,
timeout: 1.0,
}
Vec := struct {
len: uint,

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
main := fn(): u8 {
return 0

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
opaque := fn(): ?^u8 {
return null

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
sum_days := .[0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]

View file

@ -1,6 +1,7 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
lily := @use("../../lily/lib.hb")
main := fn(): u8 {

View file

@ -1,6 +1,6 @@
/*
* exit: 0
*/
expected := .{
exit: 0,
}
lily := @use("../../lily/lib.hb")

View file

@ -1,7 +1,7 @@
/*
* exit: 0
* stdout: "Hello, World!"
*/
expected := .{
exit: 0,
stdout: "Hello, World!",
}
lily := @use("../../lily/lib.hb")

View file

@ -1,7 +1,7 @@
/*
* stdout: Hello, World!
* exit: 0
*/
expected := .{
exit: 0,
stdout: "Hello, World!",
}
lily := @use("../../lily/lib.hb")