Commit 01da3151 authored by Valentin Reis's avatar Valentin Reis

Make argotk $PWD-oblivious

parent 839af082
Pipeline #4662 passed with stage
in 27 seconds
......@@ -23,7 +23,7 @@ import Data.Text as Text hiding (empty)
import Data.Text.IO as Text
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"
, manifest :: FilePath --"Input file, manifest."
, cmd_out :: FilePath --"Output file, application stdout"
......@@ -37,7 +37,7 @@ instance Default StackArgs where
def = StackArgs
{ dargs = []
, app = "echo \"HelloWorld\""
, manifest = "manifests/basic.json"
, manifest = "basic.json"
, cmd_out = "cmd_out.log"
, cmd_err = "cmd_err.log"
, daemon_out = "daemon_out.log"
......
......@@ -9,32 +9,37 @@ import Argotest
import Turtle
import Data.Default
import Control.Concurrent.Async
import System.Environment
import System.Console.ANSI
import System.Console.ANSI.Types (Color)
import Options.Applicative
import System.Posix.Signals
import Control.Monad
import System.Environment.FindBin
opts :: Parser (IO ())
opts = subparser
( command "clean" (info (pure $ runClean def)
opts :: StackArgs -> Parser (IO ())
opts sa = subparser
( command "clean" (info (pure $ runClean sa)
(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, \
\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."))
<> command "helloworld" (info (pure $ runHelloWorld def )
<> command "helloworld" (info (pure $ runHelloWorld sa )
(progDesc "Setup stack and check that hello world app sends \
\message back to cmd."))
<> help "Type of action to run"
)
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 app = runSimpleStack $ def {app = app}
runApp :: StackArgs -> Text -> IO ()
runApp sa app = runSimpleStack $ sa {app = app}
runHelloWorld :: StackArgs -> IO ()
runHelloWorld a@StackArgs{..} = do
......
......@@ -43,6 +43,7 @@ in rec
p.unix
p.system-filepath
p.async
p.FindBin
(pkgs.haskell.lib.doJailbreak p.panpipe)
]))
containers
......@@ -52,6 +53,7 @@ in rec
amg
nrm
];
MANIFESTS = ./manifests;
};
test = pkgs.stdenv.mkDerivation rec {
......@@ -62,11 +64,12 @@ in rec
name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [
(hpkgs.ghcWithPackages (p: [p.argotest]))
(hpkgs.ghcWithPackages (p: [p.argotest p.FindBin]))
containers
amg
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