Update integration-tests

This commit is contained in:
Chris Penner 2021-10-27 10:43:20 -06:00
parent 3234a430e5
commit 22849504c0
3 changed files with 51 additions and 60 deletions

View File

@ -7,14 +7,14 @@ import Data.List (intercalate)
import Data.Text (pack)
import EasyTest
import Shellmet (($|))
import System.Exit (ExitCode (ExitFailure, ExitSuccess))
import System.Exit (ExitCode (ExitSuccess))
import System.Process (readProcessWithExitCode)
uFile :: String
uFile = "cli/integration-tests/IntegrationTests/print.u"
uFile = "unison-cli/integration-tests/IntegrationTests/print.u"
transcriptFile :: String
transcriptFile = "cli/integration-tests/IntegrationTests/transcript.md"
transcriptFile = "unison-cli/integration-tests/IntegrationTests/transcript.md"
unisonCmdString :: String
unisonCmdString = unlines
@ -29,48 +29,45 @@ test :: Test ()
test =
EasyTest.using (pure ()) clearTempCodebase \_ ->
scope "argument-parsing" . tests $
[ expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "-h"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "version", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "init", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run", "--help"] ""
-- , expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run.compile", "--help"] "" -- Invalid Argument?
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run.file", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run.pipe", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "transcript", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "transcript.fork", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "headless", "--help"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "version"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "init"] "" -- removed
-- , expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run"] "" -- how?
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run.file", uFile, "print"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "run.pipe", "print"] unisonCmdString
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "transcript", transcriptFile] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "transcript.fork", transcriptFile] ""
-- , expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "headless"] "" -- ?
[ expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "-h"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "version", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "init", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run.file", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run.pipe", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "transcript", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "transcript.fork", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "headless", "--help"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "version"] ""
-- , expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run"] "" -- how?
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run.file", uFile, "print"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "run.pipe", "print"] unisonCmdString
, expectExitCode ExitSuccess "stack" [] ["exec", "--", "unison", "transcript", transcriptFile, "--codebase-create", tempCodebase] ""
, expectExitCode ExitSuccess "stack" [] ["exec", "--", "unison", "transcript.fork", transcriptFile, "--codebase-create", tempCodebase] ""
-- , expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "headless"] "" -- ?
-- options
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--port", "8000"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--host", "localhost"] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--token", "MY_TOKEN"] "" -- ?
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--codebase-create", tempCodebase] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--codebase", tempCodebase] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--ui", tempCodebase] ""
, expectExitCode ExitSuccess "stack" ["exec", "--", "unison", "--no-base"] ""
-- Failure
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "--port", "x"] "" -- must be number
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "run.compile", "--help"] "" -- ?
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "run.file"] "" -- without file
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "run.file", uFile] "" -- without SYMBOL
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "transcript"] "" -- without file
, expectExitCode (ExitFailure 1) "stack" ["exec", "--", "unison", "transcript.fork"] "" -- without file
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "--port", "8000"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "--host", "localhost"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "--token", "MY_TOKEN"] "" -- ?
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison"] ""
, expectExitCode ExitSuccess "stack" defaultArgs ["exec", "--", "unison", "--ui", tempCodebase] ""
-- run.compiled appears to be broken at the moment, these should be added back once it's
-- fixed to ensure it keeps working.
-- , scope "can compile, then run compiled artifact" $ tests
-- [ expectExitCode ExitSuccess "stack" defaultArgs [] ["exec", "--", "unison", "transcript", transcriptFile] ""
-- , expectExitCode ExitSuccess "stack" defaultArgs [] ["exec", "--", "unison", "run.compiled", "./unison-cli/integration-tests/IntegrationTests/main"] ""
-- ]
]
expectExitCode :: ExitCode -> FilePath -> [String] -> String -> Test ()
expectExitCode expected cmd args stdin = scope (intercalate " " (cmd : args)) do
expectExitCode :: ExitCode -> FilePath -> [String] -> [String] -> String -> Test ()
expectExitCode expected cmd defArgs args stdin = scope (intercalate " " (cmd : args <> defArgs)) do
(code, _, _) <- io $ readProcessWithExitCode cmd args stdin
expectEqual code expected
defaultArgs :: [String]
defaultArgs = ["--codebase-create", tempCodebase, "--no-base"]
clearTempCodebase :: () -> IO()
clearTempCodebase _ = do
"rm" $| (map pack ["-rf", tempCodebase])

View File

@ -2,19 +2,23 @@
```ucm:hide
.> builtins.mergeio
.> load ./unison-src/transcripts-using-base/base.u
```
Test
```ucm:hide
.> builtins.mergeio
.> load ./unison-src/transcripts-using-base/base.u
.> add
```
```unison
use .builtin
coolFunction x = x * 2
coolFunction.doc = {{ This is a cool function. }}
main : '{IO, Exception} ()
main = '(printLine "Hello, world!")
```
```ucm
.> add
.> link coolFunction.doc coolFunction
.> compile.output main ./unison-cli/integration-tests/IntegrationTests/main
```

View File

@ -1,13 +1,10 @@
# Integration test: transcript
Test
```unison
use .builtin
coolFunction x = x * 2
coolFunction.doc = {{ This is a cool function. }}
main : '{IO, Exception} ()
main = '(printLine "Hello, world!")
```
```ucm
@ -18,8 +15,7 @@ coolFunction.doc = {{ This is a cool function. }}
⍟ These new definitions are ok to `add`:
coolFunction : Nat -> Nat
coolFunction.doc : Doc.Deprecated
main : '{IO, Exception} ()
```
```ucm
@ -27,14 +23,8 @@ coolFunction.doc = {{ This is a cool function. }}
⍟ I've added these definitions:
coolFunction : Nat -> Nat
coolFunction.doc : Doc.Deprecated
main : '{IO, Exception} ()
.> link coolFunction.doc coolFunction
Updates:
1. coolFunction : Nat -> Nat
+ 2. coolFunction.doc : builtin.Doc
.> compile.output main ./unison-cli/integration-tests/IntegrationTests/main
```