#! /bin/sh
#|
exec racket -tm "$0" ${1+"$@"}
|#

#lang racket

;; ---------------------------------------------------------------------------------------------------
;; a script that runs client on all in<n>.xml files and compares the expected XML output wuth outN.xml

(provide main)

;; ---------------------------------------------------------------------------------------------------
;; implementation 

;; systems require: 
;; it relies on a script in xdiff-xml that compares XML outputs in the context of SwDev projects
(define xml-diff "./xdiff-xml")
(define xclient  "./client.rkt < in~a.xml")

(define (main . x)
  (for ((f (directory-list)) #:when (regexp-match #px"in(\\d).xml$" (path->string f)))
    (test (second (regexp-match #px"in(\\d).xml$" (path->string f))))))

;; String [Nat] -> Boolean 
(define (test n)
  (displayln "-----------------------------------------------------------------------------")
  (printf    "testing in~a.xml, out~a.xml\n" n n)
  (void (system (format "~a | ~a out~a.xml -" (format xclient n) xml-diff n))))

(define (run n)
  (void (system (format xclient n))))