Raymond Toy pushed to branch master at cmucl / cmucl Commits: fd2e83a1 by Raymond Toy at 2025-12-12T15:38:35-08:00 Fix two important typos in unix-get-username and delete-directory In `unix-get-username`, we were freeing `name` instead of `result`. In `delete-directory`, we misspelled `recursive` as `recusive`. Fix these typos. - - - - - b9494595 by Raymond Toy at 2025-12-12T15:54:05-08:00 Add some tests for unix-get-username and delete-directory Add a simple test that unix-get-username returns something useful. Add a test for delete-directory that tests it deletes directories as specified, include recursively. - - - - - 4 changed files: - src/code/extensions.lisp - src/code/unix.lisp - tests/pathname.lisp - tests/unix.lisp Changes: ===================================== src/code/extensions.lisp ===================================== @@ -676,7 +676,7 @@ subdirectories. Dirname must be a pathname to a directory. Any NAME or TYPE components in Dirname are ignored." (declare (type pathname dirname)) - (when recusive + (when recursive ;; Find all the files or directories in DIRNAME. (dolist (path (directory (merge-pathnames "*.*" dirname))) ;; If the path is a directory, recursively delete the directory. ===================================== src/code/unix.lisp ===================================== @@ -2564,5 +2564,5 @@ (cast result c-call:c-string) nil) status)) - (free-alien name))))) + (free-alien result))))) ===================================== tests/pathname.lisp ===================================== @@ -142,3 +142,16 @@ "/*.*") :truenamep nil :follow-links nil))) (assert-equal dir-tilde dir-home)))) + +(define-test delete-directory + (let ((dir (ensure-directories-exist "tmp/a/b/c/"))) + ;; Verify that the directories were created. + (assert-equal "tmp/a/b/c/" + dir) + ;; Try to delete the directory. It should fail, which we verify + ;; by noting the directory listing is not empty. + (ext::delete-directory (pathname "tmp/")) + (assert-true (directory "tmp/")) + ;; Now recursively delete the directory. + (ext::delete-directory (pathname "tmp/") :recursive t) + (assert-false (directory "tmp/")))) ===================================== tests/unix.lisp ===================================== @@ -88,4 +88,7 @@ (assert-false result) (assert-true (and (integerp errno) (plusp errno))))) - +(define-test unix-get-username + (let ((uid (unix:unix-getuid))) + (assert-true uid) + (assert-true (unix::unix-get-username uid)))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ae1bdde7deb88dc3204e625... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ae1bdde7deb88dc3204e625... You're receiving this email because of your account on gitlab.common-lisp.net.