3e7ab07e82
El SDK CI - dev / build-and-test (pull_request) Failing after 10m4s
Completes the Phase 1 runner and migrates the 11 test files onto it. - forward-declare the registry accessors in the test preamble; they are defined at the end of the unit but the El runner is compiled in between - eltest.el: explicit trailing return in the void emit_* helpers, which otherwise lower to 'return println(...)' and fail to compile - test files import runtime/eltest.el explicitly, using the language's own textual import mechanism rather than compiler-side auto-injection - DESIGN.md 6.5: gate on allocation COUNT AND BYTES, not count alone Verified: self-hosting fixpoint byte-identical (gen2 == gen3). 6 of 11 suites run and report per-test timing. The other 5 fail to COMPILE, and fail identically under the committed compiler -- pre-existing breakage this framework makes visible for the first time.
98 lines
3.4 KiB
EmacsLisp
98 lines
3.4 KiB
EmacsLisp
import "../../runtime/eltest.el"
|
|
// test_fs.el - native test suite for runtime/fs.el
|
|
//
|
|
// Covers: fs_write/read round-trip, fs_exists, fs_mkdir, fs_list,
|
|
// fs_list_json, and edge cases (empty file, overwrite, non-existent path).
|
|
|
|
test "fs-write-and-read" {
|
|
let path: String = "/tmp/el_test_fs_basic.txt"
|
|
let content: String = "hello from El"
|
|
let ok: Bool = fs_write(path, content)
|
|
assert ok, "fs_write returns true on success"
|
|
let got: String = fs_read(path)
|
|
assert got == content, "fs_read returns what was written"
|
|
}
|
|
|
|
test "fs-exists" {
|
|
let path: String = "/tmp/el_test_fs_exists.txt"
|
|
fs_write(path, "exists check")
|
|
let exists: Bool = fs_exists(path)
|
|
assert exists, "fs_exists returns true for created file"
|
|
let missing: Bool = fs_exists("/tmp/__el_no_such_file_xyz__.txt")
|
|
assert !missing, "fs_exists returns false for non-existent file"
|
|
}
|
|
|
|
test "fs-read-nonexistent" {
|
|
let got: String = fs_read("/tmp/__el_no_such_file_abc__.txt")
|
|
assert got == "", "reading nonexistent file returns empty string"
|
|
}
|
|
|
|
test "fs-write-overwrite" {
|
|
let path: String = "/tmp/el_test_fs_overwrite.txt"
|
|
fs_write(path, "original content")
|
|
fs_write(path, "new content")
|
|
let got: String = fs_read(path)
|
|
assert got == "new content", "second write overwrites first"
|
|
}
|
|
|
|
test "fs-write-empty-file" {
|
|
let path: String = "/tmp/el_test_fs_empty.txt"
|
|
let ok: Bool = fs_write(path, "")
|
|
assert ok, "writing empty file succeeds"
|
|
let got: String = fs_read(path)
|
|
assert got == "", "reading empty file returns empty string"
|
|
let exists: Bool = fs_exists(path)
|
|
assert exists, "empty file still exists"
|
|
}
|
|
|
|
test "fs-write-multiline" {
|
|
let path: String = "/tmp/el_test_fs_multiline.txt"
|
|
let content: String = "line one\nline two\nline three"
|
|
fs_write(path, content)
|
|
let got: String = fs_read(path)
|
|
assert got == content, "multiline content round-trips"
|
|
let lines: [String] = str_split_lines(got)
|
|
let n: Int = native_list_len(lines)
|
|
assert n == 3, "three lines after read"
|
|
}
|
|
|
|
test "fs-mkdir" {
|
|
let dir: String = "/tmp/el_test_fs_mkdir_dir"
|
|
let ok: Bool = fs_mkdir(dir)
|
|
assert ok, "fs_mkdir returns true"
|
|
let exists: Bool = fs_exists(dir)
|
|
assert exists, "created directory exists"
|
|
}
|
|
|
|
test "fs-list" {
|
|
let dir: String = "/tmp/el_test_fs_list_dir"
|
|
fs_mkdir(dir)
|
|
fs_write(dir + "/a.txt", "a")
|
|
fs_write(dir + "/b.txt", "b")
|
|
let files: [String] = fs_list(dir)
|
|
// Filter out empty strings from trailing newline
|
|
let n: Int = native_list_len(files)
|
|
// We expect at least 2 entries (a.txt and b.txt)
|
|
assert n >= 2, "fs_list returns at least 2 entries"
|
|
}
|
|
|
|
test "fs-list-json" {
|
|
let dir: String = "/tmp/el_test_fs_listjson_dir"
|
|
fs_mkdir(dir)
|
|
fs_write(dir + "/x.txt", "x")
|
|
fs_write(dir + "/y.txt", "y")
|
|
let result: String = fs_list_json(dir)
|
|
assert str_starts_with(result, "["), "fs_list_json returns JSON array"
|
|
assert str_ends_with(result, "]"), "fs_list_json JSON array is closed"
|
|
// Should contain at least one filename
|
|
assert str_len(result) > 2, "fs_list_json result is non-empty array"
|
|
}
|
|
|
|
test "fs-write-and-read-special-chars" {
|
|
let path: String = "/tmp/el_test_fs_special.txt"
|
|
let content: String = "tabs:\there\nnewlines: ok\n\"quoted\""
|
|
fs_write(path, content)
|
|
let got: String = fs_read(path)
|
|
assert got == content, "special chars in content round-trip"
|
|
}
|