From 9c1b2a653808b45e1a4e9a2742839240c0de6dbc Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Wed, 23 Sep 2026 15:56:23 -0400 Subject: [PATCH] Anchor the push-number rewrite to the build directory DrDr scrubs push-specific paths from captured output, so that a log changes only when the test's behavior does. It replaced the push number as a bare string, so it also rewrote every other occurrence of those digits. On push 73506 `raco pkg show` therefore reported expeditor as changed, because its checksum ends in that number: 65e20a410bdc5f09c0682a1bb57cac2b68d73506 65e20a410bdc5f09c0682a1bb57cac2b68d frtime did the same on push 73507, and any push whose number appears in an installed package's checksum will do it again. Replace the build directory joined with the push number instead; output for real build paths does not change. --- run-collect.rkt | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/run-collect.rkt b/run-collect.rkt index d9f39d8..09403d4 100644 --- a/run-collect.rkt +++ b/run-collect.rkt @@ -123,6 +123,21 @@ (regexp-replace** ([pat subst] ...) s) subst0)])) +;; Scrub machine- and push-specific paths from captured output, so that a +;; log changes only when the test's behavior does. The placeholder replaces +;; the last element of `rev-dir`, the build's directory, and output matches +;; only where the whole directory appears, so other occurrences of the push +;; number's digits, such as in a git checksum, survive. +(define (scrub-output s rev-dir tmp home cwd) + (define rev-dir/scrubbed + (apply build-path (append (drop-right (explode-path rev-dir) 1) + (list "")))) + (regexp-replace** ([(path->string rev-dir) (path->string rev-dir/scrubbed)] + [tmp ""] + [home ""] + [(path->string cwd) ""]) + s)) + (define (run/collect/wait/log log-path command #:timeout timeout #:env env @@ -133,16 +148,12 @@ (lambda () (notify! "No cache: ~a" log-path) - (define rev (number->string (current-rev))) + (define rev-dir (revision-dir (current-rev))) (define home (hash-ref env "HOME")) (define tmp (hash-ref env "TMPDIR")) - (define cwd (path->string (current-directory))) + (define cwd (current-directory)) (define (rewrite s) - (regexp-replace** ([rev ""] - [tmp ""] - [home ""] - [cwd ""]) - s)) + (scrub-output s rev-dir tmp home cwd)) (set! ran? #t) (rewrite-status @@ -168,3 +179,22 @@ #:timeout exact-nonnegative-integer? (listof string?) . -> . boolean?)]) + +(module+ test + (require rackunit) + + ;; the callers' `cwd` ends in a separator, as `(current-directory)` does + (define (scrub s) + (scrub-output s (string->path "/opt/plt/builds/73506") + "/tmp/x/" "/home/jay" + (string->path "/opt/plt/builds/73506/trunk/"))) + + (check-equal? (scrub "/opt/plt/builds/73506/logs/pkgs/base") + "/opt/plt/builds//logs/pkgs/base") + (check-equal? (scrub "/opt/plt/builds/73506/trunk/racket") "racket") + (check-equal? (scrub "/tmp/x/foo") "foo") + (check-equal? (scrub "/home/jay/.racket") "/.racket") + ;; expeditor's checksum on push 73506, and a bare mention of the number + (check-equal? (scrub "65e20a410bdc5f09c0682a1bb57cac2b68d73506") + "65e20a410bdc5f09c0682a1bb57cac2b68d73506") + (check-equal? (scrub "ran 73506 tests") "ran 73506 tests"))