mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
filesys.test: fixes for copy-file test on MinGW
In the copy-file test, is uses call-with-input-file and get-string-all to retrieve file contents. Since the file is not opened in binary mode, CRLF line ending may be added when writing and then reading the string back from the filesystem. * test-suite/tests/filesys.test (normalize-newlines): new helper function ("copy file: copy-file dest content"): pass even if CRLF line endings are added ("copy file: read only dest"): handle posibility of geteuid not being defined
This commit is contained in:
parent
6b4d829d40
commit
2177f3f6c5
1 changed files with 20 additions and 2 deletions
|
@ -46,6 +46,18 @@
|
|||
(chmod file (logior (stat:mode (stat file)) #o200)))
|
||||
(delete-file file)))
|
||||
|
||||
(define (normalize-newlines s)
|
||||
"Returns a copy of the input string, replacing any #\return #\newline
|
||||
pairs with #\newline."
|
||||
(let loop ((i 0) (result '()))
|
||||
(if (< i (string-length s))
|
||||
(if (and (< (+ i 1) (string-length s))
|
||||
(char=? (string-ref s i) #\return)
|
||||
(char=? (string-ref s (+ i 1)) #\newline))
|
||||
(loop (+ i 2) (cons #\newline result))
|
||||
(loop (+ i 1) (cons (string-ref s i) result)))
|
||||
(list->string (reverse result)))))
|
||||
|
||||
;;;
|
||||
;;; copy-file
|
||||
;;;
|
||||
|
@ -69,8 +81,14 @@
|
|||
(with-test-prefix "successful copy"
|
||||
(copy-file src dest)
|
||||
(pass-if-equal "copy-file dest content" msg
|
||||
(call-with-input-file dest get-string-all)))
|
||||
(unless (zero? (geteuid))
|
||||
;; Since call-with-input-file is always text mode, it may have
|
||||
;; \r\n on MinGW.
|
||||
(normalize-newlines
|
||||
(call-with-input-file dest get-string-all))))
|
||||
;; Checking for a geteuid of zero is testing of the user
|
||||
;; is root, making the chmod to read-only meaningless. geteuid is
|
||||
;; not defined in MinGW.
|
||||
(unless (and (defined? 'geteuid) (zero? (geteuid)))
|
||||
(with-test-prefix "read only dest"
|
||||
(chmod dest #o444)
|
||||
(with-exception-handler
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue