mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 08:58:36 +00:00
ci: preserve Unicode separators in standalone test filenames
This commit is contained in:
@ -56,7 +56,8 @@ def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("-j", "--jobs", type=positive_int, default=1, help="files at a time (default: 1)")
|
||||
args = parser.parse_args(argv)
|
||||
return run_tests([path for path in sys.stdin.read().splitlines() if path], args.jobs)
|
||||
# Unicode line separators can occur in filenames. Only stdin's newlines separate paths.
|
||||
return run_tests([path for path in sys.stdin.read().split("\n") if path], args.jobs)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -66,5 +67,5 @@ if __name__ == "__main__":
|
||||
# GitHub Actions reads annotations as UTF-8, including on Windows.
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
# Git Bash writes its find/printf paths as UTF-8, even on Windows.
|
||||
sys.stdin.reconfigure(encoding="utf-8")
|
||||
sys.stdin.reconfigure(encoding="utf-8", newline=None)
|
||||
sys.exit(main())
|
||||
|
||||
@ -62,6 +62,24 @@ class StandaloneRunnerTest(unittest.TestCase):
|
||||
self.assertIn(f"== {name}".encode(), result.stdout.splitlines())
|
||||
self.assertIn(f"::error file={name}::{name} failed".encode(), result.stdout.splitlines())
|
||||
|
||||
def test_only_newlines_separate_test_paths(self):
|
||||
names = ["test_before\u2028after.py", "test_before\u0085after.py"]
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
for index, name in enumerate(names):
|
||||
(Path(tmp) / name).write_bytes(f"print('child {index} ran')\n".encode())
|
||||
for separator in ("\n", "\r\n"):
|
||||
with self.subTest(separator=separator):
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-I", str(RUNNER), "-j", "2"],
|
||||
cwd=tmp, input=separator.join(names).encode("utf-8"),
|
||||
capture_output=True, timeout=30,
|
||||
)
|
||||
output = result.stdout.decode("utf-8").replace("\r\n", "\n")
|
||||
self.assertEqual(result.returncode, 0, output + result.stderr.decode("utf-8"))
|
||||
for index, name in enumerate(names):
|
||||
self.assertIn(f"== {name}\nchild {index} ran\n", output)
|
||||
self.assertIn("2 files, 0 files failed", output)
|
||||
|
||||
def test_bounds_concurrency_without_timing_assumptions(self):
|
||||
lock = threading.Lock()
|
||||
rendezvous = threading.Barrier(2)
|
||||
|
||||
Reference in New Issue
Block a user