Raymond Toy pushed to branch issue-266-b-tilde-pathname-support at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/general-info/release-21f.md
    ... ... @@ -39,6 +39,7 @@ public domain.
    39 39
         * ~~#253~~ Block-compile list-to-hashtable and callers
    
    40 40
         * ~~#258~~ Remove `get-page-size` from linux-os.lisp
    
    41 41
         * ~~#269~~ Add function to get user's home directory
    
    42
    +    * ~~#266~~ Support "~user" in namestrings
    
    42 43
       * Other changes:
    
    43 44
       * Improvements to the PCL implementation of CLOS:
    
    44 45
       * Changes to building procedure:
    

  • tests/os.lisp
    ... ... @@ -7,7 +7,7 @@
    7 7
     (define-test user-homedir.1
    
    8 8
       "Test user-homedir"
    
    9 9
       (:tag :issues)
    
    10
    -  ;; Simple test to see if get-user-homedir-pathname returns the
    
    10
    +  ;; Simple test to see if get-user-homedir-namestring returns the
    
    11 11
       ;; expected value.  Use getuid and getpwuid to figure out what the
    
    12 12
       ;; name and home directory should be.
    
    13 13
       (let* ((uid (unix:unix-getuid))
    
    ... ... @@ -15,15 +15,13 @@
    15 15
         (assert-true uid)
    
    16 16
         (assert-true user-info)
    
    17 17
         (let* ((info-dir (unix:user-info-dir user-info))
    
    18
    -           (info-name (unix:user-info-name user-info))
    
    19
    -           (expected-home-pathname (pathname
    
    20
    -                                    (concatenate 'string info-dir "/"))))
    
    21
    -      (multiple-value-bind (home-pathname status)
    
    22
    -          (system:get-user-homedir-pathname info-name)
    
    18
    +           (info-name (unix:user-info-name user-info)))
    
    19
    +      (multiple-value-bind (home-namestring status)
    
    20
    +          (system:get-user-homedir-namestring info-name)
    
    23 21
             (assert-true info-dir)
    
    24 22
             (assert-true info-name)
    
    25 23
     
    
    26
    -        (assert-equal home-pathname expected-home-pathname)
    
    24
    +        (assert-equal home-namestring info-dir)
    
    27 25
             (assert-eql status 0)))))
    
    28 26
     
    
    29 27
     (define-test user-homedir.2
    
    ... ... @@ -33,6 +31,6 @@
    33 31
       ;; value for a user that does not exist.  Well, we assume such a
    
    34 32
       ;; user doesn't exist.
    
    35 33
           (multiple-value-bind (home-pathname status)
    
    36
    -          (system:get-user-homedir-pathname "zotuserunknown")
    
    34
    +          (system:get-user-homedir-namestring "zotuserunknown")
    
    37 35
             (assert-eql home-pathname nil)
    
    38 36
             (assert-eql status 0)))

  • tests/pathname.lisp
    ... ... @@ -111,3 +111,34 @@
    111 111
     	  test
    
    112 112
     	(assert-equal printed-value (output pathname))
    
    113 113
     	(assert-equal namestring (namestring pathname))))))
    
    114
    +
    
    115
    +(define-test issue.266.pathname-tilde.unknown-user
    
    116
    +    (:tag :issues)
    
    117
    +  ;; This assumes that there's no user named "zotunknown".
    
    118
    +  (assert-error 'simple-error (parse-namestring "~zotunknown/*.*")))
    
    119
    +
    
    120
    +(define-test issue.266.pathname-tilde.1
    
    121
    +    (:tag :issues)
    
    122
    +  ;; Simple test for ~ in pathnames.  Get a directory list using
    
    123
    +  ;; #P"~/*.*".  This should produce exactly the same list as the
    
    124
    +  ;; #search-list P"home:*.*".
    
    125
    +  (let ((dir-home (directory #p"home:*.*" :truenamep nil :follow-links nil))
    
    126
    +        (dir-tilde (directory #p"~/*.*" :truenamep nil :follow-links nil)))
    
    127
    +    (assert-equal dir-tilde dir-home)))
    
    128
    +
    
    129
    +(define-test issue.266.pathname-tilde.2
    
    130
    +    (:tag :issues)
    
    131
    +  ;; Simple test for ~ in pathnames.  Get a directory list using
    
    132
    +  ;; #P"~user/*.*".  This should produce exactly the same list as the
    
    133
    +  ;; #search-list P"home:*.*".  We determine the user name via getuid
    
    134
    +  ;; #and getpwuid.
    
    135
    +  (let ((user-name (unix:user-info-name (unix:unix-getpwuid (unix:unix-getuid)))))
    
    136
    +    (assert-true user-name)
    
    137
    +    (let* ((dir-home (directory #p"home:*.*" :truenamep nil :follow-links nil))
    
    138
    +         
    
    139
    +           (dir-tilde (directory (concatenate 'string
    
    140
    +                                              "~"
    
    141
    +                                              user-name
    
    142
    +                                              "/*.*")
    
    143
    +                                 :truenamep nil :follow-links nil)))
    
    144
    +      (assert-equal dir-tilde dir-home))))