@@ -11,7 +11,9 @@ import VersoUtil.LzCompress
1111import Tests
1212
1313structure Config where
14+ verbose : Bool := false
1415 updateExpected : Bool := false
16+ checkTeX : Bool := false
1517
1618open Verso.Search.Stemmer.Porter in
1719def testStemmer (_ : Config) : IO Unit := do
@@ -37,8 +39,10 @@ Tests manual-genre TeX generation. `dir` is a subdirectory specific to a particu
3739which is where actual output should go, and which contains the expected output directory.
3840`doc` is the document to be rendered.
3941-/
40- def testTexOutput (dir : System.FilePath) (doc : Verso.Doc.VersoDoc Verso.Genre.Manual) :
41- Config → IO Unit := fun config =>
42+ def testTexOutput
43+ (dir : System.FilePath)
44+ (doc : Verso.Doc.VersoDoc Verso.Genre.Manual)
45+ (config : Config) : IO Unit := do
4246 let versoConfig : Verso.Genre.Manual.Config := {
4347 destination := "src/tests/integration" / dir / "output" ,
4448 emitTeX := true ,
@@ -50,13 +54,13 @@ def testTexOutput (dir : System.FilePath) (doc : Verso.Doc.VersoDoc Verso.Genre.
5054 let logError (msg : String) := IO.eprintln msg
5155 ReaderT.run (emitTeX logError versoConfig doc.toPart) extension_impls%
5256
53- Verso.Integration.runTests {
57+ Verso.Integration.runTests { config with
5458 testDir := "src/tests/integration" / dir,
5559 updateExpected := config.updateExpected,
5660 runTest
5761 }
5862
59- def testZip (_ : Config) : IO Unit := do
63+ def testZip (cfg : Config) : IO Unit := do
6064 IO.println "Running zip tests with fixed files..."
6165 testExtract #[] .store
6266 testExtract #[] .deflate
@@ -74,16 +78,21 @@ def testZip (_ : Config) : IO Unit := do
7478 testExtract #[("T2.lean" , me), ("other" , bwd)] .store
7579 testExtract #[("T2.lean" , me), ("other" , bwd)] .deflate
7680 for _ in (0 : Nat)...10 do
77- IO.setRandSeed (← IO.monoNanosNow)
81+ let seedValue ← IO.monoNanosNow
82+ if cfg.verbose then IO.println s! "Seed is { seedValue} "
83+ IO.setRandSeed seedValue
7884 let mut randFiles := #[]
7985 for _ in 0 ...(← IO.rand 0 15 ) do
8086 let name ← randName
8187 let size ← IO.rand 0 50000
8288 let content ← IO.getRandomBytes <| .ofNat size
8389 randFiles := randFiles.push (name, content)
84- IO.println s! "Running random zip test with { randFiles.size} files, sizes:"
85- for (x, y) in randFiles do
86- IO.println s! " * { x} : { y.size} bytes"
90+ if cfg.verbose then
91+ IO.println s! "Running random zip test with { randFiles.size} files, sizes:"
92+ for (x, y) in randFiles do
93+ IO.println s! " * { x} : { y.size} bytes"
94+ else
95+ IO.println s! "Running random zip test with { randFiles.size} files"
8796 testExtract randFiles .store
8897 testExtract randFiles .deflate
8998
@@ -147,12 +156,15 @@ def tests := [
147156 testStemmer,
148157 testTexOutput "sample-doc" SampleDoc.doc,
149158 testTexOutput "inheritance-doc" InheritanceDoc.doc,
159+ testTexOutput "code-content-doc" CodeContent.doc,
150160 testZip
151161]
152162
153163def getConfig (config : Config) : List String → IO Config
154164 | [] => pure config
155165 | "--update-expected" :: args => getConfig { config with updateExpected := true } args
166+ | "--verbose" :: args | "-v" :: args => getConfig { config with verbose := true } args
167+ | "--check-tex" :: args => getConfig { config with checkTeX := true } args
156168 | other :: _ => throw <| .userError s! "Didn't understand { other} "
157169
158170def main (args : List String) : IO UInt32 := do
0 commit comments