tools.test: adding with-test-file and with-test-directory.

These provide unique temp files (and directories) that are
automatically cleaned up when the quotation exits. Mostly this
allows us to simplify some of our test files.
locals-and-roots
John Benediktsson 2016-04-04 10:31:47 -07:00
parent 2ea3e304cf
commit dd3189ecb6
1 changed files with 12 additions and 5 deletions

View File

@ -2,11 +2,12 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators command-line USING: accessors arrays assocs combinators command-line
compiler.units continuations debugger effects fry compiler.units continuations debugger effects fry
generalizations io kernel lexer locals macros namespaces parser generalizations io io.files.temp io.files.unique kernel lexer
prettyprint quotations sequences sequences.generalizations locals macros namespaces parser prettyprint quotations sequences
source-files source-files.errors source-files.errors.debugger sequences.generalizations source-files source-files.errors
splitting stack-checker summary tools.errors unicode vocabs source-files.errors.debugger splitting stack-checker summary
vocabs.files vocabs.metadata vocabs.parser words ; tools.errors unicode vocabs vocabs.files vocabs.metadata
vocabs.parser words ;
FROM: vocabs.hierarchy => load ; FROM: vocabs.hierarchy => load ;
IN: tools.test IN: tools.test
@ -157,6 +158,12 @@ SYMBOL: forget-tests?
PRIVATE> PRIVATE>
: with-test-file ( ..a quot: ( ..a path -- ..b ) -- ..b )
'[ "" "" _ cleanup-unique-file ] with-temp-directory ; inline
: with-test-directory ( ..a quot: ( ..a -- ..b ) -- ..b )
[ cleanup-unique-directory ] with-temp-directory ; inline
TEST: unit-test TEST: unit-test
TEST: must-infer-as TEST: must-infer-as
TEST: must-infer TEST: must-infer