* standalone/test-bad-identifiers: New test.
authorNeil Jerram <neil@ossau.uklinux.net>
Sat, 29 Dec 2007 01:35:47 +0000 (01:35 +0000)
committerNeil Jerram <neil@ossau.uklinux.net>
Sat, 29 Dec 2007 01:35:47 +0000 (01:35 +0000)
* standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.

test-suite/ChangeLog
test-suite/standalone/Makefile.am
test-suite/standalone/test-bad-identifiers [new file with mode: 0755]

index 72a2491..bdb5f60 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-29  Neil Jerram  <neil@ossau.uklinux.net>
+
+       * standalone/test-bad-identifiers: New test.
+       * standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
+
 2007-12-13  Stephen Compall  <s11@member.fsf.org>
 
        * tests/srfi-69.test (SRFI-69)[can use all arguments, including
index 9a3c3a3..13a4c39 100644 (file)
@@ -49,6 +49,9 @@ CLEANFILES = *.x
 check_SCRIPTS += test-system-cmds
 TESTS += test-system-cmds
 
+check_SCRIPTS += test-bad-identifiers
+TESTS += test-bad-identifiers
+
 check_SCRIPTS += test-require-extension
 TESTS += test-require-extension
 
diff --git a/test-suite/standalone/test-bad-identifiers b/test-suite/standalone/test-bad-identifiers
new file mode 100755 (executable)
index 0000000..5e263fc
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+exec guile -s "$0" "$@"
+!#
+
+(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"
+    ))
+
+(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)))))))
+
+(define (directory-files-matching dir pattern)
+  (let ((file-name-regexp (make-regexp pattern)))
+    (filter (lambda (fn)
+             (regexp-exec file-name-regexp fn))
+           (directory-files dir))))
+
+(let loop ((file-names (directory-files-matching "../../libguile"
+                                                "\\.[ch]$")))
+  (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: