ocaml bindings for chibi-scheme VM
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

document upstream test runner for 0.1.1

+40 -28
+32 -4
README.md
··· 4 4 small, embeddable R7RS Scheme implementation. 5 5 6 6 chibi-ocaml lets you embed one or more sandboxed Scheme virtual machines in your 7 - OCaml programs. The chibi-scheme runtime is vendored and compiled automatically 8 - -- no system-level installation of chibi-scheme is required. But a C compiler capable of building chibi-scheme is required. 7 + OCaml programs. The chibi-scheme runtime is vendored and compiled automatically, 8 + so no system-level installation of chibi-scheme is required. A C compiler capable 9 + of building chibi-scheme is still required. 9 10 10 11 ## Features 11 12 12 - - **Full R7RS Scheme** -- the complete chibi-scheme 0.12.0 interpreter 13 + - **Embedded chibi-scheme runtime** -- based on vendored chibi-scheme 0.12.0 sources 13 14 - **Multiple independent VMs** -- each `Context.t` has its own heap 14 15 - **Configurable memory limits** -- set initial and maximum heap sizes 15 16 - **Capability-based sandboxing** -- whitelist file, network, process, and I/O access ··· 31 32 git clone https://github.com/username/chibi-ocaml.git 32 33 cd chibi-ocaml 33 34 dune build 34 - dune runtest # 97 binding tests + chibi's own 8000+ tests 35 + dune runtest 35 36 ``` 37 + 38 + ## Running Upstream chibi Tests 39 + 40 + The repository includes a runner for executing upstream `chibi-scheme` test 41 + files through the OCaml bindings. 42 + 43 + If you have an upstream checkout at `~/data/src/chibi-scheme`, run: 44 + 45 + ```sh 46 + dune exec test_runner/run_chibi_tests.exe 47 + ``` 48 + 49 + The runner looks for tests in this order: 50 + 51 + - `CHIBI_TEST_ROOT` 52 + - `~/data/src/chibi-scheme` 53 + - `vendor/chibi-scheme` 54 + 55 + To point at a different checkout: 56 + 57 + ```sh 58 + CHIBI_TEST_ROOT=/path/to/chibi-scheme dune exec test_runner/run_chibi_tests.exe 59 + ``` 60 + 61 + This runner is intended to compare embedded behavior with native 62 + `chibi-scheme` on the same test files. If a suite fails, check whether it also 63 + fails in the upstream checkout before treating it as a bindings regression. 36 64 37 65 ## Quick Start 38 66
+1 -1
chibi-ocaml.opam
··· 1 1 # This file is generated by dune, edit dune-project instead 2 2 opam-version: "2.0" 3 - version: "0.1.0" 3 + version: "0.1.1" 4 4 synopsis: "OCaml bindings for chibi-scheme, an embeddable R7RS Scheme VM" 5 5 description: 6 6 "chibi-ocaml provides OCaml bindings to the chibi-scheme interpreter, allowing you to embed one or more sandboxed Scheme VMs in your OCaml programs. Features include configurable memory limits, capability-based sandboxing, effect-based streaming, and full R7RS support. The chibi-scheme runtime is vendored and compiled automatically - no system installation required."
+1 -1
dune-project
··· 2 2 3 3 (name chibi-ocaml) 4 4 5 - (version 0.1.0) 5 + (version 0.1.1) 6 6 7 7 (generate_opam_files true) 8 8
+2 -11
lib/chibi.ml
··· 234 234 try Chibi_ffi.env_define ctx name void with _ -> () 235 235 ) names 236 236 237 - (** Install sandbox restrictions by overriding dangerous bindings with 238 - void and redirecting I/O ports. 239 - 240 - The sandbox enforces restrictions on the interaction environment after 241 - the standard library has been loaded. Each capability that is NOT 242 - granted causes the corresponding bindings to be replaced with void. 243 - 244 - This covers bindings from (scheme base), (scheme file), 245 - (chibi filesystem), (chibi process), (chibi net), (chibi system), 246 - (chibi shell), (scheme process-context), (scheme eval), (scheme load), 247 - and related modules. *) 237 + (** Install sandbox restrictions by overriding selected bindings with void 238 + and redirecting I/O ports. *) 248 239 let apply_sandbox (t : t) = 249 240 let sandbox = t.sandbox in 250 241 let ctx = t.raw in
+4 -11
test_runner/run_chibi_tests.ml
··· 1 - (** Run the chibi-scheme test suites through our OCaml bindings. 2 - 3 - This program exercises the full chibi-scheme test infrastructure 4 - through the chibi-ocaml library, verifying that the embedded VM 5 - can correctly execute all the standard tests. *) 1 + (** Run selected upstream chibi-scheme test suites through the OCaml bindings. *) 6 2 7 3 open Chibi_ocaml.Chibi 8 4 module Ffi = Chibi_ocaml.Chibi_ffi ··· 43 39 let tests_dir = Filename.concat test_root "tests" 44 40 let lib_dir = Filename.concat test_root "lib" 45 41 46 - (** Create a context suitable for running tests. 47 - Full access, with module path pointing at vendored lib. *) 42 + (** Create a context suitable for running tests. *) 48 43 let make_test_context ?(max_heap = 64 * 1024 * 1024) () = 49 44 Unix.putenv "CHIBI_MODULE_PATH" lib_dir; 50 45 let config = Context.{ ··· 64 59 let eval_capturing_output ctx code = 65 60 Io.capture ctx (fun () -> Eval.string ctx code) 66 61 67 - (** Load a .scm file and capture its output. 68 - Uses load_direct to properly handle top-level import forms. *) 62 + (** Load a .scm file and capture its output. *) 69 63 let load_capturing_output ctx file = 70 64 Io.capture ctx (fun () -> Eval.load_direct ctx file) 71 65 72 - (** Evaluate multi-expression code by writing to a temp file and loading. 73 - This properly handles import and other top-level forms. *) 66 + (** Evaluate multi-expression code by writing to a temp file and loading. *) 74 67 let eval_multi_capturing_output ctx code = 75 68 let tmpfile = Filename.temp_file "chibi_test_" ".scm" in 76 69 Fun.protect ~finally:(fun () -> Sys.remove tmpfile) (fun () ->