Skip to content

Commit

Permalink
Improve test efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Grant Jeffries committed Nov 11, 2019
1 parent 7d718cd commit 41b49f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions bowtie-js/test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ 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"
(for_ Bowtie.Example.wellTyped runWellTyped)

describe
"applications"
testApps
(testApps libFiles)

runWellTyped :: (FilePath, Text) -> Spec
runWellTyped (name, src) =
Expand All @@ -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 ->
Expand Down
8 changes: 4 additions & 4 deletions bowtie/test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import qualified Text.Megaparsec as Mega

main :: IO ()
main = do
libFiles <- readDirectoryFiles "../example-lib"
appExamples <- getAppExamples
hspec do
describe
Expand All @@ -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 ->
Expand Down

0 comments on commit 41b49f8

Please sign in to comment.