diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-14 18:51:26 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-14 18:51:26 +0200 |
commit | be0e2017b46e981060b1f9f5fd764571ad2dc2a1 (patch) | |
tree | 1897c90e2d72fe495976850deb71ca27541dc8ac | |
parent | 077cfa3e35330ec982c0b4c9047c0956d04d1103 (diff) |
-rw-r--r-- | src/Parser/Statement.hs | 10 | ||||
-rw-r--r-- | src/Run.hs | 4 | ||||
-rw-r--r-- | src/Test.hs | 2 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs index 812c559..d843fc8 100644 --- a/src/Parser/Statement.hs +++ b/src/Parser/Statement.hs @@ -98,12 +98,6 @@ shellStatement = do , do off <- stateOffset <$> getParserState symbol ":" - pname <- case mbpname of - Just pname -> return pname - Nothing -> do - registerParseError $ FancyError off $ S.singleton $ ErrorFail $ - "missing parameter with keyword ‘as’" - return $ TypedVarName (VarName "") node <- case mbnode of Just node -> return node Nothing -> do @@ -115,8 +109,10 @@ shellStatement = do void $ L.indentGuard scn GT ref script <- shellScript cont <- testBlock ref + let expr | Just pname <- mbpname = LambdaAbstraction pname cont + | otherwise = const <$> cont return $ TestBlockStep EmptyTestBlock <$> - (SpawnShell pname <$> node <*> script <*> LambdaAbstraction pname cont) + (SpawnShell mbpname <$> node <*> script <*> expr) ] exprStatement :: TestParser (Expr (TestBlock ())) @@ -132,7 +132,9 @@ evalBlock (TestBlockStep prev step) = evalBlock prev >> case step of tool = fromMaybe (optDefaultTool opts) (lookup pname $ optProcTools opts) withProcess (Right node) pname Nothing tool $ evalBlock . inner - SpawnShell (TypedVarName (VarName tname)) node script inner -> do + SpawnShell mbname node script inner -> do + let tname | Just (TypedVarName (VarName name)) <- mbname = name + | otherwise = "shell" let pname = ProcName tname withShellProcess node pname script $ evalBlock . inner diff --git a/src/Test.hs b/src/Test.hs index b8c5049..198b7e6 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -34,7 +34,7 @@ data TestStep a where Subnet :: TypedVarName Network -> Network -> (Network -> TestBlock a) -> TestStep a DeclNode :: TypedVarName Node -> Network -> (Node -> TestBlock a) -> TestStep a Spawn :: TypedVarName Process -> Either Network Node -> (Process -> TestBlock a) -> TestStep a - SpawnShell :: TypedVarName Process -> Node -> ShellScript -> (Process -> TestBlock a) -> TestStep a + SpawnShell :: Maybe (TypedVarName Process) -> Node -> ShellScript -> (Process -> TestBlock a) -> TestStep a Send :: Process -> Text -> TestStep () Expect :: SourceLine -> Process -> Traced Regex -> [ TypedVarName Text ] -> ([ Text ] -> TestBlock a) -> TestStep a Flush :: Process -> Maybe Regex -> TestStep () |