提交 496f4550 编写于 作者: L Lucas Meneghel Rodrigues

Merge pull request #369 from lmr/fix-wrapper-patterns

Fix Wrapper Patterns
......@@ -25,6 +25,7 @@ import stat
import shlex
import shutil
import threading
import fnmatch
try:
import subprocess32 as subprocess
......@@ -868,11 +869,8 @@ def should_run_inside_wrapper(cmd):
args = shlex.split(cmd)
cmd_binary_name = args[0]
for script, cmd in runtime.WRAP_PROCESS_NAMES_EXPR:
if os.path.isabs(cmd_binary_name) and os.path.isabs(cmd) is False:
cmd_binary_name = os.path.basename(cmd_binary_name)
cmd = os.path.basename(cmd)
if cmd_binary_name == cmd:
for script, cmd_expr in runtime.WRAP_PROCESS_NAMES_EXPR:
if fnmatch.fnmatch(cmd_binary_name, cmd_expr):
runtime.CURRENT_WRAPPER = script
if runtime.WRAP_PROCESS is not None and runtime.CURRENT_WRAPPER is None:
......
......@@ -6,7 +6,8 @@ import unittest
import tempfile
# simple magic for using scripts within a source tree
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..')
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..',
'..', '..')
basedir = os.path.abspath(basedir)
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
......@@ -41,36 +42,46 @@ class WrapperTest(unittest.TestCase):
def test_global_wrapper(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --wrapper %s examples/tests/datadir.py' % self.script.path
cmd_line = ('./scripts/avocado run --wrapper %s '
'examples/tests/datadir.py' % self.script.path)
result = process.run(cmd_line, ignore_status=True)
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertTrue(os.path.exists(self.tmpfile),
"Wrapper did not create file %s" % self.tmpfile)
"Wrapper did not touch the tmp file %s\nStdout: "
"%s\nCmdline: %s" %
(self.tmpfile, result.stdout, cmd_line))
def test_process_wrapper(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --wrapper %s:datadir examples/tests/datadir.py' % self.script.path
cmd_line = ('./scripts/avocado run --wrapper %s:*/datadir '
'examples/tests/datadir.py' % self.script.path)
result = process.run(cmd_line, ignore_status=True)
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertTrue(os.path.exists(self.tmpfile),
"Wrapper did not create file %s" % self.tmpfile)
"Wrapper did not touch the tmp file %s\nStdout: "
"%s\nStdout: %s" %
(self.tmpfile, cmd_line, result.stdout))
def test_both_wrappers(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --wrapper %s --wrapper %s:datadir examples/tests/datadir.py' % (self.dummy.path, self.script.path)
cmd_line = ('./scripts/avocado run --wrapper %s --wrapper %s:*/datadir '
'examples/tests/datadir.py' % (self.dummy.path,
self.script.path))
result = process.run(cmd_line, ignore_status=True)
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertTrue(os.path.exists(self.tmpfile),
"Wrapper did not create file %s" % self.tmpfile)
"Wrapper did not touch the tmp file %s\nStdout: "
"%s\nStdout: %s" %
(self.tmpfile, cmd_line, result.stdout))
def tearDown(self):
self.script.remove()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册