1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00
guile/test-suite/standalone/test-bad-identifiers
Rob Browning 3ff8836e64 test-bad-identifiers: ignore *.[hc] dotfiles
When generating the list of test files, ignore any whose names begin
with a dot.  If nothing else, this avoids crashing on the symlinks that
Emacs creates for files with pending changes.  In that case it creates a
symlink to nowhere until the content is saved or reverted, and those
symlinks produce test failures like this:

  Backtrace:
             3 (primitive-load "/home/rlb/src/guile/utf8-debug/test-su?")
  In ice-9/eval.scm:
      619:8  2 (_ #(#(#(#<directory (guile-user) 7f0239b32c80> #) #) #))
  In ice-9/ports.scm:
     450:11  1 (call-with-input-file "../../libguile/.#strings.c" #<p?> ?)
  In unknown file:
             0 (open-file "../../libguile/.#strings.c" "r" #:encoding # ?)

  ERROR: In procedure open-file:
  In procedure open-file: No such file or directory: "../../libguile/.#strings.c"
  FAIL: test-bad-identifiers

* test-suite/standalone/test-bad-identifiers: ignore files with names
beginning with a dot.
2024-04-14 15:59:31 -05:00

74 lines
2.2 KiB
Scheme
Executable file

#!/bin/sh
exec guile -q -s "$0" "$@"
!#
;; The use of certain identifiers as variable or parameter names has
;; been found to cause build problems on particular platforms. The
;; aim of this test is to cause "make check" to fail (on GNU/Linux,
;; which most Guile developers use) if we accidentally add new code
;; that uses those identifiers.
(define bad-identifiers
'(
;; On AIX 5.2 and 5.3, /usr/include/sys/timer.h includes:
;; #ifndef _LINUX_SOURCE_COMPAT
;; #define func_data t_union.data
;; #endif
;; So we want to avoid using func_data in Guile source code.
"func_data"
;; More troublesome identifiers can be added into the list here.
))
(use-modules (ice-9 regex) (ice-9 rdelim))
(define bad-id-regexp
(make-regexp (string-append "\\<("
(string-join (map regexp-quote bad-identifiers) "|")
")\\>")))
(define exit-status 0)
;; Non-exported code from (ice-9 ftw).
(define (directory-files dir)
(let ((dir-stream (opendir dir)))
(let loop ((new (readdir dir-stream))
(acc '()))
(if (eof-object? new)
(begin
(closedir dir-stream)
acc)
(loop (readdir dir-stream)
(if (or (string=? "." new) ;;; ignore
(string=? ".." new)) ;;; ignore
acc
(cons (in-vicinity dir new) acc)))))))
(let loop ((file-names (filter (lambda (fn)
(and (or (string-suffix? ".h" fn)
(string-suffix? ".c" fn))
(not (string-prefix? "." (basename fn)))))
(directory-files "../../libguile"))))
(or (null? file-names)
(begin
(with-input-from-file (car file-names)
(lambda ()
(let loop ((linenum 1) (line (read-line)))
(or (eof-object? line)
(begin
(if (regexp-exec bad-id-regexp line)
(begin
(set! exit-status 1)
(format (current-error-port)
"~a:~a: ~a\n"
(car file-names)
linenum
line)))
(loop (+ linenum 1) (read-line)))))))
(loop (cdr file-names)))))
(exit exit-status)
;; Local Variables:
;; mode: scheme
;; End: