Skip to content

Commit

Permalink
Add shell-mode to shell plugin
Browse files Browse the repository at this point in the history
Now you can run shell plugin just you are running shell!

[TestRun:Example]
plugin = Shell
shell_mode = true
command = #!/bin/bash
          echo "hi"
          SOMEVAR=2
          echo somevar: $$SOMEVAR
          echo somevar+2: $$($$SOMEVAR + 2)

Signed-off-by: Richard Barella <richard.t.barella@intel.com>
  • Loading branch information
ribab committed Dec 5, 2018
1 parent e54727b commit 3cb6ca1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pylib/Tools/Build/Shell.py
Expand Up @@ -51,6 +51,7 @@ def __init__(self):
self.options['allocate_cmd'] = (None, "Command to use for allocating nodes from the resource manager")
self.options['deallocate_cmd'] = (None, "Command to use for deallocating nodes from the resource manager")
self.options['asis_target'] = (None, "Specifies name of asis_target being built. This is used with \"ASIS\" keyword to determine whether to do anything.")
self.options['shell_mode'] = ("false", "Use shlex or shell-mode for parsing?")

self.allocated = False
self.testDef = None
Expand Down Expand Up @@ -352,7 +353,10 @@ def execute(self, log, keyvals, testDef):
if False == self.allocate(log, cmds, testDef):
return

cfgargs = shlex.split(cmds['command'])
if cmds['shell_mode'].lower() == "false":
cfgargs = shlex.split(cmds['command'])
else:
cfgargs = ["sh", "-c", cmds['command']]

if 'TestRun' in log['section'].split(":")[0]:
harass_exec_ids = testDef.harasser.start(testDef)
Expand Down
26 changes: 26 additions & 0 deletions tests/bat/shell_mode.ini
@@ -0,0 +1,26 @@
[MTTDefaults]
description = Tests shell_mode feature in Shell plugin

[TestRun:with_shell_mode]
plugin = Shell
shell_mode = true
command = #!/bin/bash
echo "hi"
SOMEVAR=2
echo somevar: $$SOMEVAR
echo somevar+2: $$($$SOMEVAR + 2)

[TestRun:without_shell_mode]
plugin = Shell
command = #!/bin/bash
echo "hi"
SOMEVAR=2
echo somevar: $$SOMEVAR
echo somevar+2: $$($$SOMEVAR + 2)
fail_test = true



[Reporter:JunitXML]
plugin = JunitXML
filename = default_check_profile.xml

0 comments on commit 3cb6ca1

Please sign in to comment.