Change test runner options to SCREAMING_SNAKE_CASE

This commit also changes the name of `test_select` to `ODIN_TEST_NAMES`,
to better conform with the already-existing `-test-name:<name>` option.
This commit is contained in:
Feoramund
2024-05-29 15:50:16 -04:00
parent e11f3d2520
commit b7e1ae7073
4 changed files with 22 additions and 22 deletions

View File

@@ -23,19 +23,19 @@ _ :: pkg_log
_ :: strings
// Specify how many threads to use when running tests.
TEST_THREADS : int : #config(test_threads, 0)
TEST_THREADS : int : #config(ODIN_TEST_THREADS, 0)
// Track the memory used by each test.
TRACKING_MEMORY : bool : #config(test_track_memory, false)
TRACKING_MEMORY : bool : #config(ODIN_TEST_TRACK_MEMORY, false)
// Specify how much memory each thread allocator starts with.
PER_THREAD_MEMORY : int : #config(test_thread_memory, mem.ROLLBACK_STACK_DEFAULT_BLOCK_SIZE)
PER_THREAD_MEMORY : int : #config(ODIN_TEST_THREAD_MEMORY, mem.ROLLBACK_STACK_DEFAULT_BLOCK_SIZE)
// Select a specific set of tests to run by name.
TEST_SELECT : string : #config(test_select, "")
TEST_NAMES : string : #config(ODIN_TEST_NAMES, "")
// Show the fancy animated progress report.
FANCY_OUTPUT : bool : #config(test_fancy, true)
FANCY_OUTPUT : bool : #config(ODIN_TEST_FANCY, true)
// Copy failed tests to the clipboard when done.
USE_CLIPBOARD : bool : #config(test_clipboard, false)
USE_CLIPBOARD : bool : #config(ODIN_TEST_CLIPBOARD, false)
// How many test results to show at a time per package.
PROGRESS_WIDTH : int : #config(test_progress_width, 24)
PROGRESS_WIDTH : int : #config(ODIN_TEST_PROGRESS_WIDTH, 24)
end_t :: proc(t: ^T) {
@@ -122,12 +122,12 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
alloc_error: mem.Allocator_Error
when TEST_SELECT != "" {
when TEST_NAMES != "" {
select_internal_tests: [dynamic]Internal_Test
defer delete(select_internal_tests)
{
index_list := TEST_SELECT
index_list := TEST_NAMES
for selector in strings.split_iterator(&index_list, ",") {
// Temp allocator is fine since we just need to identify which test it's referring to.
split_selector := strings.split(selector, ".", context.temp_allocator)
@@ -640,7 +640,7 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
if total_success_count > 0 {
when USE_CLIPBOARD {
clipboard_writer := io.to_writer(bytes.buffer_to_stream(&clipboard_buffer))
fmt.wprint(clipboard_writer, "-define:test_select=")
fmt.wprint(clipboard_writer, "-define:ODIN_TEST_NAMES=")
for test_index in sorted_failed_test_reasons {
#no_bounds_check it := internal_tests[test_index]
fmt.wprintf(clipboard_writer, "%s.%s,", it.pkg, it.name)
@@ -655,7 +655,7 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
"" if total_failure_count == 1 else "s",
" has" if total_failure_count == 1 else "s have")
} else {
fmt.wprintf(batch_writer, "\nTo run only the failed test%s, use:\n\t-define:test_select=",
fmt.wprintf(batch_writer, "\nTo run only the failed test%s, use:\n\t-define:ODIN_TEST_NAMES=",
"" if total_failure_count == 1 else "s")
for test_index in sorted_failed_test_reasons {
#no_bounds_check it := internal_tests[test_index]

View File

@@ -1,6 +1,6 @@
ODIN=../../odin
PYTHON=$(shell which python3)
COMMON=-no-bounds-check -vet -strict-style -define:test_track_memory=true
COMMON=-no-bounds-check -vet -strict-style -define:ODIN_TEST_TRACK_MEMORY=true
COLLECTION=-collection:tests=..
all: all_bsd \
@@ -34,13 +34,13 @@ download_test_assets:
$(PYTHON) download_assets.py
image_test:
$(ODIN) test image $(COMMON) -define:test_progress_width=12 -out:test_core_image
$(ODIN) test image $(COMMON) -define:ODIN_TEST_PROGRESS_WIDTH=12 -out:test_core_image
compress_test:
$(ODIN) test compress $(COMMON) -define:test_progress_width=3 -out:test_core_compress
$(ODIN) test compress $(COMMON) -define:ODIN_TEST_PROGRESS_WIDTH=3 -out:test_core_compress
container_test:
$(ODIN) test container $(COMMON) -define:test_progress_width=4 -out:test_core_container
$(ODIN) test container $(COMMON) -define:ODIN_TEST_PROGRESS_WIDTH=4 -out:test_core_container
crypto_test:
$(ODIN) test crypto $(COMMON) -define:test_progress_width=18 -o:speed -out:test_crypto

View File

@@ -1,17 +1,17 @@
@echo off
set COMMON=-no-bounds-check -vet -strict-style -define:test_track_memory=true
set COMMON=-no-bounds-check -vet -strict-style -define:ODIN_TEST_TRACK_MEMORY=true
set COLLECTION=-collection:tests=..
set PATH_TO_ODIN==..\..\odin
python3 download_assets.py
echo ---
echo Running core:compress tests
echo ---
%PATH_TO_ODIN% test compress %COMMON% -define:test_progress_width=3 -out:test_core_compress.exe || exit /b
%PATH_TO_ODIN% test compress %COMMON% -define:ODIN_TEST_PROGRESS_WIDTH=3 -out:test_core_compress.exe || exit /b
echo ---
echo Running core:container tests
echo ---
%PATH_TO_ODIN% test container %COMMON% -define:test_progress_width=4 -out:test_core_container.exe || exit /b
%PATH_TO_ODIN% test container %COMMON% -define:ODIN_TEST_PROGRESS_WIDTH=4 -out:test_core_container.exe || exit /b
echo ---
echo Running core:crypto tests
@@ -25,7 +25,7 @@ rem %PATH_TO_ODIN% run encoding/hxa %COMMON% %COLLECTION% -out:test_hxa.exe |
%PATH_TO_ODIN% run encoding/json %COMMON% -out:test_json.exe || exit /b
%PATH_TO_ODIN% run encoding/varint %COMMON% -out:test_varint.exe || exit /b
%PATH_TO_ODIN% run encoding/xml %COMMON% -out:test_xml.exe || exit /b
%PATH_TO_ODIN% test encoding/cbor %COMMON% -out:test_cbor.exe -define:test_threads=1 -define:test_fancy=false || exit /b
%PATH_TO_ODIN% test encoding/cbor %COMMON% -out:test_cbor.exe -define:ODIN_TEST_THREADS=1 -define:ODIN_TEST_FANCY=false || exit /b
%PATH_TO_ODIN% run encoding/hex %COMMON% -out:test_hex.exe || exit /b
%PATH_TO_ODIN% run encoding/base64 %COMMON% -out:test_base64.exe || exit /b
@@ -42,7 +42,7 @@ echo ---
echo ---
echo Running core:image tests
echo ---
%PATH_TO_ODIN% test image %COMMON% -define:test_progress_width=12 -out:test_core_image.exe || exit /b
%PATH_TO_ODIN% test image %COMMON% -define:ODIN_TEST_PROGRESS_WIDTH=12 -out:test_core_image.exe || exit /b
echo ---
echo Running core:math tests
@@ -107,4 +107,4 @@ echo ---
echo ---
echo Running core:time tests
echo ---
%PATH_TO_ODIN% run time %COMMON% %COLLECTION% -out:test_core_time.exe || exit /b
%PATH_TO_ODIN% run time %COMMON% %COLLECTION% -out:test_core_time.exe || exit /b

View File

@@ -1,2 +1,2 @@
@echo off
odin test . -define:test_track_memory=true -define:test_progress_width=12 -vet -strict-style
odin test . -define:ODIN_TEST_TRACK_MEMORY=true -define:ODIN_TEST_PROGRESS_WIDTH=12 -vet -strict-style