* fix: a default Windows clone keeps pinned files byte for byte; LoRA test no longer depends on TEMP (#636) Git for Windows converts text files to CRLF on checkout by default, so a fresh clone failed npm run --prefix tools/vendor check with Viewer.js drift. .gitattributes now marks the pinned Viewer.js, Toolkit and concept stylesheet files as never converted, and a test holds that for every tracked file under them. .gitattributes stays out of the Registry package. test_preview_writes_nothing_and_makes_no_requests expected the full settings path, which only holds when the temp folder is outside the home folder. On Windows %TEMP% is under the profile, so the review showed ~\... and the test failed. It now pins the home folder beside the temp root. * fix(tests): the Built-in instructions test reads Python source with either line ending (#636) In a default Windows clone py/tagging_defaults.py is checked out with CRLF, so the test's search for the closing paren missed and JSON.parse failed on a carriage return: 1453 of 1454 frontend tests passed. The test now normalizes CRLF before it slices the source. * fix(tests): two more Windows machine failures: killed test servers, nearby ComfyUI (#636) On a Windows machine with a virtual environment, the tests that start tests/browser/server.py failed their cleanup with WinError 32 on the server's log file, 3 of 3 runs. The venv's python.exe is a launcher that runs the real interpreter as a child; killing the launcher returns while Windows is still ending that child. The temp folder is now removed by remove_when_released, which waits until the files are released, up to 30 s. CI never saw it: its Windows job runs a plain interpreter. The diagnostics tests that expect no output folder ran in the temp root, so the fallback's ../../ComfyUI/output could reach a real ComfyUI next to it. They now run two folders deep inside the temp folder. * docs(testing): what a Windows development machine needs for the suite (#636) * fix(tests): one import style in test_process_cleanup; the line-ending test ignores GIT_* (#636) Code quality flagged unittest imported both ways. The line-ending test shells out to git, which inside the pre-push hook would follow the exported GIT_DIR; it now runs git without GIT_* variables, proved with GIT_DIR and GIT_INDEX_FILE pointing at a decoy repository that stays untouched.
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
"""Pinned files keep their bytes in every clone (#636).
|
|
|
|
``npm run --prefix tools/vendor check`` compares the vendored Viewer.js and
|
|
ComfyAssets Toolkit files, and the workspace's copy of the concept
|
|
stylesheet, with recorded hashes. Git for Windows converts text files to CRLF
|
|
on checkout by default, which changes those bytes, so ``.gitattributes`` marks
|
|
them as never converted. This holds that for every tracked file under them.
|
|
"""
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess # nosec B404 - fixed git arguments, no shell
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PINNED = (
|
|
"web/lib/viewerjs",
|
|
"web/js/shared/toolkit",
|
|
"web/js/workspace/concept.css",
|
|
"docs/concepts/workspace/style.css",
|
|
)
|
|
|
|
|
|
def _git(*args: str) -> str:
|
|
# Without GIT_* variables: the pre-push hook exports GIT_DIR and
|
|
# GIT_INDEX_FILE, which must not choose the repository read here.
|
|
env = {
|
|
key: value for key, value in os.environ.items() if not key.startswith("GIT_")
|
|
}
|
|
return subprocess.run( # nosec B603 B607 - fixed git arguments, no shell
|
|
["git", *args], cwd=ROOT, env=env, check=True, capture_output=True, text=True
|
|
).stdout
|
|
|
|
|
|
@unittest.skipUnless(
|
|
shutil.which("git") and (ROOT / ".git").exists(), "needs a git checkout"
|
|
)
|
|
class TestPinnedLineEndings(unittest.TestCase):
|
|
def test_every_pinned_file_is_never_converted(self):
|
|
files = _git("ls-files", "-z", "--", *PINNED).split("\0")
|
|
files = [name for name in files if name]
|
|
self.assertGreater(len(files), 8, files)
|
|
report = _git("check-attr", "-z", "text", "--", *files).split("\0")
|
|
# -z output: path, attribute, value, repeated.
|
|
values = dict(zip(report[0::3], report[2::3]))
|
|
for name in files:
|
|
with self.subTest(path=name):
|
|
self.assertEqual(values[name], "unset")
|
|
|
|
def test_the_repository_stores_them_with_lf(self):
|
|
report = _git("ls-files", "--eol", "--", *PINNED).splitlines()
|
|
self.assertTrue(report)
|
|
for line in report:
|
|
with self.subTest(line=line):
|
|
self.assertNotIn("i/crlf", line)
|
|
self.assertNotIn("i/mixed", line)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|