Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the test runner #3646

Merged
merged 90 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
8ae375d
Move log timestamping out to `do_time_header` proc
Feoramund May 23, 2024
7d4da6e
Fix trailing space with only `.Date` log option
Feoramund May 23, 2024
1875e7c
Make `log.do_*_header` argument orders consistent
Feoramund May 27, 2024
558c330
Add task-stopping functionality to `thread.Pool`
Feoramund May 23, 2024
8137b9d
Add `mem.tracking_allocator_reset`
Feoramund May 23, 2024
fc4f6b8
Add `core:encoding/ansi` package
Feoramund May 27, 2024
50dffaf
Add `mem.Rollback_Stack`
Feoramund May 27, 2024
95c2e02
Share `libc` signal definitions with more platforms
Feoramund May 27, 2024
b6c4dfb
Refactor the test runner
Feoramund May 27, 2024
d030240
Remove unneeded code
Feoramund May 28, 2024
87ea4a2
Temporarily disable Windows-specific test runner
Feoramund May 28, 2024
852f694
Get tests passing again
Feoramund May 28, 2024
eb3d6d7
Update `core:image` tests to use new runner.
Kelimion May 29, 2024
22c092f
Delete duplicated flag.
Kelimion May 29, 2024
e3181c1
Update `core:compress` tests
Kelimion May 29, 2024
a463e28
Update `core:container` tests
Kelimion May 29, 2024
a0b2ea6
Update `tests\core\crypto`
Kelimion May 29, 2024
568b746
Fix indentation
Feoramund May 28, 2024
0f675fa
Use `uintptr` where applicable in `mem.Rollback_Stack`
Feoramund May 28, 2024
09ef08f
Add more sanity checking to `mem.Rollback_Stack`
Feoramund May 28, 2024
1afc235
Use plain sort for `internal_tests`
Feoramund May 28, 2024
eadfbb1
Forbid singleton allocations from shrinking their block offset
Feoramund May 28, 2024
dffc3af
Remove `safe_heap_allocator` from test runner
Feoramund May 28, 2024
89d8df2
Combine multi-line attributes onto one line
Feoramund May 28, 2024
a1c5beb
Fix ANSI redraw eating last log line
Feoramund May 29, 2024
dcfda19
Send terminal control code to `STDOUT` instead
Feoramund May 29, 2024
e11f3d2
Fix missing `-` for define in `tests/core/build.bat`
Feoramund May 29, 2024
b7e1ae7
Change test runner options to `SCREAMING_SNAKE_CASE`
Feoramund May 29, 2024
c531427
Update -define for `crypto`
Kelimion May 29, 2024
bf42e39
Be specific about `int` size for `Rollback_Stack` asserts
Feoramund May 29, 2024
e1a3c0e
Track memory in the test runner by default
Feoramund May 29, 2024
49fa663
Report test memory usage only if there's an issue
Feoramund May 29, 2024
84ad71f
Support `ODIN_TEST_PROGRESS_WIDTH=0`
Feoramund May 29, 2024
6a1649d
Update using new defaults for memory + reporting width
Kelimion May 29, 2024
a27b167
Update `tests\core\encoding\cbor` to use new test runner.
Kelimion May 30, 2024
1f6a6f2
Support deterministic random seeding of tests
Feoramund May 29, 2024
b74b956
Remove unneeded import
Feoramund May 29, 2024
40b20fb
Port `tests\core\c\libc`
Kelimion May 30, 2024
3404dea
Port `tests\encoding\hex`
Kelimion May 30, 2024
1b32e27
Port `tests\core\encoding\hxa`
Kelimion May 30, 2024
601df0e
Port `tests\core\encoding\json`
Kelimion May 30, 2024
6641a6f
Port `tests\core\encoding\varint`
Kelimion May 30, 2024
9d0f483
Port `tests\core\encoding\xml`
Kelimion May 30, 2024
d334b8c
Port `tests\core\path\filepath`
Kelimion May 30, 2024
6f7c5a7
Port `tests\core\fmt`
Kelimion May 30, 2024
39fd73f
Port `testing\core\hash`
Kelimion May 30, 2024
d7bfbe0
Port `testing\core\text\i18n`
Kelimion May 30, 2024
b0faab2
Port `tests\core\math`, `math\linalg\glsl` and `math\noise`
Kelimion May 30, 2024
8383a45
Port `tests\core\text\match`
Kelimion May 30, 2024
9829a02
Port `tests\core\odin`
Kelimion May 30, 2024
80b1157
Port `tests\core\reflect`
Kelimion May 30, 2024
ed0384c
Port `tests\core\runtime`
Kelimion May 30, 2024
9ba02e8
Port `tests\core\slice`
Kelimion May 30, 2024
a406ff7
Port `tests\core\strings`
Kelimion May 30, 2024
5b1ffba
Port `testing\core\time`
Kelimion May 30, 2024
dacb0f7
Port `tests\core\thread`
Kelimion May 31, 2024
62b7d8d
Port `tests\core\net`
Kelimion May 31, 2024
8d93379
Factor benchmarks out into tests\benchmark\<pkg>
Kelimion May 31, 2024
54dae06
Update CI
Kelimion May 31, 2024
3354212
Update ci.yml
Kelimion May 31, 2024
3061696
Update ci.yml
Kelimion Jun 1, 2024
6050bc3
Add missing benchmarks build.bat.
Kelimion Jun 1, 2024
fb37572
Rename `signal_handler.odin` to `signal_handler_libc.odin`
Feoramund May 30, 2024
d172366
Catch `SIGILL`, `SIGFPE`, `SIGSEGV` in the test runner
Feoramund May 30, 2024
433ca53
Be specific about platforms not implementing test runner signal handler
Feoramund May 30, 2024
6a5d51f
Use more concise way of satisfying `-vet`
Feoramund May 31, 2024
cb8faf5
Remove `-test-name` in favor of test runner option
Feoramund Jun 1, 2024
45fa9d8
Expand documentation comment for `ODIN_TEST_NAMES`
Feoramund Jun 1, 2024
21064fb
Clear thread pool task data on restart
Feoramund Jun 1, 2024
9dcf345
Set thread pool `is_running` to false on shutdown
Feoramund Jun 1, 2024
ccdbd4b
Simplify casts in `mem.Rollback_Stack` procs
Feoramund Jun 1, 2024
4875f74
Remove Windows test runner in favor of `libc` implementation
Feoramund Jun 1, 2024
cb00b80
Add note about `SIGSEGV` edge case on UNIX-likes
Feoramund Jun 1, 2024
5db65aa
Make it easier to learn about `ODIN_TEST_CLIPBOARD`
Feoramund Jun 1, 2024
6a92033
Log thread count at test run start
Feoramund Jun 1, 2024
5e3e958
Add `-define:ODIN_TEST_LOG_LEVEL` to set lowest log level
Feoramund Jun 1, 2024
d581dbb
Keep test runner main thread from using 100% of a CPU core
Feoramund Jun 1, 2024
890fe07
Disable `FANCY_OUTPUT` in Odin test scripts
Feoramund Jun 1, 2024
21a1ddf
Disable NetBSD tests until 'undefined reference to stdout' is solved.
Kelimion Jun 2, 2024
9d8d864
Plug leak in AES tests.
Kelimion Jun 2, 2024
60d0c03
Strip old test runner back out of `internal`, `issues` and `vendor`
Kelimion Jun 2, 2024
8d8c42e
Use `T.seed` in tests where applicable
Feoramund Jun 2, 2024
3f1249c
Tell user about `ODIN_TEST_RANDOM_SEED` option
Feoramund Jun 2, 2024
f77ce35
Be pedantic about not overwriting Odin errors
Feoramund Jun 2, 2024
ac94842
Fix `STDIN`, `STDOUT`, `STDERR` handles for BSDs
Feoramund Jun 2, 2024
c8539fe
Revert "Disable NetBSD tests until 'undefined reference to stdout' is…
Feoramund Jun 2, 2024
6a5633d
Fix wrong `PTHREAD_CANCEL_ASYNCHRONOUS` on FreeBSD and OpenBSD
Feoramund Jun 3, 2024
7764ab2
Prevent test runner deadlock on NetBSD
Feoramund Jun 3, 2024
fa29974
Use `Warning` log level for reporting memory leaks
Feoramund Jun 3, 2024
0ff130d
Fix ad hoc `printf` in test runner signal handler
Feoramund Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
(cd tests/core; gmake all_bsd)
(cd tests/internal; gmake all_bsd)
(cd tests/issues; ./run.sh)
(cd tests/benchmark; gmake all)
build_linux:
name: Ubuntu Build, Check, and Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -80,6 +81,11 @@ jobs:
cd tests/internal
make
timeout-minutes: 10
- name: Odin core library benchmarks
run: |
cd tests/benchmark
make
timeout-minutes: 10
- name: Odin check examples/all for Linux i386
run: ./odin check examples/all -vet -strict-style -target:linux_i386
timeout-minutes: 10
Expand Down Expand Up @@ -131,6 +137,11 @@ jobs:
cd tests/internal
make
timeout-minutes: 10
- name: Odin core library benchmarks
run: |
cd tests/benchmark
make
timeout-minutes: 10
build_macOS_arm:
name: MacOS ARM Build, Check, and Test
runs-on: macos-14 # This is an arm/m1 runner.
Expand Down Expand Up @@ -170,6 +181,11 @@ jobs:
cd tests/internal
make
timeout-minutes: 10
- name: Odin core library benchmarks
run: |
cd tests/benchmark
make
timeout-minutes: 10
build_windows:
name: Windows Build, Check, and Test
runs-on: windows-2022
Expand Down Expand Up @@ -217,6 +233,13 @@ jobs:
cd tests\core
call build.bat
timeout-minutes: 10
- name: Core library benchmarks
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
cd tests\benchmark
call build.bat
timeout-minutes: 10
- name: Vendor library tests
shell: cmd
run: |
Expand Down
4 changes: 2 additions & 2 deletions core/bufio/reader.odin
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ MIN_READ_BUFFER_SIZE :: 16
@(private)
DEFAULT_MAX_CONSECUTIVE_EMPTY_READS :: 128

