Skip to content

Commit 34792a9

Browse files
redsun82Copilot
andcommitted
Just: let an empty argument be an argument
Both entry points dropped empty arguments before looking at them, to absorb a caller interpolating a variable that was never set. No justfile here can produce one: a root that contributes nothing contributes no list element, so the case the filtering existed for cannot arise, and dropping arguments silently is a bad way to find out otherwise. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent c06208c commit 34792a9

4 files changed

Lines changed: 1 addition & 30 deletions

File tree

‎misc/just/codeql_test_run.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ def resolve_codeql(args: argparse.Namespace) -> Path:
117117

118118

119119
def main():
120-
# An empty argument can come from a caller interpolating an unset variable.
121-
sys.argv = [a for a in sys.argv if a]
122120
args = parse_arguments()
123121

124122
if args.all:

‎misc/just/language_tests.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818

1919
def main():
20-
# Blank arguments are dropped before the count is taken: one comes of a caller
21-
# interpolating a variable that was never set, and a list of nothing but those is no
22-
# arguments at all rather than a root to find a justfile above.
23-
argv = [arg for arg in sys.argv[1:] if arg]
20+
argv = sys.argv[1:]
2421
if not argv:
2522
print("Usage: language_tests.py ROOT [ARG...]", file=sys.stderr)
2623
return 1

‎misc/just/test_codeql_test_run.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,6 @@ def test_sorts_a_whole_command_line_at_once(self):
129129
self.assertTrue(args.all)
130130

131131

132-
class TestEmptyArguments(unittest.TestCase):
133-
"""Dropped by `main` before parsing, which is earlier than it looks.
134-
135-
Filtering these inside the sorting loop instead would leave them in front of
136-
`argparse`, and an empty argument ahead of a `--` stops the separator being
137-
recognised, so the `--` would reach `codeql test run` as an argument of its own.
138-
"""
139-
140-
def test_an_empty_argument_is_ignored(self):
141-
# One of these comes of a caller interpolating a variable that was never set.
142-
self.assertEqual(paths("", "some/test"), ["some/test"])
143-
144-
def test_an_empty_argument_does_not_disturb_a_separator(self):
145-
self.assertEqual(flags("", "--", "--check-databases")[-1], "--check-databases")
146-
self.assertNotIn("--", flags("", "--", "--check-databases"))
147-
148-
149132
class TestOfferedChecks(unittest.TestCase):
150133
"""What a root offers and what `--all-checks` enables are separate things.
151134

‎misc/just/test_language_tests.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ def test_needs_a_root(self):
109109
self.assertEqual(status, 1)
110110
run.assert_not_called()
111111

112-
def test_nothing_but_blank_arguments_is_no_arguments(self):
113-
# An unset variable interpolated by a caller arrives as one of these. Counting
114-
# it as an argument and then dropping it left nothing to take a root from.
115-
status, run, _ = self.run_main("", "")
116-
self.assertEqual(status, 1)
117-
run.assert_not_called()
118-
119112
def test_reports_a_root_with_no_justfile_above_it(self):
120113
orphan = self.semmle_code / "elsewhere"
121114
orphan.mkdir()

0 commit comments

Comments
 (0)