Class: HaskellTestHook
- Inherits:
-
HaskellFileHook
- Object
- Mumukit::Templates::MultiFileHook
- HaskellFileHook
- HaskellTestHook
- Defined in:
- lib/test_hook.rb
Instance Method Summary collapse
- #command_line(test_file, _code_file) ⇒ Object
- #compile_code_file(req) ⇒ Object
- #compile_file_content(req) ⇒ Object
- #compile_test_file(req) ⇒ Object
- #has_files?(_req) ⇒ Boolean
- #to_structured_result(result) ⇒ Object
Methods inherited from HaskellFileHook
#cleanup_raw_result, #tempfile_extension
Instance Method Details
#command_line(test_file, _code_file) ⇒ Object
62 63 64 |
# File 'lib/test_hook.rb', line 62 def command_line(test_file, _code_file) ['bash', '-c', "cd #{dir_from_file_path test_file} && runhaskell #{test_file}"] end |
#compile_code_file(req) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/test_hook.rb', line 52 def compile_code_file(req) " {-# OPTIONS_GHC -fdefer-type-errors #-}\n module Code where\n \n \#{req.content}\n \#{req.extra}\n HASKELL\nend\n" |
#compile_file_content(req) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/test_hook.rb', line 13 def compile_file_content(req) { 'Test.hs' => compile_test_file(req), 'Code.hs' => compile_code_file(req) } end |
#compile_test_file(req) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/test_hook.rb', line 20 def compile_test_file(req) " {-# OPTIONS_GHC -fdefer-type-errors #-}\n import Test.Hspec\n import Test.Hspec.Runner (hspecWith, defaultConfig, Config (configFormatter))\n import Test.QuickCheck\n import Test.Hspec.Formatters\n import Code\n \n import qualified Control.Exception as Exception\n \n import Data.List\n \n structured :: Formatter\n structured = silent {\n exampleSucceeded = \\\\p ->\n writeTerm [formatPath p, \"passed\", \"\"],\n exampleFailed = \\\\p result -> case result of\n (Right e) -> writeTerm [formatPath p, \"failed\", e]\n (Left e) -> writeTerm [formatPath p, \"failed\", show e],\n headerFormatter = write $ \"@@@RESULTS-START@@@[\",\n footerFormatter = write $ \"null]\"\n }\n where formatPath (ps, p) = intercalate \" \" $ (ps ++ [p])\n writeTerm = write.(++\",\").show\n \n main :: IO ()\n main = hspecWith defaultConfig {configFormatter = Just structured} $ do\n \#{req.test.lines.map {|it| ' ' + it}.join}\n HASKELL\nend\n" |
#has_files?(_req) ⇒ Boolean
9 10 11 |
# File 'lib/test_hook.rb', line 9 def has_files?(_req) true end |
#to_structured_result(result) ⇒ Object
4 5 6 7 |
# File 'lib/test_hook.rb', line 4 def to_structured_result(result) result = result.split('@@@RESULTS-START@@@').last super(result).compact end |