]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.scaffold: overhaul of `scaffold-unit-tests`
authorolus2000 <alsabak@gmail.com>
Sun, 20 Aug 2023 20:02:55 +0000 (22:02 +0200)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 21 Aug 2023 13:15:49 +0000 (08:15 -0500)
basis/tools/scaffold/scaffold.factor

index 06dd4495a682b216be9ee3c4196e80cff512c379..76377d4a0dee360abf03dc0783a966c211ccec54 100644 (file)
@@ -5,9 +5,9 @@ classes classes.error combinators combinators.short-circuit
 continuations effects eval hashtables help.markup interpolate io
 io.directories io.encodings.utf8 io.files io.pathnames
 io.streams.string kernel math math.parser namespaces prettyprint
-quotations sequences sets sorting splitting strings system
-timers unicode urls vocabs vocabs.loader vocabs.metadata words
-words.symbol ;
+prettyprint.config quotations sequences sets sorting splitting
+strings system timers unicode urls vocabs vocabs.loader
+vocabs.metadata words words.symbol ;
 IN: tools.scaffold
 
 SYMBOL: developer-name
@@ -341,11 +341,13 @@ M: word scaffold-docs scaffold-word-docs ;
 : set-scaffold-tests-file ( vocab path -- )
     [ tests-file-string ] dip utf8 set-file-contents ;
 
+: vocab>test-path ( vocab -- string )
+    "-tests.factor" vocab/suffix>path ;
+
 PRIVATE>
 
 : scaffold-tests ( vocab -- )
-    ensure-vocab-exists
-    dup "-tests.factor" vocab/suffix>path
+    ensure-vocab-exists dup vocab>test-path
     scaffolding? [
         set-scaffold-tests-file
     ] [
@@ -409,16 +411,22 @@ ${example-indent}}
 : run-string ( string -- datastack )
     parse-string V{ } clone swap with-datastack ; inline
 
-: scaffold-unit-test ( -- str/f )
+: read-unit-test ( -- str/f )
     read-contents dup "" = [
         drop f
     ] [
-        [ run-string unparse ] keep
+        [ run-string [ unparse ] without-limits ] keep
         make-unit-test
     ] if ;
 
-: scaffold-unit-tests ( -- str )
-    [ scaffold-unit-test dup ] [ ] produce nip "\n\n" join ;
+: read-unit-tests ( -- str )
+    [ read-unit-test dup ] [ ] produce nip "\n\n" join ;
+
+: scaffold-unit-tests ( vocab -- )
+    dup scaffold-tests vocab>test-path
+    [ read-unit-test ]
+    [ dup print "\n\n" prepend
+        over utf8 [ write ] with-file-appender ] while* drop ;
 
 HOOK: scaffold-emacs os ( -- )