refactored the testing system, fixed fput and removed arr_asm.sl

This commit is contained in:
igor
2026-02-16 14:32:13 +01:00
parent 02f54b8f86
commit 81ee4a8ff9
55 changed files with 683 additions and 376 deletions

View File

@@ -1 +0,0 @@
python main.py tests/alloc.sl -o ./build/alloc > /dev/null && ./build/alloc

View File

@@ -1 +0,0 @@
python main.py tests/arr_dynamic.sl -o ./build/arr_dynamic > /dev/null && ./build/arr_dynamic

View File

@@ -1 +0,0 @@
python main.py tests/bss_override.sl -o ./build/bss_override > /dev/null && ./build/bss_override

View File

@@ -1 +0,0 @@
python main.py tests/core_bitops.sl -o ./build/core_bitops > /dev/null && ./build/core_bitops

View File

@@ -1 +0,0 @@
python main.py tests/else_if_shorthand.sl -o ./build/else_if_shorthand > /dev/null && ./build/else_if_shorthand

View File

@@ -1 +0,0 @@
hello stderr

1
tests/eputs.stderr Normal file
View File

@@ -0,0 +1 @@
hello stderr

View File

@@ -1 +0,0 @@
python main.py tests/eputs.sl -o ./build/eputs > /dev/null && ./build/eputs 2>&1

View File

@@ -1 +0,0 @@
python main.py tests/fib.sl -o ./build/fib > /dev/null && ./build/fib

View File

@@ -1 +0,0 @@
python main.py tests/goto.sl -o ./build/goto > /dev/null && ./build/goto

View File

@@ -1 +0,0 @@
python main.py tests/hello.sl -o ./build/hello > /dev/null && ./build/hello

View File

@@ -1 +0,0 @@
python main.py tests/here.sl -o ./build/here > /dev/null && ./build/here

View File

@@ -1 +0,0 @@
python main.py tests/inline.sl -o ./build/inline > /dev/null && ./build/inline

View File

@@ -1 +0,0 @@
python main.py tests/integration_core.sl -o ./build/integration_core > /dev/null && ./build/integration_core

View File

@@ -1 +0,0 @@
python main.py tests/io_read_file.sl -o ./build/io_read_file > /dev/null && ./build/io_read_file

View File

@@ -0,0 +1 @@
stdin via test

View File

@@ -1 +0,0 @@
python main.py tests/io_read_stdin.sl -o ./build/io_read_stdin > /dev/null && printf 'stdin via test\n' | ./build/io_read_stdin

View File

@@ -1 +0,0 @@
python main.py tests/io_write_buf.sl -o ./build/io_write_buf > /dev/null && ./build/io_write_buf

View File

@@ -1 +0,0 @@
python main.py tests/io_write_file.sl -o ./build/io_write_file > /dev/null && ./build/io_write_file

View File

@@ -1 +0,0 @@
python main.py tests/jmp_test.sl -o ./build/jmp_test > /dev/null && ./build/jmp_test

View File

@@ -1 +0,0 @@
python main.py tests/list.sl -o ./build/list > /dev/null && ./build/list

View File

@@ -1 +0,0 @@
python main.py tests/loop_while.sl -o ./build/loop_while > /dev/null && ./build/loop_while

View File

@@ -1 +0,0 @@
python main.py tests/loops_and_cmp.sl -o ./build/loops_and_cmp > /dev/null && ./build/loops_and_cmp

View File

@@ -1 +0,0 @@
python main.py tests/mem.sl -o ./build/mem > /dev/null && ./build/mem

View File

@@ -1 +0,0 @@
python main.py tests/override_dup_compile_time.sl -o ./build/override_dup_compile_time > /dev/null && ./build/override_dup_compile_time

View File

@@ -1 +0,0 @@
python main.py tests/rule110.sl -o ./build/rule110 > /dev/null && ./build/rule110

View File

@@ -1 +0,0 @@
python main.py tests/str.sl -o ./build/str > /dev/null && ./build/str

View File

@@ -1 +0,0 @@
python main.py tests/string_puts.sl -o ./build/string_puts > /dev/null && ./build/string_puts

View File

@@ -1 +0,0 @@
python main.py tests/syscall_write.sl -o ./build/syscall_write > /dev/null && ./build/syscall_write

View File

@@ -1,87 +0,0 @@
#!/usr/bin/python
import sys
import os
import subprocess
import platform
import re
COLORS = {
"red": "\033[91m",
"green": "\033[92m",
"yellow": "\033[93m",
"blue": "\033[94m",
"reset": "\033[0m"
}
def print_colored(text, color):
print(COLORS.get(color, "") + text + COLORS["reset"], end="")
def _is_arm_host():
machine = platform.machine().lower()
return machine.startswith("arm") or machine.startswith("aarch")
def _wrap_qemu_for_arm(command):
if "qemu-x86_64" in command:
return command
pattern = re.compile(r"(^|\s*(?:&&|;)\s*)(\./\S+)")
def _repl(match):
prefix = match.group(1)
binary = match.group(2)
return f"{prefix}qemu-x86_64 {binary}"
return pattern.sub(_repl, command)
def run_tests():
test_dir = "tests"
any_failed = False
if not os.path.isdir(test_dir):
print("No 'tests' directory found.")
return 1
for file in sorted(os.listdir(test_dir)):
if file.endswith(".test"):
test_path = os.path.join(test_dir, file)
expected_path = test_path.replace(".test", ".expected")
if not os.path.isfile(expected_path):
print(f"Missing expected output file for {file}")
any_failed = True
continue
with open(test_path, "r") as test_file:
command = test_file.read().strip()
with open(expected_path, "r") as expected_file:
expected_output = expected_file.read().strip()
try:
run_command = _wrap_qemu_for_arm(command) if _is_arm_host() else command
result = subprocess.run(run_command, shell=True, text=True, capture_output=True)
actual_output = result.stdout.strip()
stderr_output = result.stderr.strip()
if result.returncode == 0 and actual_output == expected_output:
print_colored("[OK] ", "green")
print(f"{file} passed")
else:
print_colored("[ERR] ", "red")
print(f"{file} failed (exit {result.returncode})")
print(f"Expected:\n{expected_output}")
print(f"Got:\n{actual_output}")
if stderr_output:
print(f"Stderr:\n{stderr_output}")
any_failed = True
except Exception as e:
print_colored(f"Error running {file}: {e}", "red")
any_failed = True
print("All tests passed." if not any_failed else "Some tests failed.")
return 1 if any_failed else 0
if __name__ == "__main__":
sys.exit(run_tests())

View File

@@ -1 +0,0 @@
python main.py tests/typeconversion.sl -o ./build/typeconversion > /dev/null && ./build/typeconversion

View File

@@ -1 +0,0 @@
python main.py tests/with_variables.sl -o ./build/with_variables > /dev/null && ./build/with_variables