aboutsummaryrefslogtreecommitdiff
path: root/tools/patman/func_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/patman/func_test.py')
-rw-r--r--tools/patman/func_test.py49
1 files changed, 47 insertions, 2 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 7fa4a00786..c25a47bdeb 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -6,6 +6,7 @@
"""Functional tests for checking that patman behaves correctly"""
+import contextlib
import os
import pathlib
import re
@@ -29,8 +30,19 @@ from patman.test_util import capture_sys_output
import pygit2
from patman import status
+PATMAN_DIR = pathlib.Path(__file__).parent
+TEST_DATA_DIR = PATMAN_DIR / 'test/'
-TEST_DATA_DIR = pathlib.Path(__file__).parent / 'test/'
+
+@contextlib.contextmanager
+def directory_excursion(directory):
+ """Change directory to `directory` for a limited to the context block."""
+ current = os.getcwd()
+ try:
+ os.chdir(directory)
+ yield
+ finally:
+ os.chdir(current)
class TestFunctional(unittest.TestCase):
@@ -204,6 +216,8 @@ class TestFunctional(unittest.TestCase):
text = self._get_text('test01.txt')
series = patchstream.get_metadata_for_test(text)
cover_fname, args = self._create_patches_for_test(series)
+ get_maintainer_script = str(pathlib.Path(__file__).parent.parent.parent
+ / 'get_maintainer.pl') + ' --norolestats'
with capture_sys_output() as out:
patchstream.fix_patches(series, args)
if cover_fname and series.get('cover'):
@@ -211,7 +225,7 @@ class TestFunctional(unittest.TestCase):
series.DoChecks()
cc_file = series.MakeCcFile(process_tags, cover_fname,
not ignore_bad_tags, add_maintainers,
- None)
+ None, get_maintainer_script)
cmd = gitutil.email_patches(
series, cover_fname, args, dry_run, not ignore_bad_tags,
cc_file, in_reply_to=in_reply_to, thread=None)
@@ -506,6 +520,37 @@ complicated as possible''')
finally:
os.chdir(orig_dir)
+ def test_custom_get_maintainer_script(self):
+ """Validate that a custom get_maintainer script gets used."""
+ self.make_git_tree()
+ with directory_excursion(self.gitdir):
+ # Setup git.
+ os.environ['GIT_CONFIG_GLOBAL'] = '/dev/null'
+ os.environ['GIT_CONFIG_SYSTEM'] = '/dev/null'
+ tools.run('git', 'config', 'user.name', 'Dummy')
+ tools.run('git', 'config', 'user.email', 'dumdum@dummy.com')
+ tools.run('git', 'branch', 'upstream')
+ tools.run('git', 'branch', '--set-upstream-to=upstream')
+ tools.run('git', 'add', '.')
+ tools.run('git', 'commit', '-m', 'new commit')
+
+ # Setup patman configuration.
+ with open('.patman', 'w', buffering=1) as f:
+ f.write('[settings]\n'
+ 'get_maintainer_script: dummy-script.sh\n'
+ 'check_patch: False\n')
+ with open('dummy-script.sh', 'w', buffering=1) as f:
+ f.write('#!/usr/bin/env python\n'
+ 'print("hello@there.com")\n')
+ os.chmod('dummy-script.sh', 0x555)
+
+ # Finally, do the test
+ with capture_sys_output():
+ output = tools.run(PATMAN_DIR / 'patman', '--dry-run')
+ # Assert the email address is part of the dry-run
+ # output.
+ self.assertIn('hello@there.com', output)
+
def test_tags(self):
"""Test collection of tags in a patchstream"""
text = '''This is a patch