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 0.1.5
Added raco helper for invoking Racket tools from makefile recipes. Added raco helper for invoking Racket tools from makefile recipes.
+14 -2
View File
@@ -1,7 +1,10 @@
#lang racket #lang racket
(require "main.rkt" (require "main.rkt"
racket/string) racket/string
git
package-zipper
)
(target all (target all
(displayln "use (make clean) or (make package) or (make commit/push") (displayln "use (make clean) or (make package) or (make commit/push")
@@ -22,10 +25,19 @@
(run '(git push))) (run '(git push)))
(target status (target status
(run '(git status))) (void (dgit 'status))
)
(target pull (target pull
(run '(git 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: For a versioned archive, give the package name explicitly:
```text ```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 ## Running targets
@@ -127,10 +127,11 @@ so they can be passed directly to `rm-f` and `rm-rf` with `apply`:
(displayln "done.")) (displayln "done."))
``` ```
`list-dir/files` returns matching files and directories. `list-files` and `list-dir/files` returns matching files and directories. The regexp is matched
`list-dirs` restrict the result to files or directories. All three scan one against the file or directory name itself, not against the complete path.
directory level by default; use `#:recursive #t` to walk the complete tree. `list-files` and `list-dirs` restrict the result to files or directories. All
Non-recursive results are returned as complete paths, so the lists can be fed 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`. directly to `rm-f` or `rm-rf` with `apply`.
## Generated targets ## Generated targets
+1 -1
View File
@@ -1,7 +1,7 @@
#lang info #lang info
(define pkg-authors '(hnmdijkema)) (define pkg-authors '(hnmdijkema))
(define version "0.1.5") (define version "0.1.6")
(define license 'MIT) (define license 'MIT)
(define collection "racket-makefile") (define collection "racket-makefile")
(define pkg-desc (define pkg-desc
+3 -2
View File
@@ -141,8 +141,9 @@
(define (list-dir/files directory regexp #:recursive [recursive #f]) (define (list-dir/files directory regexp #:recursive [recursive #f])
(filter (lambda (path) (filter (lambda (path)
(let ((fn (file-name-from-path path))) (define filename (file-name-from-path path))
(regexp-match? regexp fn))) (and filename
(regexp-match? regexp filename)))
(if recursive (if recursive
(for/list ([path (in-directory directory)]) (for/list ([path (in-directory directory)])
path) path)
+7 -5
View File
@@ -31,7 +31,7 @@ raco pkg install
For a versioned archive, specify the package name explicitly: For a versioned archive, specify the package name explicitly:
@verbatim{ @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: After installation a makefile can start with:
@@ -260,10 +260,12 @@ For example:
[regexp regexp?] [regexp regexp?]
[#:recursive recursive any/c #f]) [#:recursive recursive any/c #f])
list?]{ list?]{
Returns entries below @racket[directory] that match @racket[regexp]. By default Returns entries below @racket[directory] whose file or directory name matches
only the direct contents of @racket[directory] are inspected. With @racket[regexp]. The regexp is applied to @racket[(file-name-from-path path)],
@racket[#:recursive #t], the complete tree is walked using not to the complete path. By default only the direct contents of
@racket[in-directory], and both files and directories can be returned. @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], For a non-recursive listing, complete paths are built from @racket[directory],
so the result can be passed directly to file operations such as 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$") (check-equal? (list-dirs tmp #px"a$")
(list (build-path tmp "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. ;; Recursive variants select the requested kind directly.
(define recursive-baks (define recursive-baks
(list-files tmp #px"(?i:[.]bak$)" #:recursive #t)) (list-files tmp #px"(?i:[.]bak$)" #:recursive #t))
+13 -5
View File
@@ -3,15 +3,23 @@
(require rackunit (require rackunit
(only-in racket-makefile raco)) (only-in racket-makefile raco))
(check-not-exn ;; 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 () (lambda ()
(raco '(help)))) (raco '(help))))))
(check-raco-help)
;; It must not require raco to be on PATH. The current Racket installation ;; It must not require raco to be on PATH. The current Racket installation
;; should locate its own raco first. ;; should locate its own raco first.
(define env (environment-variables-copy (current-environment-variables))) (define env (environment-variables-copy (current-environment-variables)))
(environment-variables-set! env #"PATH" #f) (environment-variables-set! env #"PATH" #f)
(parameterize ([current-environment-variables env]) (parameterize ([current-environment-variables env])
(check-not-exn (check-raco-help))
(lambda ()
(raco '(help)))))