From d239119609c4c0fb2921a44c17701f8c0bcdab3d Mon Sep 17 00:00:00 2001 From: Saul Gutierrez Date: Tue, 19 Mar 2024 16:16:34 -0700 Subject: [PATCH] tests: enable debugruntest for test-pager.t Summary: This test wasn't using `debugruntest` since it's one of those tests that shells out to Python for various things. Making this work on Windows required a couple of changes, as non-debugruntest tests rely on having bash and bash-like utils for running: - The test had to shell out and used the `echo` command for this. On Bash using `echo` is fine, but on Windows cmd's echo does not output a new line - Like in D54347528, `$PYTHON` could no longer be used on things hg called - Since the test was essentially running on Bash, the Python scripts this test was shelling out to could no longer use `sys.stdout.write`. - As this test was previously running essentially on Bash, the newlines from `sys.stdout.write` contained carriage returns - This was changed to use `hg dbsh` and `ui.write` instead Reviewed By: muirdm Differential Revision: D54826008 fbshipit-source-id: 16460ddd30dd8dc8a27ca66580ada8f50b774905 --- eden/scm/tests/test-pager.t | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/eden/scm/tests/test-pager.t b/eden/scm/tests/test-pager.t index 2351b61c1eb9b..f9aa54730c26d 100644 --- a/eden/scm/tests/test-pager.t +++ b/eden/scm/tests/test-pager.t @@ -1,13 +1,16 @@ +#debugruntest-compatible +#inprocess-hg-incompatible + $ eagerepo $ setconfig devel.segmented-changelog-rev-compat=true $ cat >> fakepager.py < import sys > printed = False > for line in sys.stdin: - > sys.stdout.write('paged! %r\n' % line) + > ui.write('paged! %r\n' % line) > printed = True > if not printed: - > sys.stdout.write('paged empty output!\n') + > ui.write('paged empty output!\n') > EOF Enable ui.assume-tty so that the pager will start, and set the pager to our @@ -15,7 +18,7 @@ fake pager that lets us see when the pager was running. $ setconfig ui.assume-tty=yes ui.color=no $ cat >>$HGRCPATH < [pager] - > pager = $PYTHON $TESTTMP/fakepager.py + > pager = hg dbsh $TESTTMP/fakepager.py > EOF $ hg init repo @@ -212,10 +215,19 @@ improve this. Pager works with shell aliases. +#if windows +On Windows cmd's echo is used, which prints carriage returns, so we use hg instead + + $ cat >> $HGRCPATH < [alias] + > echoa = !hg dbsh -c "ui.write('a\n')" + > EOF +#else $ cat >> $HGRCPATH < [alias] > echoa = !echo a > EOF +#endif $ hg echoa a @@ -343,13 +355,11 @@ During pushbuffer, pager should not start: Environment variables like LESS and LV are set automatically: $ cat > $TESTTMP/printlesslv.py < from __future__ import absolute_import > import os > import sys > sys.stdin.read() > for name in ['LESS', 'LV']: - > sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-'))) - > sys.stdout.flush() + > ui.write(('%s=%s\n') % (name, os.environ.get(name, '-'))) > EOF $ cat >> $HGRCPATH < [ui] > formatted=1 > [pager] - > pager = $PYTHON $TESTTMP/printlesslv.py + > pager = hg dbsh $TESTTMP/printlesslv.py > EOF $ unset LESS $ unset LV