53 lines
1.4 KiB
Racket
53 lines
1.4 KiB
Racket
#lang rash
|
|
|
|
(require rackunit
|
|
racket/file
|
|
racket/port
|
|
rash-coreutils)
|
|
|
|
(define test-root
|
|
(make-temporary-file "rash-coreutils-smoke-~a" 'directory))
|
|
(define output
|
|
(open-output-string))
|
|
(define errors
|
|
(open-output-string))
|
|
|
|
(dynamic-wind
|
|
void
|
|
(λ ()
|
|
(parameterize ([current-directory test-root]
|
|
[current-output-port output]
|
|
[current-error-port errors])
|
|
{
|
|
(call-with-output-file "info.rkt"
|
|
#:exists 'truncate
|
|
(λ (out)
|
|
(display "#lang racket/base\n" out)))
|
|
|
|
mkdir -p rash-coreutils-smoke/a
|
|
|
|
echo hello from rash-coreutils
|
|
ls -l rash-coreutils-smoke
|
|
ls *.rkt
|
|
ls #px"^info[.]rkt$"
|
|
|
|
(define x 42)
|
|
env RASH_COREUTILS_VALUE=(values x) printenv RASH_COREUTILS_VALUE
|
|
|
|
echo one two three | wc -w
|
|
date --iso
|
|
rm -r rash-coreutils-smoke
|
|
|
|
(check-false (directory-exists? "rash-coreutils-smoke"))
|
|
})
|
|
(check-equal? (get-output-string errors) "")
|
|
(define text (get-output-string output))
|
|
(check-true (regexp-match? #rx"hello from rash-coreutils" text))
|
|
(check-true (regexp-match? #rx"info[.]rkt" text))
|
|
(check-true (regexp-match? #rx"42" text))
|
|
(check-true (regexp-match? #rx"\n3\n" text))
|
|
(check-true (regexp-match? #px"[0-9]{4}-[0-9]{2}-[0-9]{2}T" text)))
|
|
(λ ()
|
|
(when (directory-exists? test-root)
|
|
(delete-directory/files test-root))))
|