mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-25 07:16:42 +00:00
fix: Clean up TeX syntax and add tests
1. Swap `\` for `\\` for TeX block comments to avoid issues with parsing 2. Add tests for TeX, Julia, AutoHotKey, Org mode, and Handlebars 3. Ensure tests can be run with 1 line command 4. Change logic in test framework so that tests run off of local version of `syntax.json` rather than remote version 5. Add details for running tests + adding tests for your syntax PR to readme 6. Add .gitignore file for python (to avoid compiles form tests winding up in commits)
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@@ -106,4 +106,65 @@ index 6397789..494d42f 100644
|
||||
+++ b/src/tests/example_file.sql
|
||||
@@ -1,2 +0,0 @@
|
||||
--- TODO Select all:
|
||||
-SELECT * FROM Products;
|
||||
-SELECT * FROM Products;
|
||||
diff --git a/tests/example_file.tex b/src/tests/example_file.tex
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.tex
|
||||
@@ -0,0 +1,2 @@
|
||||
-% TODO Add in preamble details
|
||||
-\begin{document}
|
||||
- \begin{comment}
|
||||
- TODO This document needs content
|
||||
- label: urgent
|
||||
- \end{comment}
|
||||
-\end{document}
|
||||
diff --git a/tests/example_file.jl b/src/tests/example_file.jl
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.jl
|
||||
@@ -0,0 +1,2 @@
|
||||
- # TODO: Hopefully this comment turns into an issue
|
||||
- print("Hello World")
|
||||
- #= TODO: Multiline comments
|
||||
- also need to be turned into task, and hopefully
|
||||
- kept together as one.
|
||||
- =#
|
||||
diff --git a/tests/example_file.ahk b/src/tests/example_file.ahk
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.ahk
|
||||
@@ -0,0 +1,2 @@
|
||||
- ; TODO: Find a better way to manage hotkeys
|
||||
- ; Maybe just switch to vim??
|
||||
- #h::
|
||||
- RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
|
||||
diff --git a/tests/example_file.hbs b/src/tests/example_file.hbs
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.hbs
|
||||
@@ -0,0 +1,2 @@
|
||||
- <!-- TODO: Hopefully this comment turns into a todo issue -->
|
||||
- {{!
|
||||
- TODO: Make a handlebar templtate
|
||||
- This is really just a test, but hopefully this works~!
|
||||
- }}
|
||||
diff --git a/tests/example_file.org b/src/tests/example_file.org
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.org
|
||||
@@ -0,0 +1,2 @@
|
||||
- # TODO: Hopefully this comment turns into a todo issue
|
||||
- #+begin_src python
|
||||
- print("Hello World")
|
||||
- #+end_src
|
||||
- + #+begin_comment
|
||||
- TODO: Multiline comments
|
||||
- also need to be turned into todos, and hopefully
|
||||
- kept together as one todo
|
||||
- #+end_comment
|
||||
|
||||
@@ -112,4 +112,67 @@ index 0000000..7cccc5b
|
||||
+++ b/src/tests/example_file.sql
|
||||
@@ -0,0 +1,2 @@
|
||||
+-- TODO Select all:
|
||||
+SELECT * FROM Products;
|
||||
+SELECT * FROM Products;
|
||||
diff --git a/tests/example_file.tex b/src/tests/example_file.tex
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.tex
|
||||
@@ -0,0 +1,2 @@
|
||||
+% TODO Add in preamble details
|
||||
+\begin{document}
|
||||
+ \begin{comment}
|
||||
+ TODO This document needs content
|
||||
+ label: urgent
|
||||
+ \end{comment}
|
||||
+\end{document}
|
||||
diff --git a/tests/example_file.jl b/src/tests/example_file.jl
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.jl
|
||||
@@ -0,0 +1,2 @@
|
||||
+ # TODO: Hopefully this comment turns into an issue
|
||||
+ print("Hello World")
|
||||
+ #= TODO: Multiline comments
|
||||
+ also need to be turned into task, and hopefully
|
||||
+ kept together as one.
|
||||
+ =#
|
||||
diff --git a/tests/example_file.ahk b/src/tests/example_file.ahk
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.ahk
|
||||
@@ -0,0 +1,2 @@
|
||||
+ ; TODO: Find a better way to manage hotkeys
|
||||
+ ; Maybe just switch to vim??
|
||||
+ #h::
|
||||
+ RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
|
||||
diff --git a/tests/example_file.hbs b/src/tests/example_file.hbs
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.hbs
|
||||
@@ -0,0 +1,2 @@
|
||||
+ <!-- TODO: Hopefully this comment turns into a todo issue -->
|
||||
+ {{!
|
||||
+ TODO: Make a handlebar templtate
|
||||
+ This is really just a test, but hopefully this works~!
|
||||
+ }}
|
||||
diff --git a/tests/example_file.org b/src/tests/example_file.org
|
||||
new file mode 100644
|
||||
index 0000000..7cccc5b
|
||||
--- /dev/null
|
||||
+++ b/src/tests/example_file.org
|
||||
@@ -0,0 +1,2 @@
|
||||
+ # TODO: Hopefully this comment turns into a todo issue
|
||||
+ #+begin_src python
|
||||
+ print("Hello World")
|
||||
+ #+end_src
|
||||
+ #+begin_comment
|
||||
+ TODO: Multiline comments
|
||||
+ also need to be turned into todos, and hopefully
|
||||
+ kept together as one todo
|
||||
+ #+end_comment
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import unittest
|
||||
import json
|
||||
from main import TodoParser
|
||||
|
||||
|
||||
@@ -15,7 +16,10 @@ class NewIssueTests(unittest.TestCase):
|
||||
# Check for newly added TODOs across the files specified.
|
||||
def setUp(self):
|
||||
diff_file = open('tests/test_new.diff', 'r')
|
||||
self.raw_issues = TodoParser().parse(diff_file)
|
||||
parser = TodoParser()
|
||||
with open('syntax.json', 'r') as syntax_json:
|
||||
parser.syntax_dict = json.load(syntax_json)
|
||||
self.raw_issues = parser.parse(diff_file)
|
||||
|
||||
def test_python_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 2)
|
||||
@@ -38,15 +42,29 @@ class NewIssueTests(unittest.TestCase):
|
||||
def test_sql_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'sql'), 1)
|
||||
|
||||
# TODO: Update tests
|
||||
# Need tests for Julia, AutoHotKey, Handlebars, Org and TeX, as these markers are not currently covered.
|
||||
def test_tex_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'tex'), 2)
|
||||
|
||||
def test_julia_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'julia'), 2)
|
||||
|
||||
def test_autohotkey_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'autohotkey'), 1)
|
||||
|
||||
def test_handlebars_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'handlebars'), 2)
|
||||
|
||||
def test_org_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'text'), 2)
|
||||
|
||||
class ClosedIssueTests(unittest.TestCase):
|
||||
# Check for removed TODOs across the files specified.
|
||||
def setUp(self):
|
||||
diff_file = open('tests/test_closed.diff', 'r')
|
||||
self.raw_issues = TodoParser().parse(diff_file)
|
||||
parser = TodoParser()
|
||||
with open('syntax.json', 'r') as syntax_json:
|
||||
parser.syntax_dict = json.load(syntax_json)
|
||||
self.raw_issues = parser.parse(diff_file)
|
||||
|
||||
def test_python_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 2)
|
||||
@@ -69,13 +87,31 @@ class ClosedIssueTests(unittest.TestCase):
|
||||
def test_sql_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'sql'), 1)
|
||||
|
||||
def test_tex_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'tex'), 2)
|
||||
|
||||
def test_julia_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'julia'), 2)
|
||||
|
||||
def test_autohotkey_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'autohotkey'), 1)
|
||||
|
||||
def test_handlebars_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'handlebars'), 2)
|
||||
|
||||
def test_org_issues(self):
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'text'), 2)
|
||||
|
||||
|
||||
class IgnorePatternTests(unittest.TestCase):
|
||||
|
||||
def test_single_ignore(self):
|
||||
os.environ['INPUT_IGNORE'] = '.*\\.java'
|
||||
diff_file = open('tests/test_new.diff', 'r')
|
||||
self.raw_issues = TodoParser().parse(diff_file)
|
||||
parser = TodoParser()
|
||||
with open('syntax.json', 'r') as syntax_json:
|
||||
parser.syntax_dict = json.load(syntax_json)
|
||||
diff_file = open('tests/test_closed.diff', 'r')
|
||||
self.raw_issues = parser.parse(diff_file)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 2)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'yaml'), 2)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'php'), 4)
|
||||
@@ -85,8 +121,11 @@ class IgnorePatternTests(unittest.TestCase):
|
||||
|
||||
def test_multiple_ignores(self):
|
||||
os.environ['INPUT_IGNORE'] = '.*\\.java, tests/example-file\\.php'
|
||||
diff_file = open('tests/test_new.diff', 'r')
|
||||
self.raw_issues = TodoParser().parse(diff_file)
|
||||
parser = TodoParser()
|
||||
with open('syntax.json', 'r') as syntax_json:
|
||||
parser.syntax_dict = json.load(syntax_json)
|
||||
diff_file = open('tests/test_closed.diff', 'r')
|
||||
self.raw_issues = parser.parse(diff_file)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 2)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'yaml'), 2)
|
||||
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'php'), 0)
|
||||
|
||||
Reference in New Issue
Block a user