Skip to content

Commit

Permalink
Allow selecting languages to test with args
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen committed Apr 23, 2022
1 parent c1fd497 commit 0aeba6e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions Glot/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
module Glot.Language
( Id
, idToText
, idFromText
, EditorConfig(..)
, RunConfig(..)
, Language(..)
Expand Down
22 changes: 21 additions & 1 deletion app/image-tester.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,39 @@ import qualified Data.Aeson as Aeson
import qualified Glot.Language as Language
import qualified Glot.DockerRun as DockerRun
import qualified Glot.Snippet as Snippet
import qualified System.Environment as Env


main :: IO ()
main =
let
prepareIds :: [String] -> [Language.Id]
prepareIds languageIds =
languageIds
& map Text.pack
& map Language.idFromText
& Maybe.catMaybes

filterLanguages :: [Language.Id] -> [Language] -> [Language]
filterLanguages languageIds languages =
if null languageIds then
languages
else
languages
& filter (\lang -> elem (Language.identifier lang) languageIds)

prepareLanguages :: [Language] -> [LanguageData]
prepareLanguages languages =
languages
& map languageDataFromLanguage
& Maybe.catMaybes
in do
languageIdsToRun <- Env.getArgs
languages <- Language.readLanguages
mapM_ runLanguage (prepareLanguages languages)
languages
& filterLanguages (prepareIds languageIdsToRun)
& prepareLanguages
& mapM_ runLanguage


data LanguageData = LanguageData
Expand Down

0 comments on commit 0aeba6e

Please sign in to comment.