#lang racket (require tests/eli-tester racket/runtime-path) (define-runtime-path here ".") (define (in-directory pth rx) (in-list (map (curry build-path pth) (filter (compose (curry regexp-match rx) path->bytes) (directory-list pth))))) (define (test-mutator m) (printf "Running ~a\n" m) (parameterize ([current-namespace (make-base-empty-namespace)]) (dynamic-require m #f))) (define run-good? (make-parameter #f)) (command-line #:program "run-test" #:once-each ["-g" "Enable running good mutators" (run-good? #t)]) (define (drop-first-line e) (regexp-replace "^[^\n]+\n" e "")) (define-syntax-rule (capture-output e) (drop-first-line (with-output-to-string (λ () e)))) (test (if (run-good?) (for ([m (in-directory (build-path here "good-mutators") #rx"rkt$")]) (test #:failure-prefix (format "~a" m) (test-mutator m))) (void)) (for ([m (in-directory (build-path here "bad-mutators") #rx"rkt$")]) (test (test-mutator m) =error> #rx"")) (test-mutator (build-path here "other-mutators" "error.rkt")) =error> #rx"plai/gc2/mutator has error" (test-mutator (build-path here "other-mutators" "top.rkt")) =error> #rx"unbound identifier in module\n in: frozzle" (capture-output (test-mutator (build-path here "other-mutators" "printing.rkt"))) => #< #< "alloc: out of space" )