Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asdf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tarn Burton
asdf
Commits
623bf535
Commit
623bf535
authored
9 years ago
by
Francois-Rene Rideau
Browse files
Options
Downloads
Patches
Plain Diff
Tweak with-temporary-file and its tests.
One WTF test fails on GCL, due to a compiler bug.
parent
3a5927e6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test-utilities.script
+14
-19
14 additions, 19 deletions
test/test-utilities.script
uiop/stream.lisp
+11
-11
11 additions, 11 deletions
uiop/stream.lisp
with
25 additions
and
30 deletions
test/test-utilities.script
+
14
−
19
View file @
623bf535
...
@@ -302,34 +302,29 @@
...
@@ -302,34 +302,29 @@
(ts "c" +crlf+ (strcat ccr +lf+))
(ts "c" +crlf+ (strcat ccr +lf+))
(ts (strcat acrlf "b") +lf+ (strcat acrlf blf)))
(ts (strcat acrlf "b") +lf+ (strcat acrlf blf)))
(DBG
:wtf-s
)
(DBG
"testing with-temporary-file"
)
(with-temporary-file (:stream s :direction :io :prefix "
LEP
")
(with-temporary-file (:stream s :direction :io :prefix "
WTF0
")
(println "Hello, World" s)
(println "Hello, World" s)
(file-position s 0)
(file-position s 0)
(assert-equal (read-line s) "Hello, World"))
(assert-equal (read-line s) "Hello, World"))
(DBG :wtf-p)
(let ((pn1 (with-temporary-file (:pathname pn :direction :output :prefix "WTF1")
(let ((pn
(assert-equal (read-file-lines pn) ())
(with-temporary-file (:pathname pn :direction :output :prefix "LEP")
pn)))
(assert-equal (read-file-lines pn) ())
(assert (not (probe-file pn1))))
pn)))
(assert (not (probe-file pn))))
(DBG :wtf-s-p)
(let ((pn
(with-temporary-file (:stream s :pathname p :keep t :direction :io :prefix "LEP")
(println "Hello, World" s)
(DBG :wsp s p (probe-file p))
p)))
(assert-equal (read-file-lines pn) '("Hello, World"))
(delete-file pn))
(let ((pn2 (with-temporary-file (:stream s :pathname p :keep t :direction :io :prefix "WTF2")
(println "Hello, World" s)
p)))
(assert-equal (read-file-lines pn2) '("Hello, World"))
(delete-file pn2))
#-gcl ;; BUG in GCL compiling the WTF internal loop. Works if loaded without compiling.
(assert
(assert
(not (probe-file
(not (probe-file
(let ((s 'outer-s))
(let ((s 'outer-s))
(with-temporary-file (:stream s :pathname p :direction :io :prefix "
LEP
")
(with-temporary-file (:stream s :pathname p :direction :io :prefix "
WTF3
")
(assert (open-stream-p s))
(assert (open-stream-p s))
(DBG :wsp s p (probe-file p))
(println "Same thing with :close-stream" s)
(println "Same thing with :close-stream" s)
:close-stream
:close-stream
(assert-equal s 'outer-s) ;; the stream s (1) has been closed and (2) is no longer in scope.
(assert-equal s 'outer-s) ;; the stream s (1) has been closed and (2) is no longer in scope.
...
...
This diff is collapsed.
Click to expand it.
uiop/stream.lisp
+
11
−
11
View file @
623bf535
...
@@ -601,17 +601,17 @@ Finally, the file will be deleted, unless the KEEP argument when CALL-FUNCTION'e
...
@@ -601,17 +601,17 @@ Finally, the file will be deleted, unless the KEEP argument when CALL-FUNCTION'e
(
when
stream
(
when
stream
(
setf
okp
pathname
)
(
setf
okp
pathname
)
(
when
want-stream-p
(
when
want-stream-p
(
setf
results
;; Note: can't return directly from within with-open-file
(
multiple-value-list
;; or the non-local return causes the file creation to be undone.
(
if
want-pathname-p
(
setf
results
(
multiple-value-list
(
funcall
thunk
stream
pathname
)
(
if
want-
pathname
-p
(
funcall
thunk
stream
))))))
)
(
funcall
thunk
stream
pathname
)
(
when
okp
(
funcall
thunk
stream
)))))))
(
unless
want-stream-p
(
cond
(
setf
results
(
multiple-value-list
(
call-function
thunk
pathname
)))
)
((
not
okp
)
nil
)
(
when
after
(
after
(
return
(
call-function
after
okp
)))
(
setf
results
(
multiple-value-list
(
call-function
after
pathname
)
)))
((
and
want-pathname-p
(
not
want-stream-p
))
(
return
(
call-function
thunk
okp
)))
(
return
(
apply
'values
results
))))
(
t
(
return
(
apply
'values
results
))))
)
(
when
(
and
okp
(
not
(
call-function
keep
)))
(
when
(
and
okp
(
not
(
call-function
keep
)))
(
ignore-errors
(
delete-file-if-exists
okp
))))))
(
ignore-errors
(
delete-file-if-exists
okp
))))))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment