Merge branch 'master' into master

This commit is contained in:
Alastair Mooney
2024-09-25 12:54:20 +01:00
committed by GitHub
16 changed files with 1483 additions and 514 deletions

View File

@@ -0,0 +1,40 @@
[
{
"language": "ILS",
"extensions": [
".ils"
],
"markers": [
{
"type": "line",
"pattern": "//"
},
{
"type": "block",
"pattern": {
"start": "/\\*",
"end": "\\*/"
}
}
]
},
{
"language": "Java",
"extensions": [
".java2"
],
"markers": [
{
"type": "line",
"pattern": "////"
},
{
"type": "block",
"pattern": {
"start": "+=",
"end": "=+"
}
}
]
}
]

View File

@@ -153,12 +153,17 @@ index 0000000..7cccc5b
--- /dev/null
+++ b/src/tests/example_file.jl
@@ -0,0 +1,2 @@
- # TODO: Hopefully this comment turns into an issue
- #TODO: Hopefully this comment turns into an issue
- # TODO: Hopefully this comment also turns into an issue
- print("Hello World")
- #= TODO: Multiline comments
- also need to be turned into task, and hopefully
- kept together as one.
- =#
- #=TODO: Another copied multiline comment
- also need to be turned into task, and hopefully
- kept together as one.
- =#
diff --git a/tests/defs.bzl b/tests/defs.bzl
index 525e25d..ba4e68d 100644
--- a/tests/defs.bzl
@@ -384,11 +389,106 @@ index 6b0c6cf..b37e70a 100644
-' TODO: remove feature to prevent legal issues
-Public Sub Plagiarize()
+Public Sub MakeOriginalIdea()
diff --git a/tests/example.sht b/tests/example.sht
index 6b0c6cf..b37e70a 100644
--- a/tests/example.sht
+++ b/tests/example.sht
@@ -1,2 +1,1 @@
-' TODO: switch to tea
-Public Sub MakeCoffee()
+Public Sub MakeTea()
diff --git a/tests/example.cu b/tests/example.cu
index 0000000..a6c6cb0
--- /dev/null
+++ b/tests/example.cu
@@ -1,9 +1,5 @@
-// TODO rename this function
__global__ void test() {
- /*
- TODO fill this with something useful
- */
}
diff --git a/tests/Makefile b/tests/Makefile
index 2996176..7545ccf 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,12 +1,9 @@
-# TODO change name.
NAME = asm
-# TODO source files must be explicitly named.
SRC = $(shell find mandatory/src -name "*.asm")
OBJ = $(patsubst src/%.asm, obj/%.o, $(SRC))
.PHONY: all
all: $(NAME)
$(NAME): $(OBJ)
- # TODO create the directory.
$(AR) rc $@ $(OBJ)
diff --git a/tests/example_file.liquid b/tests/example_file.liquid
index 0000000..7cccc5b 100644
--- a/tests/example_file.liquid
+++ b/tests/example_file.liquid
@@ -1,6 +0,0 @@
-{% comment %} TODO: remove loop logic {% endcomment %}
{% for i in (1..3) -%}
- # TODO: Do math here!
- # labels: help wanted
{{ i }}
{% endfor %}
-{% comment %}
-TODO: Render Liquid file
{% assign featured_product = all_products["product_handle"] %}
{% render "product", product: featured_product %}
-{% endcomment %}
diff --git a/tests/example_file.tsx b/tests/example_file.tsx
index 0000000..7cccc5b 100644
--- a/tests/example_file.tsx
+++ b/tests/example_file.tsx
@@ -1,7 +1,3 @@
-// TODO: rename component
-export default async function Component() {
+export default async function MyComponent() {
- /* TODO: Use state here
- labels: client */
+ const [data, setData] = useState<string>("");
return (
<div>
- {/*
- TODO: use styled component library
- */}
+ <StyledComponent>{data}</StyledComponent>
</div>
);
}
diff --git a/src/Swarm/Game/example.purs b/src/Swarm/Game/example.purs
index 525e25d..ba4e68d 100644
--- a/src/Swarm/Game/example.purs
+++ b/src/Swarm/Game/example.purs
@@ -1,14 +0,0 @@
--- | Standard devices that are always installed.
---
--- TODO: Remove standard devices
--- In the future, make a way to build these and just start the base
--- out with a large supply of each?
--- labels: redesign
-stdDeviceList =
- ["treads", "grabber", "solar panel", "scanner", "plasma cutter"]
-
-{- | Very complicated function.
-
-TODO: Create an issue for TODO
--}
-sum a b = a + b
diff --git a/src/Swarm/Game/example.agda b/src/Swarm/Game/example.agda
index 525e25d..ba4e68d 100644
--- a/src/Swarm/Game/example.agda
+++ b/src/Swarm/Game/example.agda
@@ -1,14 +0,0 @@
--- | Standard devices that are always installed.
---
--- TODO: Remove standard devices
--- In the future, make a way to build these and just start the base
--- out with a large supply of each?
--- labels: redesign
-stdDeviceList =
- ["treads", "grabber", "solar panel", "scanner", "plasma cutter"]
-
-{- | Very complicated function.
-
-TODO: Create an issue for TODO
--}
-sum a b = a + b

19
tests/test_escape.diff Normal file
View File

@@ -0,0 +1,19 @@
diff --git a/tests/ExampleFile.java b/tests/ExampleFile.java
index d340f6a..29b54da 100644
--- a/tests/ExampleFile.java
+++ b/tests/ExampleFile.java
@@ -0,0 +1,13 @@
+package com.mydomain.myapp;
+
+public class JavaTests {
+ // TODO: Some Java
+ // # Some title
+ // <SomeTag>
+
+ /*
+ TODO: Definitely some Java
+ # Another title
+ <AnotherTag>
+ */
+}
\ No newline at end of file

View File

@@ -201,6 +201,20 @@ index 0000000..525e25d
+ # This function should probably do something more interesting
+ # labels: help wanted
+ pass
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
new file mode 100644
index 0000000..525e25d
--- /dev/null
+++ b/tests/BUILD.bazel
@@ -0,0 +1,23 @@
+def hello_world():
+ # TODO: Come up with a more imaginative greeting
+ print('Hello world')
+
+ # TODO: Do more stuff
+ # This function should probably do something more interesting
+ # labels: help wanted
+ pass
diff --git a/tests/example_file.ahk b/src/tests/example_file.ahk
new file mode 100644
index 0000000..7cccc5b
@@ -424,10 +438,111 @@ index 6b0c6cf..b37e70a 100644
@@ -1,1 +1,2 @@
+' TODO: remove feature to prevent legal issues
Public Sub Plagiarize()
diff --git a/tests/example.sht b/tests/example.sht
index 6b0c6cf..b37e70a 100644
--- a/tests/example.sht
+++ b/tests/example.sht
@@ -1,1 +1,2 @@
+' TODO: switch to tea
Public Sub MakeCoffee()
diff --git a/tests/example.cu b/tests/example.cu
new file mode 100644
index 0000000..a6c6cb0
--- /dev/null
+++ b/tests/example.cu
@@ -1,3 +1,11 @@
+
+// TODO rename this function
+__global__ void test() {
+ /*
+ TODO fill this with something useful
+ */
+}
+
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..2996176
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,12 @@
+# TODO change name.
+NAME = asm
+
+# TODO source files must be explicitly named.
+SRC = $(shell find mandatory/src -name "*.asm")
+OBJ = $(patsubst src/%.asm, obj/%.o, $(SRC))
+.PHONY: all
+all: $(NAME)
+$(NAME): $(OBJ)
+ # TODO create the directory.
+ $(AR) rc $@ $(OBJ)
+
diff --git a/tests/example_file.liquid b/tests/example_file.liquid
new file mode 100644
index 0000000..7cccc5b
--- /dev/null
+++ b/tests/example_file.liquid
@@ -0,0 +1,11 @@
+{% comment %} TODO: remove loop logic {% endcomment %}
+{% for i in (1..3) -%}
+ # TODO: Do math here!
+ # labels: help wanted
+ {{ i }}
+{% endfor %}
+{% comment %}
+TODO: Render Liquid file
+{% assign featured_product = all_products["product_handle"] %}
+{% render "product", product: featured_product %}
+{% endcomment %}
diff --git a/tests/example_file.tsx b/tests/example_file.tsx
new file mode 100644
index 0000000..7cccc5b
--- /dev/null
+++ b/tests/example_file.tsx
@@ -0,0 +1,13 @@
+// TODO: rename component
+export default async function Component() {
+ /* TODO: Use state here
+ labels: client */
+
+ return (
+ <div>
+ {/*
+ TODO: use styled component library
+ */}
+ </div>
+ );
+}
diff --git a/src/Swarm/Game/example.purs b/src/Swarm/Game/example.purs
new file mode 100644
index 0000000..0ce9b1a
--- /dev/null
+++ b/src/Swarm/Game/example.purs
@@ -0,0 +1,14 @@
+-- | Standard devices that are always installed.
+--
+-- TODO: Remove standard devices
+-- In the future, make a way to build these and just start the base
+-- out with a large supply of each?
+-- labels: redesign
+stdDeviceList =
+ ["treads", "grabber", "solar panel", "scanner", "plasma cutter"]
+
+{- | Very complicated function.
+
+TODO: Create an issue for TODO
+-}
+sum a b = a + b
diff --git a/src/Swarm/Game/example.agda b/src/Swarm/Game/example.agda
new file mode 100644
index 0000000..0ce9b1a
--- /dev/null
+++ b/src/Swarm/Game/example.agda
@@ -0,0 +1,14 @@
+-- | Standard devices that are always installed.
+--
+-- TODO: Remove standard devices
+-- In the future, make a way to build these and just start the base
+-- out with a large supply of each?
+-- labels: redesign
+stdDeviceList =
+ ["treads", "grabber", "solar panel", "scanner", "plasma cutter"]
+
+{- | Very complicated function.
+
+TODO: Create an issue for TODO
+-}
+sum a b = a + b

View File

@@ -23,8 +23,8 @@ class NewIssueTests(unittest.TestCase):
self.raw_issues = parser.parse(diff_file)
def test_python_issues(self):
# Includes 2 tests for Starlark.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 6)
# Includes 4 tests for Starlark.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 8)
def test_yaml_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'yaml'), 2)
@@ -35,11 +35,9 @@ class NewIssueTests(unittest.TestCase):
def test_java_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'java'), 2)
def test_json_with_comments_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)
def test_json5_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)
def test_javascript_issues(self):
# Includes 1 test for JSON with Comments, 1 test for JSON5, 3 tests for TSX.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 5)
def test_ruby_issues(self):
# Includes 2 tests for Crystal.
@@ -58,7 +56,7 @@ class NewIssueTests(unittest.TestCase):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'julia'), 2)
def test_starlark_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 6)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 8)
def test_autohotkey_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'autohotkey'), 1)
@@ -75,6 +73,9 @@ class NewIssueTests(unittest.TestCase):
def test_twig_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'twig'), 2)
def test_makefile_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'makefile'), 3)
def test_md_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'markdown'), 8)
@@ -82,7 +83,7 @@ class NewIssueTests(unittest.TestCase):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'r'), 2)
def test_haskell_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'haskell'), 2)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'haskell'), 4)
def test_clojure_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'clojure'), 2)
@@ -93,6 +94,11 @@ class NewIssueTests(unittest.TestCase):
def test_xaml_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'xml'), 2)
def test_c_cpp_like_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'c_cpp'), 2)
def test_liquid_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'liquid'), 3)
class ClosedIssueTests(unittest.TestCase):
# Check for removed TODOs across the files specified.
@@ -130,16 +136,14 @@ class ClosedIssueTests(unittest.TestCase):
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)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'julia'), 4)
def test_starlark_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'python'), 5)
def test_json_with_comments_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)
def test_json5_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 2)
def test_javascript_issues(self):
# Includes 1 test for JSON with Comments, 1 test for JSON5, 3 tests for TSX.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'javascript'), 5)
def test_autohotkey_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'autohotkey'), 1)
@@ -156,6 +160,9 @@ class ClosedIssueTests(unittest.TestCase):
def test_twig_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'twig'), 2)
def test_makefile_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'makefile'), 3)
def test_md_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'markdown'), 8)
@@ -163,7 +170,7 @@ class ClosedIssueTests(unittest.TestCase):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'r'), 2)
def test_haskell_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'haskell'), 2)
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'haskell'), 4)
def test_clojure_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'clojure'), 2)
@@ -173,6 +180,13 @@ class ClosedIssueTests(unittest.TestCase):
def test_xaml_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'xml'), 2)
def test_c_cpp_like_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'c_cpp'), 2)
def test_liquid_issues(self):
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'liquid'), 3)
class IgnorePatternTests(unittest.TestCase):
@@ -205,3 +219,71 @@ class IgnorePatternTests(unittest.TestCase):
# Includes 2 tests for Crystal.
self.assertEqual(count_issues_for_file_type(self.raw_issues, 'ruby'), 5)
os.environ['INPUT_IGNORE'] = ''
class EscapeMarkdownTest(unittest.TestCase):
def test_simple_escape(self):
os.environ['INPUT_ESCAPE'] = 'true'
parser = TodoParser()
with open('syntax.json', 'r') as syntax_json:
parser.syntax_dict = json.load(syntax_json)
diff_file = open('tests/test_escape.diff', 'r')
# I had no other idea to make these checks dynamic.
self.raw_issues = parser.parse(diff_file)
self.assertEqual(len(self.raw_issues), 2)
issue = self.raw_issues[0]
self.assertEqual(len(issue.body), 2)
self.assertEqual(issue.body[0], '\\# Some title')
self.assertEqual(issue.body[1], '\\<SomeTag\\>')
issue = self.raw_issues[1]
self.assertEqual(len(issue.body), 2)
self.assertEqual(issue.body[0], '\\# Another title')
self.assertEqual(issue.body[1], '\\<AnotherTag\\>')
class CustomLanguageTest(unittest.TestCase):
def test_custom_lang_load(self):
os.environ['INPUT_LANGUAGES'] = 'tests/custom_languages.json'
parser = TodoParser()
# Test if the custom language ILS is actually loaded into the system
self.assertIsNotNone(parser.languages_dict['ILS'])
self.assertEqual(self.count_syntax(parser, 'ILS'), 1)
def test_custom_lang_not_dupplicate(self):
os.environ['INPUT_LANGUAGES'] = 'tests/custom_languages.json'
parser = TodoParser()
# Test if a custom language can overwrite the rules of an existing one
self.assertEqual(self.count_syntax(parser, 'Java'), 1)
for syntax in parser.syntax_dict:
if syntax['language'] == 'Java':
self.assertEqual(len(syntax['markers']), 2)
self.assertEqual(syntax['markers'][0]['pattern'], "////")
self.assertEqual(syntax['markers'][1]['pattern']['start'], '+=')
self.assertEqual(syntax['markers'][1]['pattern']['end'], '=+')
break
self.assertIsNotNone(parser.languages_dict['Java'])
self.assertEqual(len(parser.languages_dict['Java']['extensions']), 1)
self.assertEqual(parser.languages_dict['Java']['extensions'][0], ".java2")
def test_url_load(self):
os.environ['INPUT_LANGUAGES'] = 'https://raw.githubusercontent.com/alstr/todo-to-issue-action/master/tests/custom_languages.json'
os.environ['INPUT_NO_STANDARD'] = 'true'
parser = TodoParser()
self.assertEqual(len(parser.languages_dict), 2)
self.assertEqual(len(parser.syntax_dict), 2)
@staticmethod
def count_syntax(parser: TodoParser, name: str):
counter = 0
for syntax in parser.syntax_dict:
if syntax['language'] == name:
counter = counter + 1
return counter