Merge pull request #3919 from GalaxyGamingFR/fix/stubgen-stdout-newlines
fix(stubgen): write LF to stdout on Windows
This commit is contained in:
commit
4008e68e39
|
|
@ -102,6 +102,8 @@ if(BUILD_TESTING)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_stubgen.py)
|
||||
add_test(NAME debt_split COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_debt_split.py)
|
||||
add_test(NAME stubgen_stdout_newlines COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_stubgen_stdout_newlines.py)
|
||||
add_test(NAME hardware_oracle COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/hw-oracle/test_hw_oracle.py)
|
||||
add_test(NAME pr_overlap_exports COMMAND ${Python3_EXECUTABLE}
|
||||
|
|
|
|||
|
|
@ -211,6 +211,8 @@ def main(argv=None):
|
|||
ap.add_argument("--td-out", required=False, default=None, help="output file for TechnicalDebt lines, which go in docs/dev/debt/MODULE.md, default stderr when code uses stdout, otherwise stdout")
|
||||
ap.add_argument("--td-only", action="store_true", help="print only TechnicalDebt lines, no code")
|
||||
args = ap.parse_args(argv)
|
||||
if hasattr(sys.stdout, "reconfigure"):
|
||||
sys.stdout.reconfigure(encoding="utf-8", newline="\n")
|
||||
try:
|
||||
if not args.td_only and args.out and args.td_out and same_file(args.out, args.td_out):
|
||||
ap.error("--out and --td-out must name different files")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
tools = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class StubgenStdoutNewlineTests(unittest.TestCase):
|
||||
def run_stubgen(self, *extra):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
nids = Path(d) / "nids.txt"
|
||||
nids.write_text("AC1FtjqMCL0\n", encoding="utf-8", newline="\n")
|
||||
return subprocess.run(
|
||||
[sys.executable, str(tools / "stubgen.py"), "--module", "libkernel", "--nids", str(nids)] + list(extra),
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
def test_code_on_stdout_uses_lf(self):
|
||||
result = self.run_stubgen()
|
||||
self.assertIn(b"\n", result.stdout)
|
||||
self.assertNotIn(b"\r\n", result.stdout)
|
||||
|
||||
def test_td_only_on_stdout_uses_lf(self):
|
||||
result = self.run_stubgen("--td-only")
|
||||
self.assertIn(b"\n", result.stdout)
|
||||
self.assertNotIn(b"\r\n", result.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in New Issue