]> gitweb.factorcode.org Git - factor.git/commitdiff
io.files.unique: Make sure the files are the same except for the suffix. Add unit...
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 26 May 2016 00:44:13 +0000 (17:44 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 26 May 2016 00:49:59 +0000 (17:49 -0700)
basis/io/files/unique/unique-tests.factor
basis/io/files/unique/unique.factor

index f71a28f78dab2556279a5092237327e4b374de5e..e12600c7a2f10e8c65e50df0fe6ec3508c5e3b89 100644 (file)
@@ -47,3 +47,11 @@ IN: io.files.unique.tests
         ] with-unique-directory drop
     ] with-temp-directory
 ] unit-test
+
+{ 29 } [
+    [
+        "unique-files-" { "-test.0" "-test.1" } [
+            [ file-name ] map first2 mismatch
+        ] cleanup-unique-files
+    ] with-temp-directory
+] unit-test
\ No newline at end of file
index 77d5628b15ffa0d1c16a5b5e8403cd74a7e4590f..625dba32b6e22042722ab324ab6dd60be0c0ad95 100644 (file)
@@ -38,8 +38,8 @@ PRIVATE>
 
 : unique-files ( prefix suffixes -- paths )
     '[
-        _ _ [
-            random-file-name glue
+        _ _ random-file-name '[
+            _ glue
             dup touch-unique-file
         ] with map
     ] unique-retries get retry [ absolute-path ] map ;
@@ -48,7 +48,7 @@ PRIVATE>
     prefix suffix unique-file :> path
     [ path quot call ] [ path delete-file ] [ ] cleanup ; inline
 
-:: cleanup-unique-files ( ..a prefix suffixes quot: ( ..a path -- ..b ) -- ..b )
+:: cleanup-unique-files ( ..a prefix suffixes quot: ( ..a paths -- ..b ) -- ..b )
     prefix suffixes unique-files :> paths
     [ paths quot call ] [ paths [ delete-file ] each ] [ ] cleanup ; inline