Answer stability round 3: an empty argument separates no command, and two overrides on one line are read apart
This commit is contained in:
@@ -45,6 +45,9 @@ class Commits(unittest.TestCase):
|
||||
self.assertEqual(len(commits("cat <<EOF > notes\nhello\nEOF\ngit commit -m a", "/r")), 1)
|
||||
self.assertEqual(len(commits("git status &&\n\ngit commit -m a", "/r")), 1)
|
||||
|
||||
def test_an_empty_argument_separates_nothing(self):
|
||||
self.assertEqual(rules(command_breaches("git commit --author '' -m a -m b", "/r")), ["commit-one-line"])
|
||||
|
||||
def test_an_arithmetic_shift_is_no_heredoc(self):
|
||||
self.assertEqual(len(commits("echo $((1<<2))\ngit commit -m a\n2", "/r")), 1)
|
||||
|
||||
@@ -106,10 +109,10 @@ class FileBreaches(unittest.TestCase):
|
||||
|
||||
class Overrides(unittest.TestCase):
|
||||
def test_a_marker_names_a_known_rule_and_a_reason(self):
|
||||
self.assertEqual(overrides("x # rule-override image-pin: vendor ships floating tags only\n# rule-override nope: x\n# rule-override action-pin:"), {"image-pin": "vendor ships floating tags only"})
|
||||
self.assertEqual(overrides("x # rule-override image-pin: vendor ships floating tags only\n# rule-override nope: x\n# rule-override action-pin:"), ({"image-pin": "vendor ships floating tags only"}, ["rule-override nope: x", "rule-override action-pin: "]))
|
||||
|
||||
def test_markdown_takes_an_html_comment(self):
|
||||
self.assertEqual(overrides("<!-- rule-override no-ai-attribution: quotes the banned line -->"), {"no-ai-attribution": "quotes the banned line"})
|
||||
self.assertEqual(overrides("<!-- rule-override no-ai-attribution: quotes the banned line -->")[0], {"no-ai-attribution": "quotes the banned line"})
|
||||
|
||||
|
||||
class Hook(unittest.TestCase):
|
||||
@@ -150,8 +153,12 @@ class Hook(unittest.TestCase):
|
||||
self.assertIn("todo.md: not ranked", ran.stderr)
|
||||
|
||||
def test_a_malformed_override_is_named(self):
|
||||
ran = hook({"cwd": self.repo, "tool_input": {"command": "git commit -m a -m b # rule-override commit-oneline: x"}, "tool_name": "Bash"}, self.repo)
|
||||
self.assertIn("names no rule below, or gives no reason", ran.stderr)
|
||||
ran = hook({"cwd": self.repo, "tool_input": {"command": f"git commit -m a -m b -m '{TRAILER}' # rule-override no-ai-attribution: quotes it # rule-override commit-oneline: x"}, "tool_name": "Bash"}, self.repo)
|
||||
self.assertIn("`rule-override commit-oneline: x` names no rule below", ran.stderr)
|
||||
|
||||
def test_a_markdown_file_is_told_the_html_comment(self):
|
||||
ran = hook({"cwd": self.repo, "tool_input": {"content": TRAILER, "file_path": f"{self.repo}/a.md"}, "tool_name": "Write"}, self.repo)
|
||||
self.assertIn("`<!-- rule-override no-ai-attribution: <reason> -->`", ran.stderr)
|
||||
|
||||
def test_a_missing_field_breaks_nothing(self):
|
||||
for given in [{"command": None}, {"content": None, "file_path": f"{self.repo}/a.md"}, {"edits": [None], "file_path": f"{self.repo}/a.md"}]:
|
||||
|
||||
Reference in New Issue
Block a user