reader_init :: proc(b: ^Reader, rd: io.Reader, size: int = DEFAULT_BUF_SIZE, allocator := context.allocator) {
reader_init :: proc(b: ^Reader, rd: io.Reader, size: int = DEFAULT_BUF_SIZE, allocator := context.allocator, loc := #caller_location) {
size := size
size = max(size, MIN_READ_BUFFER_SIZE)
reader_reset(b, rd)
b.buf_allocator = allocator
b.buf = make([]byte, size, allocator)
b.buf = make([]byte, size, allocator, loc)
}

reader_init_with_buf :: proc(b: ^Reader, rd: io.Reader, buf: []byte) {
Expand Down
70 changes: 35 additions & 35 deletions core/bytes/buffer.odin
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ Read_Op :: enum i8 {
}


buffer_init :: proc(b: ^Buffer, buf: []byte) {
resize(&b.buf, len(buf))
buffer_init :: proc(b: ^Buffer, buf: []byte, loc := #caller_location) {
resize(&b.buf, len(buf), loc=loc)
copy(b.buf[:], buf)
}

buffer_init_string :: proc(b: ^Buffer, s: string) {
resize(&b.buf, len(s))
buffer_init_string :: proc(b: ^Buffer, s: string, loc := #caller_location) {
resize(&b.buf, len(s), loc=loc)
copy(b.buf[:], s)
}

buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator) {
buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator, loc := #caller_location) {
if b.buf == nil {
b.buf = make([dynamic]byte, len, cap, allocator)
b.buf = make([dynamic]byte, len, cap, allocator, loc)
return
}

Expand Down Expand Up @@ -96,28 +96,28 @@ buffer_truncate :: proc(b: ^Buffer, n: int) {
}

@(private)
_buffer_try_grow :: proc(b: ^Buffer, n: int) -> (int, bool) {
_buffer_try_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) -> (int, bool) {
if l := len(b.buf); n <= cap(b.buf)-l {
resize(&b.buf, l+n)
resize(&b.buf, l+n, loc=loc)
return l, true
}
return 0, false
}

@(private)
_buffer_grow :: proc(b: ^Buffer, n: int) -> int {
_buffer_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) -> int {
m := buffer_length(b)
if m == 0 && b.off != 0 {
buffer_reset(b)
}
if i, ok := _buffer_try_grow(b, n); ok {
if i, ok := _buffer_try_grow(b, n, loc=loc); ok {
return i
}

if b.buf == nil && n <= SMALL_BUFFER_SIZE {
// Fixes #2756 by preserving allocator if already set on Buffer via init_buffer_allocator
reserve(&b.buf, SMALL_BUFFER_SIZE)
resize(&b.buf, n)
reserve(&b.buf, SMALL_BUFFER_SIZE, loc=loc)
resize(&b.buf, n, loc=loc)
return 0
}

Expand All @@ -127,31 +127,31 @@ _buffer_grow :: proc(b: ^Buffer, n: int) -> int {
} else if c > max(int) - c - n {
panic("bytes.Buffer: too large")
} else {
resize(&b.buf, 2*c + n)
resize(&b.buf, 2*c + n, loc=loc)
copy(b.buf[:], b.buf[b.off:])
}
b.off = 0
resize(&b.buf, m+n)
resize(&b.buf, m+n, loc=loc)
return m
}

buffer_grow :: proc(b: ^Buffer, n: int) {
buffer_grow :: proc(b: ^Buffer, n: int, loc := #caller_location) {
if n < 0 {
panic("bytes.buffer_grow: negative count")
}
m := _buffer_grow(b, n)
resize(&b.buf, m)
m := _buffer_grow(b, n, loc=loc)
resize(&b.buf, m, loc=loc)
}

buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.Error) {
buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int, loc := #caller_location) -> (n: int, err: io.Error) {
b.last_read = .Invalid
if offset < 0 {
err = .Invalid_Offset
return
}
_, ok := _buffer_try_grow(b, offset+len(p))
_, ok := _buffer_try_grow(b, offset+len(p), loc=loc)
if !ok {
_ = _buffer_grow(b, offset+len(p))
_ = _buffer_grow(b, offset+len(p), loc=loc)
}
if len(b.buf) <= offset {
return 0, .Short_Write
Expand All @@ -160,47 +160,47 @@ buffer_write_at :: proc(b: ^Buffer, p: []byte, offset: int) -> (n: int, err: io.
}


buffer_write :: proc(b: ^Buffer, p: []byte) -> (n: int, err: io.Error) {
buffer_write :: proc(b: ^Buffer, p: []byte, loc := #caller_location) -> (n: int, err: io.Error) {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, len(p))
m, ok := _buffer_try_grow(b, len(p), loc=loc)
if !ok {
m = _buffer_grow(b, len(p))
m = _buffer_grow(b, len(p), loc=loc)
}
return copy(b.buf[m:], p), nil
}

buffer_write_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int) -> (n: int, err: io.Error) {
return buffer_write(b, ([^]byte)(ptr)[:size])
buffer_write_ptr :: proc(b: ^Buffer, ptr: rawptr, size: int, loc := #caller_location) -> (n: int, err: io.Error) {
return buffer_write(b, ([^]byte)(ptr)[:size], loc=loc)
}

buffer_write_string :: proc(b: ^Buffer, s: string) -> (n: int, err: io.Error) {
buffer_write_string :: proc(b: ^Buffer, s: string, loc := #caller_location) -> (n: int, err: io.Error) {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, len(s))
m, ok := _buffer_try_grow(b, len(s), loc=loc)
if !ok {
m = _buffer_grow(b, len(s))
m = _buffer_grow(b, len(s), loc=loc)
}
return copy(b.buf[m:], s), nil
}

buffer_write_byte :: proc(b: ^Buffer, c: byte) -> io.Error {
buffer_write_byte :: proc(b: ^Buffer, c: byte, loc := #caller_location) -> io.Error {
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, 1)
m, ok := _buffer_try_grow(b, 1, loc=loc)
if !ok {
m = _buffer_grow(b, 1)
m = _buffer_grow(b, 1, loc=loc)
}
b.buf[m] = c
return nil
}

buffer_write_rune :: proc(b: ^Buffer, r: rune) -> (n: int, err: io.Error) {
buffer_write_rune :: proc(b: ^Buffer, r: rune, loc := #caller_location) -> (n: int, err: io.Error) {
if r < utf8.RUNE_SELF {
buffer_write_byte(b, byte(r))
buffer_write_byte(b, byte(r), loc=loc)
return 1, nil
}
b.last_read = .Invalid
m, ok := _buffer_try_grow(b, utf8.UTF_MAX)
m, ok := _buffer_try_grow(b, utf8.UTF_MAX, loc=loc)
if !ok {
m = _buffer_grow(b, utf8.UTF_MAX)
m = _buffer_grow(b, utf8.UTF_MAX, loc=loc)
}
res: [4]byte
res, n = utf8.encode_rune(r)
Expand Down
2 changes: 1 addition & 1 deletion core/c/libc/signal.odin
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ when ODIN_OS == .Windows {
SIGTERM :: 15
}

when ODIN_OS == .Linux || ODIN_OS == .FreeBSD {
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Haiku || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
SIG_ERR :: rawptr(~uintptr(0))
SIG_DFL :: rawptr(uintptr(0))
SIG_IGN :: rawptr(uintptr(1))
Expand Down
14 changes: 8 additions & 6 deletions core/c/libc/stdio.odin
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ when ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
SEEK_END :: 2

foreign libc {
stderr: ^FILE
stdin: ^FILE
stdout: ^FILE
__sF: [3]FILE
}

stdin: ^FILE = &__sF[0]
stdout: ^FILE = &__sF[1]
stderr: ^FILE = &__sF[2]
}

when ODIN_OS == .FreeBSD {
Expand All @@ -127,9 +129,9 @@ when ODIN_OS == .FreeBSD {
SEEK_END :: 2

foreign libc {
stderr: ^FILE
stdin: ^FILE
stdout: ^FILE
@(link_name="__stderrp") stderr: ^FILE
@(link_name="__stdinp") stdin: ^FILE
@(link_name="__stdoutp") stdout: ^FILE
}
}

Expand Down
Loading