Per @guill review on PR #13425: add tests covering Windows-style line
endings, since editors often save files with CRLF and we want to confirm
the CR never leaks into the returned value.
- `_write_env_file` now opens with `newline=""` so the on-disk bytes
match the literal string passed in (deterministic across host OSes,
no `\n` -> `\r\n` translation on Windows).
New tests:
- `test_crlf_line_ending`: `"...\r\n"` -> value (no trailing CR).
- `test_crlf_multiline_only_first_line_used`: `readline(128)` stops at
the translated newline boundary for CRLF lines.
- `test_crlf_with_surrounding_whitespace`: leading/trailing spaces +
CRLF still yield the bare value.
- `test_lone_cr_line_ending`: classic-Mac / legacy editor `"...\r"`
is also handled by universal-newlines decoding.
15/15 unit tests pass.
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df5a8-36be-7107-a4af-c7e4f51687df
folder_paths.base_path is overridden by --base-directory to a user-supplied
location. Launchers/installers write the .comfy_environment marker next to the
ComfyUI install itself, so reading from base_path would silently fall back to
'local-git' whenever --base-directory is in use, defeating the purpose of the
env header.
Amp-Thread-ID: https://ampcode.com/threads/T-019df554-0cf8-755a-9f84-674e974aa5d1
Co-authored-by: Amp <amp@ampcode.com>
Default value is now 'local-git' (was 'local_git'). Dashes are easier to type and more conventional in HTTP-header-adjacent identifiers. Tests updated accordingly.
Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
Replaces the hand-rolled '_cached_value' module global with @functools.cache, which is the standard Python idiom for memoization. Tests now use the built-in get_deploy_environment.cache_clear() to reset between cases.
Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
Defense-in-depth: cap readline() so a malformed or maliciously-large single-line file cannot blow up memory before the value is sanitized.
Adds tests-unit/deploy_environment_test.py covering: missing file fallback, basic read, whitespace strip, multi-line (only first line used), empty + whitespace-only files, control-char stripping (header-injection protection), non-ASCII stripping, 128-byte read cap, cache stickiness, and OSError fallback.
Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>