Fix Julia, Lua, and OCaml test failures

- Julia: Rename test() to run_test() to avoid name collision
- Julia: Use lambda syntax instead of do-block for cleaner execution
- Lua: Fix signature format test - verify structure instead of counting colons
- OCaml: Use apt-get instead of failing setup-ocaml@v2 action
This commit is contained in:
Russell Ballestrini 2026-01-06 09:40:05 -05:00
parent a1eedc55ea
commit dc29e64196
3 changed files with 44 additions and 64 deletions

View file

@ -568,21 +568,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 5
- name: Install dependencies
- name: Install OCaml
run: |
opam install -y cohttp-lwt-unix yojson digestif || true
sudo apt-get update
sudo apt-get install -y ocaml
- name: Run OCaml tests
run: |
eval $(opam env)
ocaml str.cma unix.cma tests/test_un_ml.ml || true
run: ocaml str.cma unix.cma tests/test_un_ml.ml || true
- name: Integration test
if: env.UNSANDBOX_PUBLIC_KEY != ''
run: |
eval $(opam env)
ocaml un.ml test/fib.py 2>&1 | tee output.txt || true
ocaml str.cma unix.cma un.ml test/fib.py 2>&1 | tee output.txt || true
grep -q "fib(10) = 55" output.txt || echo "OCaml integration pending"
clojure:

View file

@ -7,7 +7,7 @@ using Base64
passed = Ref(0)
failed = Ref(0)
function test(name, fn)
function run_test(name, fn)
try
fn()
println(" ✓ $name")
@ -55,119 +55,105 @@ EXT_MAP = Dict(
println("\n=== Extension Mapping Tests ===")
test("Python extension maps correctly") do
assert_equal(EXT_MAP[".py"], "python")
end
run_test("Python extension maps correctly", () -> assert_equal(EXT_MAP[".py"], "python"))
test("Julia extension maps correctly") do
assert_equal(EXT_MAP[".jl"], "julia")
end
run_test("Julia extension maps correctly", () -> assert_equal(EXT_MAP[".jl"], "julia"))
test("JavaScript extension maps correctly") do
assert_equal(EXT_MAP[".js"], "javascript")
end
run_test("JavaScript extension maps correctly", () -> assert_equal(EXT_MAP[".js"], "javascript"))
test("Go extension maps correctly") do
assert_equal(EXT_MAP[".go"], "go")
end
run_test("Go extension maps correctly", () -> assert_equal(EXT_MAP[".go"], "go"))
test("R extensions map correctly") do
run_test("R extensions map correctly", () -> begin
assert_equal(EXT_MAP[".r"], "r")
assert_equal(EXT_MAP[".R"], "r")
end
end)
println("\n=== HMAC Signature Tests ===")
test("HMAC-SHA256 generates 64 character hex string") do
run_test("HMAC-SHA256 generates 64 character hex string", () -> begin
sig = bytes2hex(hmac_sha256("test-secret", "test-message"))
assert_equal(length(sig), 64)
end
end)
test("Same input produces same signature") do
run_test("Same input produces same signature", () -> begin
sig1 = bytes2hex(hmac_sha256("key", "msg"))
sig2 = bytes2hex(hmac_sha256("key", "msg"))
assert_equal(sig1, sig2)
end
end)
test("Different secrets produce different signatures") do
run_test("Different secrets produce different signatures", () -> begin
sig1 = bytes2hex(hmac_sha256("key1", "msg"))
sig2 = bytes2hex(hmac_sha256("key2", "msg"))
assert_not_equal(sig1, sig2)
end
end)
test("Signature format verification") do
run_test("Signature format verification", () -> begin
timestamp = "1704067200"
method = "POST"
endpoint = "/execute"
body = """{"language":"python"}"""
message = "$timestamp:$method:$endpoint:$body"
assert_true(startswith(message, timestamp))
assert_contains(message, ":POST:")
assert_contains(message, ":/execute:")
end
end)
println("\n=== Language Detection Tests ===")
test("Detect language from .jl extension") do
run_test("Detect language from .jl extension", () -> begin
ext = splitext("script.jl")[2]
assert_equal(EXT_MAP[ext], "julia")
end
end)
test("Python shebang detection") do
run_test("Python shebang detection", () -> begin
content = "#!/usr/bin/env python3\nprint('hello')"
first_line = split(content, "\n")[1]
assert_true(startswith(first_line, "#!"))
assert_contains(first_line, "python")
end
end)
println("\n=== Argument Parsing Tests ===")
test("Parse -e KEY=VALUE format") do
run_test("Parse -e KEY=VALUE format", () -> begin
arg = "DEBUG=1"
parts = split(arg, "=", limit=2)
key = parts[1]
value = parts[2]
assert_equal(key, "DEBUG")
assert_equal(value, "1")
end
assert_equal(parts[1], "DEBUG")
assert_equal(parts[2], "1")
end)
test("Parse -e KEY=VALUE with equals in value") do
run_test("Parse -e KEY=VALUE with equals in value", () -> begin
arg = "URL=https://example.com?foo=bar"
parts = split(arg, "=", limit=2)
key = parts[1]
value = parts[2]
assert_equal(key, "URL")
assert_equal(value, "https://example.com?foo=bar")
end
assert_equal(parts[1], "URL")
assert_equal(parts[2], "https://example.com?foo=bar")
end)
println("\n=== File Operations Tests ===")
test("Base64 encoding/decoding") do
run_test("Base64 encoding/decoding", () -> begin
content = "print('hello world')"
encoded = base64encode(content)
decoded = String(base64decode(encoded))
assert_equal(decoded, content)
end
end)
test("Extract file basename") do
run_test("Extract file basename", () -> begin
path = "/home/user/project/script.jl"
assert_equal(basename(path), "script.jl")
end
end)
test("Extract file extension") do
run_test("Extract file extension", () -> begin
path = "/home/user/project/script.jl"
assert_equal(splitext(path)[2], ".jl")
end
end)
println("\n=== API Constants Tests ===")
test("API base URL format") do
run_test("API base URL format", () -> begin
api_base = "https://api.unsandbox.com"
assert_true(startswith(api_base, "https://"))
assert_contains(api_base, "unsandbox.com")
end
end)
# Summary
println("\n=== Summary ===")

View file

@ -162,15 +162,14 @@ test("Signature format is timestamp:METHOD:path:body", function()
local timestamp = "1704067200"
local method = "POST"
local endpoint = "/execute"
local body = '{"language":"python","code":"print(1)"}'
local body = '{"language":"python"}'
local message = timestamp .. ":" .. method .. ":" .. endpoint .. ":" .. body
assert_contains(message, ":")
local count = 0
for _ in message:gmatch(":") do count = count + 1 end
assert_equal(count, 3)
-- Verify format by checking structure, not counting colons (body may contain colons)
assert_true(message:sub(1, #timestamp) == timestamp)
assert_contains(message, ":POST:")
assert_contains(message, ":/execute:")
end)
-- ============================================================================