···66# Third-party sources (fetch locally with opam source)
77third_party/
8899+# YAML test suite (clone manually to tests/ for running test suite)
1010+tests/yaml-test-suite/
1111+912# Editor and OS files
1013.DS_Store
1114*.swp
···7979yamlcat input.yaml
8080```
81818282+## Testing
8383+8484+Yamlrw is tested against the official [YAML Test Suite](https://github.com/yaml/yaml-test-suite), a comprehensive collection of YAML test cases.
8585+8686+### Running the Full Test Suite
8787+8888+To run the complete YAML test suite with HTML report generation:
8989+9090+1. **Clone the test suite** (one-time setup):
9191+ ```bash
9292+ cd tests
9393+ git clone --depth 1 --branch data https://github.com/yaml/yaml-test-suite
9494+ cd ..
9595+ ```
9696+9797+2. **Run the tests**:
9898+ ```bash
9999+ # Standard tests with HTML report
100100+ opam exec -- dune build @yaml-test-suite
101101+102102+ # Eio-based tests with HTML report
103103+ opam exec -- dune build @yaml-test-suite-eio
104104+ ```
105105+106106+**View the results**:
107107+- The HTML reports are generated in `_build/default/tests/yaml-test-results.html` and `_build/default/tests/yaml-test-results-eio.html`
108108+- Open them in a browser to see detailed test results with filtering and search capabilities
109109+110110+### Running Unit Tests
111111+112112+Run the standard unit tests:
113113+114114+```bash
115115+opam exec -- dune runtest
116116+```
117117+118118+### CI Integration
119119+120120+The CI pipeline automatically:
121121+- Runs all unit tests
122122+- Clones the YAML test suite
123123+- Executes the full test suite
124124+- Generates HTML reports
125125+126126+All tests must pass before merging changes.
127127+82128## API Documentation
8312984130Build the documentation with:
···11+; Test executables for the full YAML test suite
22+33+(executable
44+ (name run_all_tests)
55+ (modules run_all_tests test_yamlrw)
66+ (libraries yamlrw test_suite_lib alcotest))
77+88+(executable
99+ (name run_all_tests_eio)
1010+ (modules run_all_tests_eio)
1111+ (libraries yamlrw test_suite_lib_eio eio_main))
1212+1313+; Alias to run the full YAML test suite and generate HTML report
1414+; Requires yaml-test-suite to be cloned to tests/yaml-test-suite
1515+(rule
1616+ (alias yaml-test-suite)
1717+ (deps (source_tree yaml-test-suite))
1818+ (targets yaml-test-results.html)
1919+ (action
2020+ (run %{exe:run_all_tests.exe}
2121+ --test-suite-path %{workspace_root}/tests/yaml-test-suite
2222+ --html yaml-test-results.html)))
2323+2424+(rule
2525+ (alias yaml-test-suite-eio)
2626+ (deps (source_tree yaml-test-suite))
2727+ (targets yaml-test-results-eio.html)
2828+ (action
2929+ (run %{exe:run_all_tests_eio.exe}
3030+ --test-suite-path %{workspace_root}/tests/yaml-test-suite
3131+ --html yaml-test-results-eio.html)))
+6-3
tests/run_all_tests.ml
···99module JF = Test_suite_lib.Json_format
1010module JC = Test_suite_lib.Json_compare
11111212-let test_suite_path = "../yaml-test-suite"
1212+let test_suite_path = "yaml-test-suite"
13131414(* HTML escape function *)
1515let html_escape s =
···424424let () =
425425 let html_output = ref None in
426426 let show_skipped = ref false in
427427+ let test_suite_path_ref = ref test_suite_path in
427428 let args = [
428429 "--html", Arg.String (fun s -> html_output := Some s),
429430 "<file> Generate HTML report to file";
430431 "--show-skipped", Arg.Set show_skipped,
431432 " Show details of skipped tests";
433433+ "--test-suite-path", Arg.Set_string test_suite_path_ref,
434434+ "<path> Path to yaml-test-suite directory";
432435 ] in
433433- Arg.parse args (fun _ -> ()) "Usage: run_all_tests [--html <file>] [--show-skipped]";
436436+ Arg.parse args (fun _ -> ()) "Usage: run_all_tests [--html <file>] [--show-skipped] [--test-suite-path <path>]";
434437435435- let all_tests = TL.load_directory test_suite_path in
438438+ let all_tests = TL.load_directory !test_suite_path_ref in
436439 Printf.printf "Total tests loaded: %d\n%!" (List.length all_tests);
437440438441 let results = List.map run_test all_tests in
+8-6
tests/run_all_tests_eio.ml
···1111module JF = Test_suite_lib.Json_format
1212module JC = Test_suite_lib.Json_compare
13131414-let test_suite_path = "../yaml-test-suite"
1414+let test_suite_path = "yaml-test-suite"
15151616(* HTML escape function *)
1717let html_escape s =
···437437 let html_output = ref None in
438438 let show_skipped = ref false in
439439 let sequential = ref false in
440440+ let test_suite_path_ref = ref test_suite_path in
440441 let args = [
441442 "--html", Arg.String (fun s -> html_output := Some s),
442443 "<file> Generate HTML report to file";
···444445 " Show details of skipped tests";
445446 "--sequential", Arg.Set sequential,
446447 " Run tests sequentially instead of in parallel";
448448+ "--test-suite-path", Arg.Set_string test_suite_path_ref,
449449+ "<path> Path to yaml-test-suite directory";
447450 ] in
448448- Arg.parse args (fun _ -> ()) "Usage: run_all_tests_eio [--html <file>] [--show-skipped] [--sequential]";
451451+ Arg.parse args (fun _ -> ()) "Usage: run_all_tests_eio [--html <file>] [--show-skipped] [--sequential] [--test-suite-path <path>]";
449452450453 Eio_main.run @@ fun env ->
451454 (* Use fs (full filesystem) rather than cwd (sandboxed) to allow ".." navigation *)
452455 let fs = Eio.Stdenv.fs env in
453456 (* Get the absolute path to the test suite *)
454454- let cwd = Sys.getcwd () in
455455- let test_suite_abs = if Filename.is_relative test_suite_path then
456456- Filename.concat cwd test_suite_path
457457+ let test_suite_abs = if Filename.is_relative !test_suite_path_ref then
458458+ Filename.concat (Sys.getcwd ()) !test_suite_path_ref
457459 else
458458- test_suite_path
460460+ !test_suite_path_ref
459461 in
460462461463 let start_time = Unix.gettimeofday () in