mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-25 07:16:42 +00:00
test: allow multiple diff files to be consumed
This sets up the ability to have one diff file create a simulated filesystem and a second to simulate an edit of an existing file
This commit is contained in:
@@ -16,21 +16,22 @@ class IssueUrlInsertionTest(unittest.TestCase):
|
|||||||
diff_file = None
|
diff_file = None
|
||||||
parser = None
|
parser = None
|
||||||
|
|
||||||
def _setUp(self, diff_file):
|
def _setUp(self, diff_files):
|
||||||
# get current working directory
|
# get current working directory
|
||||||
self.orig_cwd = os.getcwd()
|
self.orig_cwd = os.getcwd()
|
||||||
|
|
||||||
# Create temporary directory to hold simulated filesystem.
|
# Create temporary directory to hold simulated filesystem.
|
||||||
self.tempdir = tempfile.TemporaryDirectory()
|
self.tempdir = tempfile.TemporaryDirectory()
|
||||||
|
|
||||||
# run patch against the diff file to generate the simulated filesystem
|
for diff_file in diff_files:
|
||||||
subprocess.run(['patch', '-d', self.tempdir.name,
|
# run patch against the diff file to generate/update the simulated filesystem
|
||||||
'-i', f'{os.getcwd()}/tests/{diff_file}'],
|
subprocess.run(['patch', '-d', self.tempdir.name,
|
||||||
stdout=subprocess.DEVNULL,
|
'-i', f'{os.getcwd()}/tests/{diff_file}'],
|
||||||
stderr=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
check=True)
|
stderr=subprocess.DEVNULL,
|
||||||
|
check=True)
|
||||||
|
|
||||||
self.diff_file = open(f'tests/{diff_file}', 'r')
|
self.diff_file = open(f'tests/{diff_files[-1]}', 'r')
|
||||||
self.parser = TodoParser()
|
self.parser = TodoParser()
|
||||||
with open('syntax.json', 'r') as syntax_json:
|
with open('syntax.json', 'r') as syntax_json:
|
||||||
self.parser.syntax_dict = json.load(syntax_json)
|
self.parser.syntax_dict = json.load(syntax_json)
|
||||||
@@ -54,7 +55,7 @@ class IssueUrlInsertionTest(unittest.TestCase):
|
|||||||
@unittest.skipIf(os.getenv('SKIP_PROCESS_DIFF_TEST', 'false') == 'true',
|
@unittest.skipIf(os.getenv('SKIP_PROCESS_DIFF_TEST', 'false') == 'true',
|
||||||
"Skipping because 'SKIP_PROCESS_DIFF_TEST' is 'true'")
|
"Skipping because 'SKIP_PROCESS_DIFF_TEST' is 'true'")
|
||||||
def test_url_insertion(self):
|
def test_url_insertion(self):
|
||||||
self._setUp('test_new.diff')
|
self._setUp(['test_new.diff'])
|
||||||
self._standardTest(80)
|
self._standardTest(80)
|
||||||
|
|
||||||
# There is a known bug related to this issue, so until it's resolved
|
# There is a known bug related to this issue, so until it's resolved
|
||||||
@@ -62,7 +63,7 @@ class IssueUrlInsertionTest(unittest.TestCase):
|
|||||||
# See #225 and #224
|
# See #225 and #224
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_same_title_in_same_file(self):
|
def test_same_title_in_same_file(self):
|
||||||
self._setUp('test_same_title_in_same_file.diff')
|
self._setUp(['test_same_title_in_same_file.diff'])
|
||||||
self._standardTest(5)
|
self._standardTest(5)
|
||||||
|
|
||||||
# There is a known bug related to this issue, so until it's resolved
|
# There is a known bug related to this issue, so until it's resolved
|
||||||
@@ -70,7 +71,7 @@ class IssueUrlInsertionTest(unittest.TestCase):
|
|||||||
# See #229
|
# See #229
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_comment_suffix_after_source_line(self):
|
def test_comment_suffix_after_source_line(self):
|
||||||
self._setUp('test_comment_suffix_after_source_line.diff')
|
self._setUp(['test_comment_suffix_after_source_line.diff'])
|
||||||
self._standardTest(1)
|
self._standardTest(1)
|
||||||
# get details about the issue and source file
|
# get details about the issue and source file
|
||||||
issue = self.raw_issues[0]
|
issue = self.raw_issues[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user