Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tools: gen_tables.py quotes the path it could not read

xbsheng9bc6ae9cb270
diff --git a/tests/test_gen_tables_inputs.py b/tests/test_gen_tables_inputs.py
index 445f71378..5acd20580 100644
--- a/tests/test_gen_tables_inputs.py
+++ b/tests/test_gen_tables_inputs.py
@@ -56,6 +56,14 @@ class RootTest(unittest.TestCase):
self.assertIn("not a folder", err)
self.assertEqual(out, "")
+ def test_the_root_it_could_not_read_is_quoted(self):
+ # Quoted, so the line shows the path it was handed even when that token is empty or has spaces in it.
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp) / "no such checkout"
+ code, _, err = run("--root", str(root), "--check")
+ self.assertEqual(code, 2, err)
+ self.assertIn(f"--root '{root}'", err)
+
def test_a_folder_that_is_not_a_checkout_names_what_is_missing(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp) / "empty"
@@ -74,7 +82,9 @@ class RootTest(unittest.TestCase):
code, out, err = run("--root", str(root), "--check")
self.assertEqual(code, 2, err)
self.assertIn("no tools/readme_stats.py in it", err)
- self.assertNotIn("examples/", err)
+ # The other four paths must not be named as missing: pin the phrase, not a bare "examples/",
+ # since the line also carries the root, whose path a runner could one day spell with it.
+ self.assertNotIn("no examples/", err)
def test_a_refused_root_is_never_the_out_of_date_exit(self):
# The one thing a weekly job and the README-tables job both read as a real finding.
@@ -118,6 +128,17 @@ class AdoptTest(unittest.TestCase):
self.assertIn("Nothing was written", err)
self.assertEqual(out, "")
+ def test_an_empty_patch_path_is_still_named_in_the_line(self):
+ # `--adopt ''` (or a stray pair of quotes) leaves the token empty: quoted, the line still shows what
+ # it tried to read instead of "cannot read : No such file or directory".
+ with tempfile.TemporaryDirectory() as tmp:
+ root = valid(tmp)
+ code, out, err = run("--root", str(root), "--adopt", "")
+ self.assertEqual(code, 2, err)
+ self.assertIn("cannot read ''", err)
+ self.assertIn("Nothing was written", err)
+ self.assertEqual(out, "")
+
def test_the_root_is_judged_before_the_patch_is_applied(self):
# A readable patch and a root with nothing of the repository in it: no tv.json may appear.
with tempfile.TemporaryDirectory() as tmp:
diff --git a/tools/gen_tables.py b/tools/gen_tables.py
index 3a1bf42a2..514995518 100644
--- a/tools/gen_tables.py
+++ b/tools/gen_tables.py
@@ -288,12 +288,12 @@ def read_inputs(root, patch):
says the generated files are stale when in fact nothing was read at all.
"""
if not root.is_dir():
- return None, f"--root {root}: not a folder. Nothing was read or written."
+ return None, f"--root '{root}': not a folder. Nothing was read or written."
# examples/ is what it reads; the three OWNED files are the parts of the checkout it writes.
needs = ["examples"] + list(OWNED)
missing = [f"{n}/" if n == "examples" else n for n in needs if not (root / n).exists()]
if missing:
- return None, (f"--root {root}: no {', no '.join(missing)} in it. Point --root at a checkout of this "
+ return None, (f"--root '{root}': no {', no '.join(missing)} in it. Point --root at a checkout of this "
f"repository: nothing was read or written.")
if patch is None:
return None, None
@@ -301,7 +301,8 @@ def read_inputs(root, patch):
return Path(patch).read_text(encoding="utf-8"), None
except OSError as e:
# A path that is a directory is OSError too (IsADirectoryError), so this covers a patch folder.
- return None, f"--adopt: cannot read {patch}: {e.strerror}. Nothing was written."
+ # The path is quoted so an empty --adopt ('' or a stray pair of quotes) is visible in the line.
+ return None, f"--adopt: cannot read '{patch}': {e.strerror}. Nothing was written."
def main(argv=None):