Diverse aanpassingen

This commit is contained in:
2026-08-09 14:56:42 +02:00
parent ac8e492aff
commit 2e1899292c
8 changed files with 63 additions and 22 deletions
+8
View File
@@ -1,3 +1,11 @@
0.1.6
Fixed the raco helper test for the Racket package build service: raco help
legitimately writes usage text to stderr, while raco test --drdr treats any
stderr output as a test failure. The test now captures child stdout/stderr.
Changed list-dir/files so its regexp matches only the entry name returned by
file-name-from-path, instead of the complete path.
0.1.5
Added raco helper for invoking Racket tools from makefile recipes.
+14 -2
View File
@@ -1,7 +1,10 @@
#lang racket
(require "main.rkt"
racket/string)
racket/string
git
package-zipper
)
(target all
(displayln "use (make clean) or (make package) or (make commit/push")
@@ -22,10 +25,19 @@
(run '(git push)))
(target status
(run '(git status)))
(void (dgit 'status))
)
(target pull
(run '(git pull)))
(target clean
(for-each (λ (f) (displayln f) (rm-f f)) (list-files "." #px"([.]bak|~)$" #:recursive #t))
(for-each (λ (d) (displayln d) (rm-rf d)) (list-dirs "." #px"(compiled|doc)$" #:recursive #t))
(for-each (λ (f) (displayln f) (rm-f f)) (list-files "scrbl" #px"[.](css|js|html)$"))
)
(target package
(deps clean)
(zip-package))
+6 -5
View File
@@ -40,7 +40,7 @@ raco pkg install
For a versioned archive, give the package name explicitly:
```text
raco pkg install --name racket-makefile racket-makefile-0.1.5.zip
raco pkg install --name racket-makefile racket-makefile-0.1.6.zip
```
## Running targets
@@ -127,10 +127,11 @@ so they can be passed directly to `rm-f` and `rm-rf` with `apply`:
(displayln "done."))
```
`list-dir/files` returns matching files and directories. `list-files` and
`list-dirs` restrict the result to files or directories. All three scan one
directory level by default; use `#:recursive #t` to walk the complete tree.
Non-recursive results are returned as complete paths, so the lists can be fed
`list-dir/files` returns matching files and directories. The regexp is matched
against the file or directory name itself, not against the complete path.
`list-files` and `list-dirs` restrict the result to files or directories. All
three scan one directory level by default; use `#:recursive #t` to walk the
complete tree. Results are returned as usable paths, so the lists can be fed
directly to `rm-f` or `rm-rf` with `apply`.
## Generated targets
+1 -1
View File
@@ -1,7 +1,7 @@
#lang info
(define pkg-authors '(hnmdijkema))
(define version "0.1.5")
(define version "0.1.6")
(define license 'MIT)
(define collection "racket-makefile")
(define pkg-desc
+3 -2
View File
@@ -141,8 +141,9 @@
(define (list-dir/files directory regexp #:recursive [recursive #f])
(filter (lambda (path)
(let ((fn (file-name-from-path path)))
(regexp-match? regexp fn)))
(define filename (file-name-from-path path))
(and filename
(regexp-match? regexp filename)))
(if recursive
(for/list ([path (in-directory directory)])
path)
+7 -5
View File
@@ -31,7 +31,7 @@ raco pkg install
For a versioned archive, specify the package name explicitly:
@verbatim{
raco pkg install --name racket-makefile racket-makefile-0.1.5.zip
raco pkg install --name racket-makefile racket-makefile-0.1.6.zip
}
After installation a makefile can start with:
@@ -260,10 +260,12 @@ For example:
[regexp regexp?]
[#:recursive recursive any/c #f])
list?]{
Returns entries below @racket[directory] that match @racket[regexp]. By default
only the direct contents of @racket[directory] are inspected. With
@racket[#:recursive #t], the complete tree is walked using
@racket[in-directory], and both files and directories can be returned.
Returns entries below @racket[directory] whose file or directory name matches
@racket[regexp]. The regexp is applied to @racket[(file-name-from-path path)],
not to the complete path. By default only the direct contents of
@racket[directory] are inspected. With @racket[#:recursive #t], the complete
tree is walked using @racket[in-directory], and both files and directories can
be returned.
For a non-recursive listing, complete paths are built from @racket[directory],
so the result can be passed directly to file operations such as
+9
View File
@@ -41,6 +41,15 @@
(check-equal? (list-dirs tmp #px"a$")
(list (build-path tmp "a")))
;; Matching is against the entry name, not against parent directories.
(define misleading-parent (build-path tmp "compiled-parent"))
(make-directory* misleading-parent)
(define ordinary-file (build-path misleading-parent "ordinary.txt"))
(call-with-output-file ordinary-file (lambda (out) (display "ordinary" out)))
(check-false
(member ordinary-file
(list-dir/files tmp #px"compiled" #:recursive #t)))
;; Recursive variants select the requested kind directly.
(define recursive-baks
(list-files tmp #px"(?i:[.]bak$)" #:recursive #t))
+14 -6
View File
@@ -3,15 +3,23 @@
(require rackunit
(only-in racket-makefile raco))
(check-not-exn
(lambda ()
(raco '(help))))
;; DrDr (used by the package build service) counts any output on stderr as a
;; test failure. `raco help` legitimately writes its usage text to stderr, so
;; keep the child process output local to this test.
(define (check-raco-help)
(define out (open-output-string))
(define err (open-output-string))
(parameterize ([current-output-port out]
[current-error-port err])
(check-not-exn
(lambda ()
(raco '(help))))))
(check-raco-help)
;; It must not require raco to be on PATH. The current Racket installation
;; should locate its own raco first.
(define env (environment-variables-copy (current-environment-variables)))
(environment-variables-set! env #"PATH" #f)
(parameterize ([current-environment-variables env])
(check-not-exn
(lambda ()
(raco '(help)))))
(check-raco-help))