Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26 test integration #40

Merged
merged 5 commits into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
*.tix
*.tix
tmp
packagedb
15 changes: 14 additions & 1 deletion GLaDOS2023.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,17 @@ test-suite test
ExecTests

main-is: TestMain.hs
build-depends: base >=4.14.1.0, tasty >= 1.4.3, tasty-discover >= 5.0.0, tasty-hunit >= 0.10.0.3, GLaDOS2023, containers
build-depends: base >=4.14.1.0, tasty >= 1.4.3, tasty-discover >= 5.0.0, tasty-hunit >= 0.10.0.3, GLaDOS2023, containers

test-suite test-integration
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: integrationTests/
main-is: Main.hs
build-depends: base >=4.14.1.0,
ansi-terminal >= 0.11.3,
filepath >= 1.4.2.1,
process >= 1.6.8.0,
directory >= 1.3.3.0,
exitcode >= 0.1.0.0,
GLaDOS2023
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/builtins1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/builtins2.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#t
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/builtins3.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#f
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/call.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/error.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*** ERROR : variable foo is not bound.
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/factorial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3628800
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/foo.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/function1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/if1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/if2.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/if3.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/lambda1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#<procedure>
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/lambda2.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/lambda3.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/sample1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/sample2.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions IntegrationTestFolder/TestFilesSolved/superior.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#t
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ all: clean
test: clean
@cabal test --test-show-details=direct

integration-test: clean
@cabal run test-integration

clean:
@rm -f *.tix;
@rm -f *.tix
1 change: 0 additions & 1 deletion TestFiles/hello_world.scm

This file was deleted.

60 changes: 60 additions & 0 deletions integrationTests/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module Main where

import Data.List
import System.Console.ANSI
import System.Directory
import System.Exit
import System.FilePath
import System.Process

main :: IO ()
main = do
putStrLn "Integration Test:\t\t\tOutput\tExit Status\n"
loop =<< getFiles

getFiles :: IO [String]
getFiles = map takeBaseName . filter (`notElem` [".", ".."]) <$> getDirectoryContents "./IntegrationTestFolder/TestFiles/"

printOk :: IO ()
printOk =
setSGR [SetColor Foreground Vivid Green]
>> putStr ("OK")
>> setSGR [Reset]

printError :: IO ()
printError =
setSGR [SetColor Foreground Vivid Red]
>> putStr ("Error")
>> setSGR [Reset]

printRes :: Bool -> Bool -> ExitCode -> IO ()
printRes True False ExitSuccess = printOk >> putStr "\t" >> printOk >> putStr "\n"
printRes True False (ExitFailure n) = printOk >> putStr "\t" >> printError >> putStr "\n"
printRes True True ExitSuccess = printOk >> putStr "\t" >> printError >> putStr "\n"
printRes True True (ExitFailure n) = printOk >> putStr "\t" >> printOk >> putStr "\n"
printRes False False ExitSuccess = printError >> putStr "\t" >> printOk >> putStr "\n"
printRes False False (ExitFailure n) = printError >> putStr "\t" >> printError >> putStr "\n"
printRes False True ExitSuccess = printError >> putStr "\t" >> printError >> putStr "\n"
printRes False True (ExitFailure n) = printError >> putStr "\t" >> printOk >> putStr "\n"

test :: String -> (ExitCode, String, String) -> IO ()
test fn (ex, out, err) = do
solvedStr <- readFile ("./IntegrationTestFolder/TestFilesSolved/" ++ fn ++ ".scm")
printRes (solvedStr == out) (isInfixOf "error" fn) ex

getOutput :: String -> IO ()
getOutput fn =
test fn
=<< readProcessWithExitCode
"cabal"
[ "run",
"glados",
"echo-args",
"--",
("./IntegrationTestFolder/TestFiles/" ++ fn ++ ".scm")
]
""

loop :: [String] -> IO ()
loop [] = putStr ""
loop (x : xs) = putStr ("Test glados with: " ++ x ++ ".scm\t\t") >> getOutput x >> loop xs