From 41b49f8bb3250a16afb52edeb87b423ee6df5622 Mon Sep 17 00:00:00 2001 From: Ian Grant Jeffries Date: Mon, 11 Nov 2019 16:45:05 -0500 Subject: [PATCH] Improve test efficiency --- bowtie-js/test/Test.hs | 10 +++++----- bowtie/test/Test.hs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bowtie-js/test/Test.hs b/bowtie-js/test/Test.hs index 216c159..aed3b4e 100644 --- a/bowtie-js/test/Test.hs +++ b/bowtie-js/test/Test.hs @@ -13,7 +13,8 @@ import qualified Bowtie.Example import qualified Data.Text.IO as TIO main :: IO () -main = +main = do + libFiles <- readDirectoryFiles "../example-lib" hspec do describe "well-typed-examples" @@ -21,7 +22,7 @@ main = describe "applications" - testApps + (testApps libFiles) runWellTyped :: (FilePath, Text) -> Spec runWellTyped (name, src) = @@ -37,11 +38,10 @@ runWellTyped (name, src) = let annotatedRes = res <> "\n\n/*\n" <> js <> "\n*/\n" TIO.writeFile ("test/well-typed-golden-files" name) annotatedRes -testApps :: Spec -testApps = +testApps :: HashMap FilePath Text -> Spec +testApps libFiles = it "lunar-lander" do appSource <- TIO.readFile "../example-app/lunar-lander.bowtie" - libFiles <- readDirectoryFiles "../example-lib" -- TODO: wasted work -- TODO: get rid of .. js <- case sourcesToCore libFiles ("../example-app/lunar-lander.bowtie", appSource) of Left e -> diff --git a/bowtie/test/Test.hs b/bowtie/test/Test.hs index 43cf39a..e82b682 100644 --- a/bowtie/test/Test.hs +++ b/bowtie/test/Test.hs @@ -16,6 +16,7 @@ import qualified Text.Megaparsec as Mega main :: IO () main = do + libFiles <- readDirectoryFiles "../example-lib" appExamples <- getAppExamples hspec do describe @@ -37,12 +38,11 @@ main = do Bowtie.Surface.InferSpec.spec describe "example-app" $ - for_ appExamples f + for_ appExamples (f libFiles) where - f :: FilePath -> Spec - f path = + f :: HashMap FilePath Text -> FilePath -> Spec + f libFiles path = it path do - libFiles <- readDirectoryFiles "../example-lib" -- TODO: wasted work appSource <- TIO.readFile path case Interpret.interpretProgram libFiles (path, appSource) of Left e ->