git.iko.soy/rowtype-yoga/purescript-yoga-http-api
on v0.1.5 help sign in
rowtype-yoga/purescript-yoga-http-api/test/CompileFailTest.Spec.purs
42 lines 1.3 kB history raw
1module CompileFailTest.Spec where
3import Prelude
5import CompileFail (compileFile, spagoSources, warmCache)
6import Data.Array as Array
7import Data.Foldable (for_)
8import Data.String as String
9import Data.String.Pattern (Pattern(..))
10import Effect (Effect)
11import Effect.Class (liftEffect)
12import Effect.Ref as Ref
13import Node.FS.Sync as FSSync
14import ViTest (beforeAll, describe, test)
15import ViTest.Expect (expectToBe)
17casesDir :: String
18casesDir = "test-compile-fail/cases"
20testCompileFail :: Effect Unit
21testCompileFail = describe "Compile-fail tests" do
22 ctxRef <- liftEffect $ Ref.new { sources: [], outputDir: "output-compile-fail" }
24 beforeAll do
25 sources <- spagoSources
26 let ctx = { sources, outputDir: "output-compile-fail" }
27 liftEffect $ Ref.write ctx ctxRef
28 warmCache ctx
30 pursFiles <- liftEffect do
31 files <- FSSync.readdir casesDir
32 pure $ Array.sort $ Array.filter (String.contains (Pattern ".purs")) files
34 for_ pursFiles \file -> do
35 let filePath = casesDir <> "/" <> file
36 let testName = String.replace (Pattern ".purs") (String.Replacement "") file
38 test testName do
39 ctx <- liftEffect $ Ref.read ctxRef
40 result <- compileFile ctx filePath
41 expectToBe true result.compilationFailed
42 expectToBe true result.containsExpected