Btter tests for the package index

This commit is contained in:
2026-08-18 13:47:29 +02:00
parent 49ff1ad354
commit 72bf39a27b
5 changed files with 66 additions and 30 deletions
+10 -12
View File
@@ -119,7 +119,6 @@
(check-true (regexp-match? #rx"a[/\\]b"
(capture-output coreutils-dirname "a/b/c.txt")))
(define saved-env (getenv "RASH_COREUTILS_TEST"))
(define env-output
(parameterize ([current-coreutils-command-runner
(λ (command)
@@ -134,18 +133,17 @@
'RASH_COREUTILS_VALUE)))
(check-equal? env-output "42\n")
(dynamic-wind
void
(λ ()
(putenv "RASH_COREUTILS_TEST" "before")
(check-equal? (capture-output coreutils-printenv "RASH_COREUTILS_TEST")
"before\n"))
(λ ()
(if saved-env
(putenv "RASH_COREUTILS_TEST" saved-env)
(putenv "RASH_COREUTILS_TEST" #f))))
(define test-environment
(environment-variables-copy (current-environment-variables)))
(environment-variables-set!
test-environment
#"RASH_COREUTILS_TEST"
#"before")
(parameterize ([current-environment-variables test-environment])
(check-equal? (capture-output coreutils-printenv "RASH_COREUTILS_TEST")
"before\n"))
(check-true (regexp-match? #rx"[0-9]{4}-[0-9]{2}-[0-9]{2}T"
(check-true (regexp-match? #px"[0-9]{4}-[0-9]{2}-[0-9]{2}T"
(capture-output coreutils-date "--iso")))
(check-exn
+45 -14
View File
@@ -1,21 +1,52 @@
#lang rash
(require rash-coreutils)
(require rackunit
racket/file
racket/port
rash-coreutils)
mkdir -p rash-coreutils-smoke/a
(define test-root
(make-temporary-file "rash-coreutils-smoke-~a" 'directory))
(define output
(open-output-string))
(define errors
(open-output-string))
echo hello from rash-coreutils
ls -l rash-coreutils-smoke
ls *.rkt
ls #px"^info[.]rkt$"
(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)))
(define x 42)
env RASH_COREUTILS_VALUE=(values x) printenv RASH_COREUTILS_VALUE
mkdir -p rash-coreutils-smoke/a
echo one two three | wc -w
echo c b a | sort
echo hello from rash-coreutils
ls -l rash-coreutils-smoke
ls *.rkt
ls #px"^info[.]rkt$"
date --iso
raco help
help
rm -r rash-coreutils-smoke
(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))))