Raymond Toy pushed to branch issue-373-handle-temp-files at cmucl / cmucl Commits: def9886b by Raymond Toy at 2025-11-10T11:25:06-08:00 Minor tweak to with-temporary-directory Call `recursive-delete-directory` with the temp directory pathname object instead of the namestring. Update pot file for new docstrings. - - - - - 78dc0983 by Raymond Toy at 2025-11-10T16:37:11-08:00 Remove old nil'ed out tests Really remove these old tests that were updated to use with-temporary-file to get a temp file for testing. - - - - - 3 changed files: - src/code/extensions.lisp - src/i18n/locale/cmucl.pot - tests/trac.lisp Changes: ===================================== src/code/extensions.lisp ===================================== @@ -717,4 +717,4 @@ ;; If a temp directory was created, remove it and all its ;; contents. Is there a better way? (when ,dirname - (recursive-delete-directory (namestring ,dirname))))))) + (recursive-delete-directory ,dirname)))))) ===================================== src/i18n/locale/cmucl.pot ===================================== @@ -6007,6 +6007,13 @@ msgid "" " On completion, the file is automatically removed." msgstr "" +#: src/code/extensions.lisp +msgid "" +"Recursively delete the directory DIR. All files and subdirectories of\n" +" DIR are removed. DIR must be a pathname to a directory. Any NAME\n" +" or TYPE components in DIR are ignored." +msgstr "" + #: src/code/extensions.lisp msgid "" "Return a namestring to a temporary directory. If Directory is not\n" ===================================== tests/trac.lisp ===================================== @@ -103,78 +103,24 @@ (assert-equal '(:absolute "TMP" "Foo" "bar") (pathname-directory "/tmp/Foo/BAR/" :case :common))) -#+nil (define-test trac.36 - (:tag :trac) - (let ((path "/tmp/trac.36.bom.txt")) - (flet ((bug (&optional (format :utf16)) + (:tag :trac) + (flet ((bug (&optional (format :utf16)) + (ext:with-temporary-file (path) (with-open-file (s path :direction :output - :if-exists :supersede :external-format format) (format s "Hello~%")) (with-open-file (s path :direction :input :external-format format) (let ((ch (read-char s))) - (values ch (file-position s)))))) - (assert-equal (values #\H 4) - (bug :utf16)) - (assert-equal (values #\H 8) - (bug :utf32))))) - -#+nil -(define-test trac.36 - (:tag :trac) - (flet ((bug (&optional (format :utf16)) - (ext:with-temporary-stream (s :direction :io :external-format format) - (format s "Hello~%") - (file-position s 0) - (let ((ch (read-char s))) - (values ch (file-position s)))))) + (values ch (file-position s))))))) (assert-equal (values #\H 4) (bug :utf16)) (assert-equal (values #\H 8) (bug :utf32)))) -(define-test trac.36 - (:tag :trac) - (flet ((bug (&optional (format :utf16)) - (ext:with-temporary-file (path) - (with-open-file (s path - :direction :output - :external-format format) - (format s "Hello~%")) - (with-open-file (s path - :direction :input - :external-format format) - (let ((ch (read-char s))) - (values ch (file-position s))))))) - (assert-equal (values #\H 4) - (bug :utf16)) - (assert-equal (values #\H 8) - (bug :utf32))))) - -#+nil -(define-test trac.43 - (:tag :trac) - (assert-true - (let ((path "/tmp/trac.43.txt")) - (unwind-protect - (progn - (with-open-file (ostream path :direction :output - :external-format :utf-8) - (dotimes (i 1000) - (write-char (code-char #x1234) ostream))) - - (with-open-file (stream path :direction :input - :external-format :utf-8) - (let ((p0 (file-position stream)) - (ch (read-char stream))) - (unread-char ch stream) - (let ((p0* (file-position stream))) - (eql p0* p0))))))))) - (define-test trac.43 (:tag :trac) (assert-true @@ -197,26 +143,6 @@ (assert-equal "#P(:DIRECTORY (:ABSOLUTE \"tmp\" \"\" \"a\" \"\" \"b\"))" (princ-to-string (make-pathname :directory '(:absolute "tmp" "" "a" "" "b"))))) -#+nil -(define-test trac.58 - (:tag :trac) - (assert-false - (let ((path "/tmp/trac.58.txt") - failures) - (unwind-protect - (progn - (with-open-file (s path :direction :output :external-format :utf-16) - (dotimes (i 300) - (write-char (code-char i) s))) - - (with-open-file (s path :direction :input :external-format :utf-16) - (dotimes (i 300) - (let ((ch (read-char s nil nil))) - (unless (= i (char-code ch)) - (push (list i ch (char-code ch)) failures))))) - failures) - (delete-file path))))) - (define-test trac.58 (:tag :trac) (assert-false @@ -318,26 +244,6 @@ (assert-equal "A1234AAAA" (subseq (trac.70-test *trac.70* "a12345") 0 9))) -#+nil -(define-test trac.79 - (:tag :trac) - ;; Create a temp file full of latin1 characters. - (assert-equal - '(0 1) - (let ((path "/tmp/trac.70.txt")) - (unwind-protect - (progn - (with-open-file (s path :direction :output :if-exists :supersede - :external-format :latin1) - (dotimes (k 255) - (write-char (code-char k) s))) - (with-open-file (s path :direction :input :external-format :latin1) - (list (file-position s) - (progn - (read-char s) - (file-position s))))) - (delete-file path))))) - (define-test trac.79 (:tag :trac) ;; Create a temp file full of latin1 characters. @@ -360,30 +266,6 @@ (assert-true (ignore-errors (format nil "~ve" 21 5d-234))) (assert-true (ignore-errors (format nil "~ve" 100 5d-234)))) -#+nil -(define-test trac.87.output - (:tag :trac) - ;; Test that run-program accepts :element-type and produces the - ;; correct output. - (let ((path "/tmp/trac.87.output") - (string "Hello")) - (unwind-protect - (progn - (with-open-file (s path :direction :output :if-exists :supersede - :external-format :latin1) - (write-string string s)) - (let* ((expected (stream:string-to-octets string :external-format :latin1)) - (octets (make-array (length expected) - :element-type '(unsigned-byte 8))) - (proc (ext:run-program "/bin/cat" (list path) - :output :stream - :element-type '(unsigned-byte 8)))) - (read-sequence octets (ext:process-output proc)) - (assert-equalp - expected - octets))) - (delete-file path)))) - (define-test trac.87.output (:tag :trac) ;; Test that run-program accepts :element-type and produces the @@ -404,32 +286,6 @@ expected octets))))) -#+nil -(define-test trac.87.input - (:tag :trac) - ;; Test that run-program accepts :element-type and produces the - ;; correct input (and output). - (let ((path "/tmp/trac.87.input") - (string "Hello")) - (unwind-protect - (progn - (with-open-file (s path :direction :output :if-exists :supersede - :external-format :latin1) - (write-string string s)) - (let ((octets (stream:string-to-octets string :external-format :latin1)) - (output (make-array (length string) - :element-type '(unsigned-byte 8))) - (proc (ext:run-program "/bin/cat" (list path) - :input :stream - :output :stream - :element-type '(unsigned-byte 8)))) - (write-sequence octets (ext:process-input proc)) - (read-sequence output (ext:process-output proc)) - (assert-equalp - octets - output))) - (delete-file path)))) - (define-test trac.87.input (:tag :trac) ;; Test that run-program accepts :element-type and produces the @@ -510,24 +366,6 @@ ;; Not quite what ticket 101 is about, but it came up in investigating ;; CLEAR-OUTPUT on a Gray stream. Verify CLEAR-OUTPUT actually ;; does. Previously, it did nothing. -#+nil -(define-test trac.101 - (:tag :trac) - (assert-eql - 0 - (let ((s (open *test-file* - :direction :output - :if-exists :supersede))) - (unwind-protect - (progn - (write-char #\a s) - (clear-output s) - (close s) - (setf s (open *test-file*)) - (file-length s)) - (close s) - (delete-file *test-file*))))) - (define-test trac.101 (:tag :trac) (assert-eql View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/fef970d55aac584f24ed2cc... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/fef970d55aac584f24ed2cc... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)