;; lib/guest/conformance.sx — shared helpers for the guest conformance driver.
;;
;; The bash driver lib/guest/conformance.sh loads this file and then for each
;; suite emits an (eval "...") form whose result is a tagged list:
;;
;;     (gc-result NAME PASSED FAILED TOTAL)
;;
;; The driver greps these from sx_server's output and aggregates them.
;;
;; Two suite shapes are supported:
;;
;;   :dict     — runner expression returns a dict with :passed/:failed/:total.
;;               (gc-dict-result "parse" (pl-parse-tests-run!))
;;
;;   :counters — runner has no return value, mutates pass/fail global counters.
;;               (gc-counters-result NAME P0 F0 PASS FAIL)
;;               where P0/F0 are the counters captured BEFORE the suite ran
;;               and PASS/FAIL are the counters AFTER.

(define
  gc-dict-result
  (fn
    (name r)
    (list
      (quote gc-result)
      name
      (get r :passed)
      (get r :failed)
      (get r :total))))

(define
  gc-counters-result
  (fn
    (name p0 f0 p1 f1)
    (list
      (quote gc-result)
      name
      (- p1 p0)
      (- f1 f0)
      (- (+ p1 f1) (+ p0 f0)))))
