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
+8
View File
@@ -1,3 +1,11 @@
0.2.9
- Make package-build tests independent of the directory from which raco test is invoked.
- Run Rash smoke tests in an isolated temporary directory and capture expected command output.
- Keep successful tests silent under raco test --drdr; unexpected failures still escape normally.
- Isolate environment-variable tests with current-environment-variables instead of mutating the process environment.
- Declare linea explicitly as a build dependency because the Rash test modules use its reader.
0.2.7 0.2.7
- Fix package setup regression in the Racket test suite after the raco command/procedure split. - Fix package setup regression in the Racket test suite after the raco command/procedure split.
+1 -1
View File
@@ -2,7 +2,7 @@
Portable Unix-style core utilities for Rash, implemented in Racket. Portable Unix-style core utilities for Rash, implemented in Racket.
Version 0.2.7 includes text/pipeline tools (`head`, `tail`, `wc`, `sort`, `uniq`, Version 0.2.9 includes text/pipeline tools (`head`, `tail`, `wc`, `sort`, `uniq`,
`cut`, `tee`, `tr`), path and filesystem helpers (`basename`, `dirname`, `cut`, `tee`, `tr`), path and filesystem helpers (`basename`, `dirname`,
`realpath`, `readlink`, `stat`, `du`, `df`, `mktemp`), environment commands `realpath`, `readlink`, `stat`, `du`, `df`, `mktemp`), environment commands
(`printenv`, `env`), and `date` backed by Gregor. (`printenv`, `env`), and `date` backed by Gregor.
+2 -3
View File
@@ -1,7 +1,7 @@
#lang info #lang info
(define pkg-authors '(hnmdijkema)) (define pkg-authors '(hnmdijkema))
(define version "0.2.7") (define version "0.2.9")
(define license 'MIT) (define license 'MIT)
(define collection "rash-coreutils") (define collection "rash-coreutils")
(define pkg-desc (define pkg-desc
@@ -17,5 +17,4 @@
'("racket-doc" '("racket-doc"
"rackunit-lib" "rackunit-lib"
"scribble-lib" "scribble-lib"
"linea" "linea"))
"rash"))
+8 -10
View File
@@ -119,7 +119,6 @@
(check-true (regexp-match? #rx"a[/\\]b" (check-true (regexp-match? #rx"a[/\\]b"
(capture-output coreutils-dirname "a/b/c.txt"))) (capture-output coreutils-dirname "a/b/c.txt")))
(define saved-env (getenv "RASH_COREUTILS_TEST"))
(define env-output (define env-output
(parameterize ([current-coreutils-command-runner (parameterize ([current-coreutils-command-runner
(λ (command) (λ (command)
@@ -134,18 +133,17 @@
'RASH_COREUTILS_VALUE))) 'RASH_COREUTILS_VALUE)))
(check-equal? env-output "42\n") (check-equal? env-output "42\n")
(dynamic-wind (define test-environment
void (environment-variables-copy (current-environment-variables)))
(λ () (environment-variables-set!
(putenv "RASH_COREUTILS_TEST" "before") test-environment
#"RASH_COREUTILS_TEST"
#"before")
(parameterize ([current-environment-variables test-environment])
(check-equal? (capture-output coreutils-printenv "RASH_COREUTILS_TEST") (check-equal? (capture-output coreutils-printenv "RASH_COREUTILS_TEST")
"before\n")) "before\n"))
(λ ()
(if saved-env
(putenv "RASH_COREUTILS_TEST" saved-env)
(putenv "RASH_COREUTILS_TEST" #f))))
(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"))) (capture-output coreutils-date "--iso")))
(check-exn (check-exn
+36 -5
View File
@@ -1,6 +1,28 @@
#lang rash #lang rash
(require rash-coreutils) (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 mkdir -p rash-coreutils-smoke/a
@@ -13,9 +35,18 @@ ls #px"^info[.]rkt$"
env RASH_COREUTILS_VALUE=(values x) printenv RASH_COREUTILS_VALUE env RASH_COREUTILS_VALUE=(values x) printenv RASH_COREUTILS_VALUE
echo one two three | wc -w echo one two three | wc -w
echo c b a | sort
date --iso date --iso
raco help
help
rm -r rash-coreutils-smoke 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))))