Skip to content

Commit 081e5f3

Browse files
committed
Rename fs -> filesystem
1 parent 24823e7 commit 081e5f3

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

buttercup-filesystem.el

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
;; simple DSL which sets up temporary file hierarchies and runs the
3434
;; code in that new context (cf. `with-temp-buffer')
3535

36-
;; The entry point is `with-temp-fs' which as first argument accepts
37-
;; the specification and then variable number of forms (i.e. "body").
38-
;; To see the documentation of the DSL call:
36+
;; The entry point is `with-temp-filesystem' which as first argument
37+
;; accepts the specification and then variable number of forms
38+
;; (i.e. "body"). To see the documentation of the DSL call:
3939
;;
40-
;; M-x describe-function RET with-temp-fs RET
40+
;; M-x describe-function RET with-temp-filesystem RET
4141

4242
;;; Code:
4343

@@ -73,14 +73,14 @@
7373
;;;;;;;;;;;;;;;;;;;;
7474
;;; Mock file system
7575

76-
(defun with-temp-fs--make-parent (spec path)
76+
(defun with-temp-filesystem--make-parent (spec path)
7777
"If SPEC is a file name, create its parent directory rooted at PATH."
7878
(save-match-data
7979
(string-match "\\(.*\\)/" spec)
8080
(when (match-string 1 spec)
8181
(make-directory (concat path "/" (match-string 1 spec)) t))))
8282

83-
(defun with-temp-fs--init (spec &optional path)
83+
(defun with-temp-filesystem--init (spec &optional path)
8484
"Interpret the SPEC inside PATH."
8585
(setq path (or path "."))
8686
(cond
@@ -91,27 +91,27 @@
9191
(stringp (cadr spec)))
9292
(when (string-match-p "/\\'" (car spec))
9393
(error "Invalid syntax: `%s' - cannot create a directory with text content" (car spec)))
94-
(with-temp-fs--make-parent (car spec) path)
94+
(with-temp-filesystem--make-parent (car spec) path)
9595
(with-temp-file (concat path "/" (car spec))
9696
(insert (cadr spec))))
9797
;; directory
9898
((and (stringp (car spec))
9999
(consp (cadr spec)))
100100
(make-directory (concat path "/" (car spec)) t)
101-
(mapc (lambda (s) (with-temp-fs--init s (concat path "/" (car spec)))) (cadr spec)))
101+
(mapc (lambda (s) (with-temp-filesystem--init s (concat path "/" (car spec)))) (cadr spec)))
102102
;; recursive spec, this should probably never happen
103-
(t (mapc (lambda (s) (with-temp-fs--init s path)) spec))))
103+
(t (mapc (lambda (s) (with-temp-filesystem--init s path)) spec))))
104104
;; directory specified using a string
105105
((and (stringp spec)
106106
(string-match-p "/\\'" spec))
107107
(make-directory (concat path "/" spec) t))
108108
;; empty file
109109
((stringp spec)
110-
(with-temp-fs--make-parent spec path)
110+
(with-temp-filesystem--make-parent spec path)
111111
(write-region "" nil (concat path "/" spec)))
112112
(t (error "Invalid syntax: `%s'" spec))))
113113

114-
(defmacro with-temp-fs (spec &rest forms)
114+
(defmacro with-temp-filesystem (spec &rest forms)
115115
"Create temporary file hierarchy according to SPEC and run FORMS.
116116
117117
SPEC is a list of specifications for file system entities which
@@ -146,7 +146,7 @@ An example showing all the possibilities:
146146
If we want to run some code in a directory with an empty file
147147
\"foo.txt\" present, we call:
148148
149-
(with-temp-fs '(\"foo\")
149+
(with-temp-filesystem '(\"foo\")
150150
(code-here)
151151
(and-some-more-forms))
152152
@@ -162,7 +162,7 @@ for change."
162162
(unwind-protect
163163
(progn
164164
(setq default-directory ,temp-root)
165-
(mapc (lambda (s) (with-temp-fs--init s ".")) ,spec)
165+
(mapc (lambda (s) (with-temp-filesystem--init s ".")) ,spec)
166166
,@forms)
167167
(delete-directory ,temp-root t)
168168
(setq default-directory ,old-dd)))))

tests/test-buttercup-filesystem.el

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,35 @@
2525
(describe "With temp fs"
2626

2727
(it "should create multiple files"
28-
(with-temp-fs '("foo" "bar" "baz")
28+
(with-temp-filesystem '("foo" "bar" "baz")
2929
(expect "foo" :to-be-file)
3030
(expect "bar" :to-be-file)
3131
(expect "baz" :to-be-file)))
3232

3333
(it "should create multiple directories and files"
34-
(with-temp-fs '("foo/" "bar/" "baz")
34+
(with-temp-filesystem '("foo/" "bar/" "baz")
3535
(expect "foo" :to-be-directory)
3636
(expect "bar" :to-be-directory)
3737
(expect "baz" :to-be-file)))
3838

3939
(it "should create nested directories"
40-
(with-temp-fs '("foo/bar" "foo/baz/")
40+
(with-temp-filesystem '("foo/bar" "foo/baz/")
4141
(expect "foo/bar" :to-be-file)
4242
(expect "foo/baz" :to-be-directory)))
4343

4444
(it "should create non-empty file"
45-
(with-temp-fs '(("foo" "amazing content"))
45+
(with-temp-filesystem '(("foo" "amazing content"))
4646
(expect "foo" :to-contain "amazing content")))
4747

4848
(it "should create non-empty nested file"
49-
(with-temp-fs '(("foo/bar" "amazing content"))
49+
(with-temp-filesystem '(("foo/bar" "amazing content"))
5050
(expect "foo/bar" :to-contain "amazing content")))
5151

5252
(it "should nest files recursively"
53-
(with-temp-fs '(("foo" ("bar" "baz" "bam/"))
54-
("a/b" ("c" "d/"))
55-
("x" (("y" ("z"))
56-
"w")))
53+
(with-temp-filesystem '(("foo" ("bar" "baz" "bam/"))
54+
("a/b" ("c" "d/"))
55+
("x" (("y" ("z"))
56+
"w")))
5757
(expect "foo/bar" :to-be-file)
5858
(expect "foo/baz" :to-be-file)
5959
(expect "foo/bam" :to-be-directory)

0 commit comments

Comments
 (0)