49 lines
1.6 KiB
Racket
49 lines
1.6 KiB
Racket
#lang racket
|
|
|
|
(require rackunit
|
|
racket/file
|
|
linea/read)
|
|
|
|
(define tmp (make-temporary-file "rash-makefile~a" 'directory))
|
|
|
|
(dynamic-wind
|
|
void
|
|
(λ ()
|
|
(define makefile-path (build-path tmp "Makefile.rkt"))
|
|
|
|
(call-with-output-file makefile-path
|
|
#:exists 'truncate/replace
|
|
(λ (out)
|
|
(displayln "#lang rash" out)
|
|
(displayln "(require rash-makefile)" out)
|
|
(displayln "(makefile demo" out)
|
|
(displayln " (default-target status)" out)
|
|
(displayln " (phony status)" out)
|
|
(displayln " (target status" out)
|
|
(displayln " (call-with-output-file \"status.out\"" out)
|
|
(displayln " #:exists 'truncate/replace" out)
|
|
(displayln " (λ (o) (display \"status\" o)))))" out)))
|
|
|
|
(define module-path `(file ,(path->string makefile-path)))
|
|
|
|
(parameterize ([current-directory tmp])
|
|
(dynamic-require module-path #f))
|
|
(check-false (file-exists? (build-path tmp "status.out")))
|
|
|
|
(define ns (module->namespace module-path))
|
|
(parameterize ([current-directory tmp]
|
|
[current-namespace ns])
|
|
(define line
|
|
(linea-read-syntax 'drracket-interaction
|
|
(open-input-string "make status\n")))
|
|
(eval line)
|
|
(check-true (file-exists? (build-path tmp "status.out")))
|
|
(delete-file (build-path tmp "status.out"))
|
|
|
|
(eval #'(make 'status))
|
|
(check-true (file-exists? (build-path tmp "status.out")))
|
|
(check-true (eval #'(procedure? make)))
|
|
(check-true (eval #'(procedure? makefile-target-demo-status)))))
|
|
(λ ()
|
|
(delete-directory/files tmp #:must-exist? #f)))
|