#lang scheme (define allocator-line '(allocator-setup "hw.ss" 200)) (call-with-input-file "results.txt" (λ (port) (let loop () ;; skip ahead to the next failing test (let ([m (regexp-match #rx"\n([L1][0-9][0-9]): failed\n" port)]) ;; if there is a failing test (when m ;; skip ahead to the beginning of it (regexp-match #rx"\n----- mutator cut here -----\n" port) ;; open the file to save the failing test (call-with-output-file (format "~a.ss" (cadr m)) (λ (out) (let line-loop () (let ([l (read-line port)]) ;; copy each line into the file until we find the next 'mutator cut here' line (unless (regexp-match #rx"----- mutator cut here -----" l) (cond [(regexp-match #rx"allocator-setup" l) (write allocator-line out)] [else (display l out)]) (newline out) (line-loop))))) #:exists 'truncate) (loop))))))