Commit f7988505 authored by Valentin Reis's avatar Valentin Reis

Merge branch 'pwd-oblivious' into 'master'

Make argotk $PWD-oblivious

Closes #3

See merge request argo/argotest!9
parents 839af082 01da3151
Pipeline #4663 passed with stage
in 6 seconds
...@@ -23,7 +23,7 @@ import Data.Text as Text hiding (empty) ...@@ -23,7 +23,7 @@ import Data.Text as Text hiding (empty)
import Data.Text.IO as Text import Data.Text.IO as Text
data StackArgs = StackArgs data StackArgs = StackArgs
{ dargs :: [Text] --"Daemon arguments. Properly quote this." { dargs :: [Text] --"Daemon arguments. Properly quote this."
, app :: Text --"Target application call, sh+path valid" , app :: Text --"Target application call, sh+path valid"
, manifest :: FilePath --"Input file, manifest." , manifest :: FilePath --"Input file, manifest."
, cmd_out :: FilePath --"Output file, application stdout" , cmd_out :: FilePath --"Output file, application stdout"
...@@ -37,7 +37,7 @@ instance Default StackArgs where ...@@ -37,7 +37,7 @@ instance Default StackArgs where
def = StackArgs def = StackArgs
{ dargs = [] { dargs = []
, app = "echo \"HelloWorld\"" , app = "echo \"HelloWorld\""
, manifest = "manifests/basic.json" , manifest = "basic.json"
, cmd_out = "cmd_out.log" , cmd_out = "cmd_out.log"
, cmd_err = "cmd_err.log" , cmd_err = "cmd_err.log"
, daemon_out = "daemon_out.log" , daemon_out = "daemon_out.log"
......
...@@ -9,32 +9,37 @@ import Argotest ...@@ -9,32 +9,37 @@ import Argotest
import Turtle import Turtle
import Data.Default import Data.Default
import Control.Concurrent.Async import Control.Concurrent.Async
import System.Environment
import System.Console.ANSI import System.Console.ANSI
import System.Console.ANSI.Types (Color) import System.Console.ANSI.Types (Color)
import Options.Applicative import Options.Applicative
import System.Posix.Signals import System.Posix.Signals
import Control.Monad import Control.Monad
import System.Environment.FindBin
opts :: Parser (IO ()) opts :: StackArgs -> Parser (IO ())
opts = subparser opts sa = subparser
( command "clean" (info (pure $ runClean def) ( command "clean" (info (pure $ runClean sa)
(progDesc "Clean sockets, logfiles.")) (progDesc "Clean sockets, logfiles."))
<> command "daemon" (info (pure $ runDaemon def) <> command "daemon" (info (pure $ runDaemon sa)
(progDesc "Set up and launch the daemon in synchronous mode, \ (progDesc "Set up and launch the daemon in synchronous mode, \
\with properly cleaned sockets, logfiles.")) \with properly cleaned sockets, logfiles."))
<> command "application" (info (runApp <$> argument str idm) <> command "application" (info (runApp sa <$> argument str idm)
(progDesc "Setup stack and run an arbitrary command in a container.")) (progDesc "Setup stack and run an arbitrary command in a container."))
<> command "helloworld" (info (pure $ runHelloWorld def ) <> command "helloworld" (info (pure $ runHelloWorld sa )
(progDesc "Setup stack and check that hello world app sends \ (progDesc "Setup stack and check that hello world app sends \
\message back to cmd.")) \message back to cmd."))
<> help "Type of action to run" <> help "Type of action to run"
) )
main :: IO () main :: IO ()
main = join $ execParser (info (opts <**>helper) idm) main = do
manifests <- getEnv "MANIFESTS"
let sa = def { manifest = decodeString manifests </> manifest def}
join $ execParser (info (opts sa <**>helper) idm)
runApp :: Text -> IO () runApp :: StackArgs -> Text -> IO ()
runApp app = runSimpleStack $ def {app = app} runApp sa app = runSimpleStack $ sa {app = app}
runHelloWorld :: StackArgs -> IO () runHelloWorld :: StackArgs -> IO ()
runHelloWorld a@StackArgs{..} = do runHelloWorld a@StackArgs{..} = do
......
...@@ -43,6 +43,7 @@ in rec ...@@ -43,6 +43,7 @@ in rec
p.unix p.unix
p.system-filepath p.system-filepath
p.async p.async
p.FindBin
(pkgs.haskell.lib.doJailbreak p.panpipe) (pkgs.haskell.lib.doJailbreak p.panpipe)
])) ]))
containers containers
...@@ -52,6 +53,7 @@ in rec ...@@ -52,6 +53,7 @@ in rec
amg amg
nrm nrm
]; ];
MANIFESTS = ./manifests;
}; };
test = pkgs.stdenv.mkDerivation rec { test = pkgs.stdenv.mkDerivation rec {
...@@ -62,11 +64,12 @@ in rec ...@@ -62,11 +64,12 @@ in rec
name = "env"; name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; }; env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [ buildInputs = [
(hpkgs.ghcWithPackages (p: [p.argotest])) (hpkgs.ghcWithPackages (p: [p.argotest p.FindBin]))
containers containers
amg amg
nrm nrm
]; ];
MANIFESTS = ./manifests;
}; };
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment