From 62375ebf2da01942145d8fc9163e7e764697dfac Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Thu, 25 Apr 2024 12:20:31 -0700 Subject: [PATCH] Refine unit test dependencies (#1804) This is a random refactoring that does two things: * Improves speed of `scripts/gen/render-sublibrary-dependencies.sh` script * Refine imports of the `TestModel.hs` (renamed to `TestRepl.hs`) unit test It appears that the only reason that the `swarm-unit` test suite imports the entire `swarm` sublibrary (hence the `brick` package), is due to `TestRepl`, which (now) imports `Swarm.TUI.Model.Repl`. Perhaps it would make sense to separate these at some point? --- scripts/gen/render-sublibrary-dependencies.sh | 2 +- swarm.cabal | 10 ++++++++-- test/unit/Main.hs | 4 ++-- test/unit/{TestModel.hs => TestRepl.hs} | 12 ++++++------ 4 files changed, 17 insertions(+), 11 deletions(-) rename test/unit/{TestModel.hs => TestRepl.hs} (95%) diff --git a/scripts/gen/render-sublibrary-dependencies.sh b/scripts/gen/render-sublibrary-dependencies.sh index 25e8e2f59..689b795cf 100755 --- a/scripts/gen/render-sublibrary-dependencies.sh +++ b/scripts/gen/render-sublibrary-dependencies.sh @@ -14,6 +14,6 @@ cd $SCRIPT_DIR/../.. # Note that "rm -f dist-newstyle/cache/plan.json" is insufficient; # we need remove the whole cache: rm -r dist-newstyle/cache -cabal build +cabal build --dry-run cabal-plan --hide-global --hide-builtin dot --tred --root swarm | twopi -Tsvg -o docs/image/sublibrary-graph.svg \ No newline at end of file diff --git a/swarm.cabal b/swarm.cabal index e7480fe53..46d42abf6 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -800,12 +800,12 @@ test-suite swarm-unit TestInventory TestLSP TestLanguagePipeline - TestModel TestNotification TestOrdering TestPedagogy TestPretty TestRecipeCoverage + TestRepl TestScoring TestUtil @@ -820,7 +820,6 @@ test-suite swarm-unit hashable, lens, mtl, - swarm, tasty >=0.10 && <1.6, tasty-expected-failure >=0.12 && <0.13, tasty-hunit >=0.10 && <0.11, @@ -830,6 +829,13 @@ test-suite swarm-unit vty, witch, + build-depends: + swarm, + swarm:swarm-engine, + swarm:swarm-lang, + swarm:swarm-scenario, + swarm:swarm-util, + hs-source-dirs: test/unit default-language: Haskell2010 ghc-options: -threaded diff --git a/test/unit/Main.hs b/test/unit/Main.hs index 7d640d877..7aa1dbf32 100644 --- a/test/unit/Main.hs +++ b/test/unit/Main.hs @@ -34,12 +34,12 @@ import TestEval (testEval) import TestInventory (testInventory) import TestLSP (testLSP) import TestLanguagePipeline (testLanguagePipeline) -import TestModel (testModel) import TestNotification (testNotification) import TestOrdering (testOrdering) import TestPedagogy (testPedagogy) import TestPretty (testPrettyConst) import TestRecipeCoverage (testDeviceRecipeCoverage) +import TestRepl (testRepl) import TestScoring (testHighScores) import Witch (from) @@ -61,7 +61,7 @@ tests s = , testDeviceRecipeCoverage (initState $ s ^. runtimeState . stdGameConfigInputs) , testHighScores , testEval (s ^. gameState) - , testModel + , testRepl , testPedagogy (s ^. runtimeState) , testInventory , testNotification (s ^. gameState) diff --git a/test/unit/TestModel.hs b/test/unit/TestRepl.hs similarity index 95% rename from test/unit/TestModel.hs rename to test/unit/TestRepl.hs index 22ad6e11e..9fd9c6675 100644 --- a/test/unit/TestModel.hs +++ b/test/unit/TestRepl.hs @@ -3,19 +3,19 @@ -- | -- SPDX-License-Identifier: BSD-3-Clause -- --- Swarm unit tests -module TestModel where +-- Swarm REPL unit tests +module TestRepl where import Data.String (fromString) import Data.Text (Text) -import Swarm.TUI.Model +import Swarm.TUI.Model.Repl import Test.Tasty import Test.Tasty.HUnit -testModel :: TestTree -testModel = +testRepl :: TestTree +testRepl = testGroup - "TUI Model" + "TUI REPL" [ testCase "latest repl lines at start" ( assertEqual